Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[RailsClub Moscow 2016] AnyCable

[RailsClub Moscow 2016] AnyCable

ActionCable is one of the most attractive new features in Rails 5. WebSockets out of the box – sounds pretty cool, doesn't it? Or maybe the proper question is "Is it really so good?"

Consider pros: easy configuration, application logic access through channels, JS client that just works.

And what about pros?

In my opinion, there is the only one problem (despite bugs, of course) – Ruby itself, the language that I'm fond of, but I'm not considering it as a technology for writing scalable concurrent applications. At least, not yet.

That's why I'm not going to use ActionCable in production.

Can we find a way out? Can we use the good parts of ActionCable with the power of Erlang/Golang/Whatever-you-like altogether?

My answer is "Yes, we can". And here comes AnyCable.

This presentation demonstrates the proof of concept, shows some benchmarks and shares my thoughts about the future of the idea.

Video [RU]: https://www.youtube.com/watch?v=-k7GQKuBevY
Github: https://github.com/anycable/anycable

Vladimir Dementyev

October 22, 2016
Tweet

More Decks by Vladimir Dementyev

Other Decks in Programming

Transcript

  1. Preface • In my opinion, the idea of ActionCable is

    great; web sockets the Rails way. But I'm pretty sad about implementation • AnyCable is not an alternative; it's an enhancement (or re-design)
  2. Outline • What is ActionCable? • ActionCable: the good parts

    • ActionCable: the bad parts • How does AnyCable eliminate the bad parts without losing the good parts
  3. ActionCable in a Nutshell Server Client WebSocket Client WebSocket stream

    C Broadcaster stream B stream A stream B channel X channel Y channel Z
  4. MemoryCable 20k connections MB 0 375 750 1 125 1

    500 1 875 2 250 2 625 3 000 Go Erlang ActionCable (2x) ActionCable (16x)
  5. WebSocket Shootout Broadcast RTT 0s 1s 2s 3s 4s 5s

    6s 7s 8s 9s 10s Number of connections 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Go Erlang ActionCable Running on AWS EC2 c3.4xlarge (16 vCPU, 30 GiB RAM)
  6. HowTo # Gemfile gem 'anycable', group: :production # generate server

    script rails generate anycable # run gRPC server ./bin/anycable
  7. HowTo # Gemfile gem 'anycable', group: :production # generate server

    script rails generate anycable # run gRPC server ./bin/anycable # run websocket server anycable-go -addr=0.0.0.0:3334
  8. HowTo # Gemfile gem 'anycable', group: :production # generate server

    script rails generate anycable # run gRPC server ./bin/anycable # run websocket server anycable-go -addr=0.0.0.0:3334 # config/application.rb config.action_cable.url = 'ws://0.0.0.0:3334'
  9. Compatibility Feature Status Connection Identifiers + Connection Request (cookies, params)

    + Disconnect Handling coming soon Subscribe to channels + Parameterized subscriptions + Unsubscribe from channels + Subscription Instance Variables - Performing Channel Actions + Streaming + Custom stream callbacks - Broadcasting +
  10. Compatibility Feature Status Connection Identifiers + Connection Request (cookies, params)

    + Disconnect Handling coming soon Subscribe to channels + Parameterized subscriptions + Unsubscribe from channels + Subscription Instance Variables - Performing Channel Actions + Streaming + Custom stream callbacks - Broadcasting +
  11. WebSocket Shootout Broadcast RTT 0s 1s 2s 3s 4s 5s

    6s 7s 8s 9s 10s Number of connections 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 ActionCable Patch 1 Running on AWS EC2 c3.4xlarge (16 vCPU, 30 GiB RAM)
  12. DisclaimerCable AnyCable have not been used in production yet… …because

    I have not been working with Rails 5 in production at all
  13. MemoryCable 20k connections MB 0 500 1 000 1 500

    2 000 2 500 3 000 3 500 4 000 Go Erlang anycable-go erlycable ActionCable
  14. WebSocket Shootout Broadcast RTT 0s 1s 2s 3s 4s 5s

    6s 7s 8s 9s 10s Number of connections 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Go Erlang ActionCable anycable-go erlycable Running on AWS EC2 c3.4xlarge (16 vCPU, 30 GiB RAM)