Introduction

Choosing the right Action Cable adapter is one of the most impactful decisions for a production real-time application. Rails 8.1 offers three production-ready adapters — Solid Cable, Redis, and PostgreSQL — each with distinct trade-offs in throughput, operational complexity, and infrastructure requirements.

Key Concepts

  • Solid Cable Adapter: A database-backed adapter that stores messages in a dedicated table. It trims expired messages automatically and works with MySQL, SQLite, and PostgreSQL.
  • Redis Adapter: Uses Redis pub/sub for message delivery. It offers the highest throughput and is the traditional choice for high-traffic applications.
  • PostgreSQL Adapter: Uses PostgreSQL's built-in NOTIFY/LISTEN mechanism. It requires no additional infrastructure beyond your existing database.
  • Adapter Throughput: The number of messages per second an adapter can reliably deliver. Redis leads, followed by Solid Cable and PostgreSQL for typical workloads.

Real World Context

A startup with 500 concurrent users does not need Redis. Solid Cable or PostgreSQL handles their message volume with zero additional infrastructure. A social platform with 50,000 concurrent users sending thousands of messages per second needs Redis's raw throughput. Choosing the right adapter avoids both over-engineering and under-provisioning.

Deep Dive

Here is a detailed comparison of the three adapters:

Solid Cable

yaml
production:
  adapter: solid_cable
  silence_polling: true
  polling_interval: 0.1

Solid Cable polls the database for new messages at a configurable interval. The default is fast enough for most applications. It creates a solid_cable_messages table:

ruby
# db/cable_schema.rb (generated by solid_cable:install)
create_table :solid_cable_messages do |t|
  t.text :channel
  t.text :payload
  t.datetime :created_at
  t.index :channel
  t.index :created_at
end

Messages are automatically trimmed after they expire (default: 30 seconds). This keeps the table small even under sustained load.

When to use Solid Cable: Applications with low to moderate real-time traffic, teams that want to minimize infrastructure, or projects already using Solid Queue and Solid Cache.

Redis

yaml
production:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") %>
  channel_prefix: myapp_production

Redis pub/sub delivers messages instantly with no polling delay. It handles very high message volumes and is battle-tested at scale.

When to use Redis: High-traffic applications, gaming, live trading platforms, or any scenario requiring sub-millisecond message delivery.

PostgreSQL

yaml
production:
  adapter: postgresql

The PostgreSQL adapter uses NOTIFY/LISTEN, a built-in pub/sub mechanism. Messages are delivered instantly (no polling), but NOTIFY has an 8,000-byte payload limit per message.

When to use PostgreSQL: Applications already running PostgreSQL that want instant delivery without Redis, as long as message payloads stay under 8KB.

Performance Comparison

AdapterDeliveryThroughputExtra InfrastructurePayload Limit
Solid CablePollingModerateNoneDatabase row size
RedisInstantVery HighRedis server512MB
PostgreSQLInstantModerateNone8,000 bytes

Common Pitfalls

  1. Defaulting to Redis without evaluating alternatives — Many teams add Redis to their stack reflexively. For applications with moderate real-time traffic, Solid Cable or PostgreSQL eliminates an infrastructure dependency.
  2. Exceeding PostgreSQL's NOTIFY payload limit — If your broadcast payloads exceed 8KB (e.g., large HTML fragments), the PostgreSQL adapter silently truncates or fails. Monitor payload sizes if using this adapter.
  3. Running Solid Cable with too slow a polling interval — The default polling interval is fine for most cases, but setting it too high (e.g., 5 seconds) introduces noticeable latency.

Best Practices

  1. Start with Solid Cable and migrate if needed — It requires zero additional infrastructure. If monitoring shows latency or throughput issues, switching to Redis requires only a config change.
  2. Use channel_prefix with Redis — When multiple applications or environments share a Redis instance, the prefix prevents message collisions.
  3. Monitor message delivery latency — Regardless of adapter, track the time between broadcast and client receipt. This metric tells you when to upgrade.

Summary

  • Rails 8.1 offers three production adapters: Solid Cable (database-backed), Redis (pub/sub), and PostgreSQL (NOTIFY/LISTEN).
  • Solid Cable is the simplest option, requiring no additional infrastructure and handling moderate traffic well.
  • Redis provides the highest throughput and instant delivery, ideal for high-traffic applications.
  • PostgreSQL offers instant delivery without Redis but has an 8KB payload limit.
  • Start simple with Solid Cable and migrate to Redis only when monitoring reveals a need.

Code Examples

yaml
# config/cable.yml — choosing your production adapter

# Option 1: Solid Cable (simplest, no extra infrastructure)
production:
  adapter: solid_cable

# Option 2: Redis (highest throughput)
# production:
#   adapter: redis
#   url: <%= ENV.fetch("REDIS_URL") %>
#   channel_prefix: myapp_production

# Option 3: PostgreSQL (instant delivery, no extra infra)
# production:
#   adapter: postgresql
✓ Completed