websocket on ruby
oneplaylist.fm beta use case
The Stack
• ruby on rails
• redis
• ruby-eventmachine
• HA-Proxy
Other on Stack
• Resque: background processing in rails
• mongodb
• coffeescript js heavy
• elasticsearch (tire ruby gem)
HA-Proxy
• tcp level load balancer
• handle http level too
• super fast, and so on.....
• high availaibility made easy
HA-Proxy stack
• HA-Proxy -> 3 ruby on rails front
• HA-Proxy -> 3 elasticsearch instance
(direct from coffee)
• HA-Proxy ...
HA-Proxy websocket
• http://oneplaylist.fm -> app
• http://oneplaylist.fm/websocket -> tcp event
machine !!
• same ip, sam...
Redis and websocket ?
• handle stateless auth -> pass a token each
request pass from front
• redis is a central point of c...
Redis and websocket
• each token -> a user id
• after authenticate, the eventmachine tcp
session register to redis pub pip...
Rails -> redis
• Rails app write data in redis key before
pushing
• when user reconnect -> eventmachine
make a get on key ...
more infos
• http://oneplaylist.fm
• https://twitter.com/mathieuel
• http://www.mathieu-elie.net
Upcoming SlideShare
Loading in...5
×

ruby + websocket + haproxy

888

Published on

OnePlaylist prod use case on using websocket, ruby-eventmachine via a HA-Proxy loadbalancer

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
888
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

ruby + websocket + haproxy

  1. 1. websocket on ruby oneplaylist.fm beta use case
  2. 2. The Stack • ruby on rails • redis • ruby-eventmachine • HA-Proxy
  3. 3. Other on Stack • Resque: background processing in rails • mongodb • coffeescript js heavy • elasticsearch (tire ruby gem)
  4. 4. HA-Proxy • tcp level load balancer • handle http level too • super fast, and so on..... • high availaibility made easy
  5. 5. HA-Proxy stack • HA-Proxy -> 3 ruby on rails front • HA-Proxy -> 3 elasticsearch instance (direct from coffee) • HA-Proxy -> event-machine tcp level websocket
  6. 6. HA-Proxy websocket • http://oneplaylist.fm -> app • http://oneplaylist.fm/websocket -> tcp event machine !! • same ip, same domain, sub path !!!!
  7. 7. Redis and websocket ? • handle stateless auth -> pass a token each request pass from front • redis is a central point of communication: super fast and performant • PUB SUB ! -> push to websocket
  8. 8. Redis and websocket • each token -> a user id • after authenticate, the eventmachine tcp session register to redis pub pipe with key user id • all message to user from rails -> pub redis key -> eventmachine redis -> websocket / browser in real time of course
  9. 9. Rails -> redis • Rails app write data in redis key before pushing • when user reconnect -> eventmachine make a get on key and push back to browser • some part of app are render only with webscoket data -> better consistency
  10. 10. more infos • http://oneplaylist.fm • https://twitter.com/mathieuel • http://www.mathieu-elie.net
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×