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

Distributed Comet with Lift and Amazon SNS

Distributed Comet with Lift and Amazon SNS

Description of using Amazon SNS to distribute comet messages around a cluster of Liftweb machines.

Ff619670d30ebdeefd49cf10af8e3292?s=128

Richard Dallaway

October 06, 2012
Tweet

Transcript

  1. Distributed Comet with Lift and Amazon SNS Richard Dallaway @d6y

    Jono Ferguson @jonoabroad Richard@UnderscoreConsulting.com
  2. You have multiple users chatting to your server, real-time using

    comet. server1:8080 "Hi" "Hi" Load balancer for http://myapp:80 Easy. All is good in the world.
  3. You add another server. server1:8080 "Hi" "Hi" Load balancer for

    http://myapp:80 server2:8081 "yo!" "yo!" How does the "Hi" message get to the "yo" users too?
  4. Here's how...

  5. During boot, each server registers with a Simple Notification Service

    topic... server1:8080 Load balancer for http://myapp:80 server2:8081 AWS SNS: topic = "chat" Register me to "chat" R server1:/8080/ confirmed! C
  6. When someone chats, the message goes to SNS first.... server1:8080

    "Hi" Load balancer for http://myapp:80 server2:8081 AWS SNS: topic = "chat" "Hi"
  7. SNS distributes it back to all registered servers (that's what

    SNS does).... server1:8080 Load balancer for http://myapp:80 server2:8081 AWS SNS: topic = "chat" "Hi"
  8. Finally, each server can push back to all connected clients.

    server1:8080 Load balancer for http://myapp:80 server2:8081 AWS SNS: topic = "chat" "Hi" "Hi" "Hi" "Hi"
  9. Huzzah.

  10. Servers are identical. (no special per-instance configuration)

  11. Servers don't have to know about each other. (and SNS

    is cheap, fast & reliable)
  12. Doesn't have to be SNS. Anything with a publish/subscribe model

    can do this (e.g., RabbitMQ)
  13. https://github.com/SpiralArm/liftmodules-aws-sns