Slide 1

Slide 1 text

AnyCable Vladimir Dementyev, Evil Martians

Slide 2

Slide 2 text

RailsConf 2016

Slide 3

Slide 3 text

RailsConf 2016

Slide 4

Slide 4 text

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)

Slide 5

Slide 5 text

Outline • What is ActionCable? • ActionCable: the good parts • ActionCable: the bad parts • How does AnyCable eliminate the bad parts without losing the good parts

Slide 6

Slide 6 text

What is ActionCable?

Slide 7

Slide 7 text

ActionCable RailsConf 2015 April, 21

Slide 8

Slide 8 text

ActionCable RailsConf 2015

Slide 9

Slide 9 text

TwitterCable

Slide 10

Slide 10 text

TwitterCable

Slide 11

Slide 11 text

TwitterCable jumping the shark – начало конца или прохождение пика/наивысшей точки (популярности)

Slide 12

Slide 12 text

TutorialCable since 2015

Slide 13

Slide 13 text

since 2012 TutorialCable since 2015

Slide 14

Slide 14 text

since 2014 TutorialCable since 2015

Slide 15

Slide 15 text

CableHype

Slide 16

Slide 16 text

CableHype

Slide 17

Slide 17 text

ActionCable in a Nutshell Server Client WebSocket Client WebSocket

Slide 18

Slide 18 text

ActionCable in a Nutshell Server Client WebSocket Client WebSocket stream C Broadcaster stream B stream A stream B

Slide 19

Slide 19 text

ActionCable in a Nutshell Server Client WebSocket Client WebSocket stream C Broadcaster stream B stream A stream B channel X channel Y channel Z

Slide 20

Slide 20 text

ActionCable Channel

Slide 21

Slide 21 text

ActionCable: the good parts

Slide 22

Slide 22 text

ActionCable: Pros • Easy configuration

Slide 23

Slide 23 text

Opt-In Cable

Slide 24

Slide 24 text

Opt-In Cable

Slide 25

Slide 25 text

ActionCable: Pros • Easy configuration • Application logic access through channels

Slide 26

Slide 26 text

ActionCable: Pros • Easy configuration • Application logic access through channels • JavaScript client that just works

Slide 27

Slide 27 text

ActionCable: Pros • Easy configuration • Application logic access through channels • JavaScript client that just works

Slide 28

Slide 28 text

ActionCable: Pros • Easy configuration • Application logic access through channels • JavaScript client that just works

Slide 29

Slide 29 text

ActionCable: the bad parts

Slide 30

Slide 30 text

MemoryCable

Slide 31

Slide 31 text

MemoryCable

Slide 32

Slide 32 text

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)

Slide 33

Slide 33 text

PollingCable

Slide 34

Slide 34 text

PollingCable

Slide 35

Slide 35 text

ScarySocket

Slide 36

Slide 36 text

Performance?

Slide 37

Slide 37 text

Performance?

Slide 38

Slide 38 text

WebSocket Shootout

Slide 39

Slide 39 text

WebSocket Shootout Client Server broadcast to all message send message back

Slide 40

Slide 40 text

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)

Slide 41

Slide 41 text

WebSocket Shootout

Slide 42

Slide 42 text

WayOutCable

Slide 43

Slide 43 text

LazyCable

Slide 44

Slide 44 text

PhoenixCable

Slide 45

Slide 45 text

PhoenixCable

Slide 46

Slide 46 text

AnyCable

Slide 47

Slide 47 text

AnyCable

Slide 48

Slide 48 text

Server Channels Streams Client (Protocol) ActionCable AnyCable

Slide 49

Slide 49 text

Server Channels Streams Client (Protocol) ActionCable AnyCable

Slide 50

Slide 50 text

Server Channels Streams Client (Protocol) Separation of Concerns ActionCable AnyCable

Slide 51

Slide 51 text

Application AnyCable Client WebSocket DB

Slide 52

Slide 52 text

Application AnyCable Client WebSocket Nginx HTTP DB

Slide 53

Slide 53 text

Application AnyCable Client WebSocket Nginx HTTP DB ?

Slide 54

Slide 54 text

gRPC

Slide 55

Slide 55 text

gRPC = Google RPC

Slide 56

Slide 56 text

gRPC = Universal RPC Framework

Slide 57

Slide 57 text

gRPC = protobuf + HTTP/2

Slide 58

Slide 58 text

AnyCable gRPC

Slide 59

Slide 59 text

Application WS Client WebSocket DB HTTP/2 RPC

Slide 60

Slide 60 text

Application WS Client WebSocket DB HTTP/2 RPC Rails App + gRPC Server

Slide 61

Slide 61 text

Application WS Client WebSocket DB HTTP/2 RPC Redis Rails App + gRPC Server

Slide 62

Slide 62 text

HowTo

Slide 63

Slide 63 text

HowTo

Slide 64

Slide 64 text

AnyCable Server anycable-go erlycable

Slide 65

Slide 65 text

HowTo

Slide 66

Slide 66 text

HowTo # Gemfile gem 'anycable', group: :production

Slide 67

Slide 67 text

HowTo # Gemfile gem 'anycable', group: :production # generate server script rails generate anycable

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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'

Slide 71

Slide 71 text

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 +

Slide 72

Slide 72 text

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 +

Slide 73

Slide 73 text

ActionCable Channel

Slide 74

Slide 74 text

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)

Slide 75

Slide 75 text

WhereTo github.com/anycable

Slide 76

Slide 76 text

DisclaimerCable AnyCable have not been used in production yet…

Slide 77

Slide 77 text

DisclaimerCable AnyCable have not been used in production yet… …because I have not been working with Rails 5 in production at all

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

ActionCable CPU

Slide 80

Slide 80 text

ActionCable CPU

Slide 81

Slide 81 text

anycable-go CPU

Slide 82

Slide 82 text

anycable-go CPU

Slide 83

Slide 83 text

erlycable CPU

Slide 84

Slide 84 text

erlycable CPU

Slide 85

Slide 85 text

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)

Slide 86

Slide 86 text

FutureCable

Slide 87

Slide 87 text

FutureCable - Shared Socket Server

Slide 88

Slide 88 text

Shared Server Application A AnyCable Client WebSocket Application B Client WebSocket

Slide 89

Slide 89 text

FutureCable

Slide 90

Slide 90 text

FutureCable - Shared Socket Server - Transport Support (Fallbacks)

Slide 91

Slide 91 text

FutureCable - Shared Socket Server - Transport Support (Fallbacks) - Enhanced Analytics

Slide 92

Slide 92 text

FutureCable - Shared Socket Server - Transport Support (Fallbacks) - Enhanced Analytics - ActionCable PaaS

Slide 93

Slide 93 text

cult of martians.com

Slide 94

Slide 94 text

Let's make ActionCable suck less! Vladimir Dementyev evilmartians.com @palkan @palkan_tula