Rails 8 Solid Cable: Real-Time Features Without Redis

Discover how Rails 8 leverages Solid Cable to enable real-time features without relying on Redis, simplifying development and boosting performance for modern web applications

Real-time Rails 8 application using Solid Cable without Redis

Real-time apps are no longer reserved for tech giants. Whether you're building live chat, notifications, or collaborative features, Rails 8's Solid Cable makes it easier than ever — no Redis required.

In this post, we’ll explore what Solid Cable is, how it works, why it’s a game-changer, and how you can build a real-time chat app using it — all while saving on infrastructure and setup complexity.


What is Solid Cable?

Solid Cable is a new database-backed adapter for Action Cable, introduced in Rails 8 (November 2024). It lets you build real-time features using your app’s existing database — PostgreSQL, SQLite, or MySQL — instead of relying on Redis.

This simplifies the tech stack, lowers costs, and removes the need for managing external servers.

How It Works
1. WebSocket messages are written to a database table.
2. Solid Cable polls the table (default: every 0.1s).
3. Connected clients receive broadcasts via WebSocket.


Why Solid Cable is a Game-Changer for Real-Time Rails Apps

Feature Solid Cable Redis
Infrastructure Built-in database External server
Cost Zero Cloud service fees
Setup Out of the box Additional configuration
Maintenance Low Moderate to high
Performance Excellent for most apps Slightly faster for high traffic

Supported Databases -
1. SQLite (default, great for simple production setups)
2. PostgreSQL (recommended for concurrency)
3. MySQL


Solid Cable vs Redis: Performance Benchmarks

Backend Users Poll Interval RTT Avg (ms)
SQLite (Solid Cable) 100 0.1s 135.82
SQLite (Solid Cable) 500 0.1s 271.79
Redis 100 68.95
Redis 500 87.5

Conclusion: Redis is faster on paper, but Solid Cable is fast enough for most use cases — especially when polling is set to 0.01s.

When to Use Solid Cable

Use Solid Cable if:
1. You're building MVPs, internal tools, or medium-scale apps
2. You want minimal infrastructure
3. You don’t already use Redis for jobs or caching

Stick with Redis if:
1. You need ultra-low latency and high concurrency
2. Redis is already part of your stack
3. You're building large-scale, performance-critical systems


Build a Real-Time Chat App in Rails 8 Using Solid Cable

Let’s walk through building a live chat application using Solid Cable in Rails 8 — with Turbo Streams and no Redis required.

Step 1: Create a New Rails 8 App

Run the following command to create a new Rails app:

rails new super-solid-chat -c tailwind

The -c tailwind flag adds Tailwind CSS for styling (optional).

Step 2: Create Model and Controller

Create a Chat model to store messages and a controller for handling requests:

rails g model chat message:string
rails g controller chats index create
rails db:migrate

Step 3: Configure Routes

Update config/routes.rb to define routes for the chats controller:

resources :chats, only: [:index, :create]

Step 4: Build the Controller

Modify app/controllers/chats_controller.rb to handle chat creation and display:

class ChatsController < ApplicationController
  def index
    @chats = Chat.all
  end

  def create
    @chat = Chat.new(chat_params)
    @chat.save
    head :no_content
  end

  private 

  def chat_params
    params.require(:chat).permit(:message)
  end
end

Step 5: Set Up the Views with Turbo Stream

  • Display and form partials with Turbo Stream integration
  • Auto-reset form with JavaScript
  • Include Turbo Frame & Turbo Stream helpers

Step 6: Configure Solid Cable

Solid Cable is enabled by default in Rails 8, but here’s the setup in case you need to configure it manually:

bundle add solid_cable
bin/rails solid_cable:install

Configure config/cable.yml for development:

development:
  adapter: solid_cable
  connects_to:
    database:
      writing: cable
  polling_interval: 0.1.seconds
  message_retention: 1.day

Update config/database.yml to include a separate database for Solid Cable:

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  primary:
    <<: *default
    database: storage/development.sqlite3
  cable:
    <<: *default
    database: storage/development_cable.sqlite3
    migrations_paths: db/cable_migrate

Step 7: Prepare the Database

rails db:prepare

This sets up the database, including Solid Cable’s schema.

Step 8: Enable Real-Time Broadcasting

Update app/models/chat.rb to broadcast new messages using Turbo Streams:

class Chat < ApplicationRecord
  validates :message, presence: true
  after_create_commit do
      broadcast_append_to "chats", target: "chats"
  end
end

Step 9: Test the App

Start the Rails server after asset compilation:

rails assets:precompile
rails s

Open two browser tabs and navigate to http://localhost:3000.
Send a message in one tab — it should appear instantly in the other, thanks to Solid Cable + Turbo Streams.


Inspecting Solid Cable WebSocket Messages

You can inspect stored WebSocket messages from the solid_cable_messages table using SQLite CLI or Rails console.

rails console

ActiveRecord::Base.establish_connection(Rails.configuration.database_configuration["development"]["cable"])

ActiveRecord::Base.connection.execute("SELECT id, CAST(channel AS TEXT) AS channel, CAST(payload AS TEXT) AS payload, created_at, channel_hash FROM solid_cable_messages LIMIT 5")

ActiveRecord::Base.establish_connection(:primary)

Tips to Optimize Solid Cable in Production

Recommendation Why it matters
Use PostgreSQL Better concurrency support
Tune Polling Interval Set to 0.01s for near real-time
Separate DB for Cable Keeps message polling isolated
Avoid db:drop Known issues in Rails 8.0 migrations

Use Cases for Solid Cable in Rails 8

  • Live Chat Applications
  • Real-Time Notifications
  • Collaborative Tools
  • Internal Dashboards
  • MVPs and Startup Products

FAQs

  1. Is Solid Cable the default in Rails 8?
    Yes — it replaces Redis as the default production adapter.
  2. Can I use Solid Cable with PostgreSQL?
    Absolutely. PostgreSQL is the recommended database for production use.
  3. Is it fast enough for real-time apps?
    Yes. With proper tuning, it performs well for most medium-scale apps.
  4. When should I still use Redis?
    If you need ultra-low latency or already use Redis for jobs or caching.

Final Thoughts

Solid Cable brings real-time WebSocket support to Rails 8 without Redis. It’s faster to set up, cheaper to run, and powerful enough for most modern applications.

If you’re building real-time features in Ruby on Rails, Solid Cable is your new best friend.

Build real-time Rails 8 applications with Sobonix – expert Ruby on Rails development
Build real-time Rails 8 applications with Sobonix – expert Ruby on Rails development

Build Real-Time Rails Apps With Sobonix

At Sobonix, we help startups and enterprises build modern, scalable Ruby on Rails applications with real-time features, Turbo, Hotwire, and modern UI.

Let our experts build your next Rails app → Get in touch with Sobonix