palkan_tula palkan IN A NUTSHELL 18 Server Client WebSocket Client WebSocket stream C Broadcaster stream B stream A stream B channel X channel Y channel Z
palkan_tula palkan http://equipe.com “With Action Cable, we could easily have 20+ 1GB dynos running during the weekends, with every growing memory” –Jon Stenqvist, CEO, Equipe
palkan_tula palkan –Bo “Due to code duplication and extra work, the memory consumption for hijack based solutions is higher and their performance is slower (more system calls, more context switches, etc’)..” 33 https://bowild.wordpress.com/2018/05/01/rubys-rack-push-decoupling-the-real-time-web-application-from-the-web/ THE hijack PRICE
palkan_tula palkan run Rack ::Builder.new do map '/cable' do use LiteCable ::Server ::Middleware, connection_class: Chat ::Connection run proc { |_| [200, {}, ['']] } end end 82 LiteCable
palkan_tula palkan CHANNEL 87 Many channels are as simple as that: What about not calling RPC in this case? class AnswersChannel < ApplicationCable ::Channel def follow(params) stream_from "questions/ #{params['id']}" end end
palkan_tula palkan MRUBY CHANNELS 102 RPC server responds with cacheable methods source Load these methods into mRuby VM Invoke mRuby methods instead of calling RPC
palkan_tula palkan MRUBY CHANNELS 103 RPC server responds with cacheable methods source [WIP] Load these methods into mRuby VM Invoke mRuby methods instead of calling RPC
palkan_tula palkan MRUBY CHANNELS 104 RPC server responds with cacheable methods source [WIP] Load these methods into mRuby VM Invoke mRuby methods instead of calling RPC
palkan_tula palkan mRuby vs. RPC 109 mRuby #perform call – 0.05ms RPC #perform call* – 0.7ms (In theory) we can achieve 20k APS** *local connection **action per second
palkan_tula palkan WHAT HAVE WE DONE 111 Moved low-level stuff from Ruby to Go and glued them together with gRPC Moved some logic from Ruby to Go to be executed with mRuby
palkan_tula palkan RUBY OR NOT 113 New Rack API could help us… …but won’t save us from ourselves …memory problems are likely to not go anywhere …maybe, compacting GC?