Distributed Comet with Lift and Amazon SNS
Richard Dallaway @d6y
Jono Ferguson @jonoabroad�
Richard@UnderscoreConsulting.com
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.
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?
Here's how...
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
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"
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"
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"
Huzzah.
Servers are identical.
(no special per-instance configuration)
Servers don't have to know about each other.
(and SNS is cheap, fast & reliable)
Doesn't have to be SNS.
Anything with a publish/subscribe model can do this �(e.g., RabbitMQ)
https://github.com/SpiralArm/liftmodules-aws-sns