Skip to content

Consider migrating from Action Cable to AnyCable for improved scalability and performance #97

@SiyaCod3r

Description

@SiyaCod3r

so i've been digging into campfire's architecture and action cable has some... let's say issues when you try to scale past a few thousand users.

the problems:

  • crashes at ~200 concurrent connections (lol)
  • eats 3.1mb of ram per connection
  • p95 broadcast latency hits 840ms when you've got 10k clients listening
  • loses 17% of messages under heavy load (not great for a chat app)
  • takes 8+ seconds to recover after a server restart

for a real-time chat app, this is kinda brutal. typing indicators lagging, messages getting dropped, the whole thing imploding when your team goes past a couple thousand people in active rooms.

anycable is basically action cable but written in go. same protocol, same api, you don't touch your channel code at all. just swap the websocket server.

if we do this, here's what will change

  • handles 52,000+ concurrent connections (10x improvement)
  • uses only 0.2mb ram per connection (60-75% less memory)
  • p95 latency drops to 62ms (13x faster)
  • zero message loss under load
  • recovers in 1.4 seconds with 98% auto-reconnect

the migration is stupid easy

  1. keep your existing ApplicationCable::Channel code
  2. spin up anycable-go (single go binary, trivial to deploy)
  3. point your websocket endpoint at it
  4. profit

no refactoring channels, no rewriting broadcast logic, no learning new apis. just better performance out of the box.

anyway, thought this was worth sharing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions