1 of 13

Distributed Comet with Lift and Amazon SNS

Richard Dallaway @d6y

Jono Ferguson @jonoabroad�

Richard@UnderscoreConsulting.com

2 of 13

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 of 13

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 of 13

Here's how...

5 of 13

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 of 13

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 of 13

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 of 13

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 of 13

Huzzah.

10 of 13

Servers are identical.

(no special per-instance configuration)

11 of 13

Servers don't have to know about each other.

(and SNS is cheap, fast & reliable)

12 of 13

Doesn't have to be SNS.

Anything with a publish/subscribe model can do this �(e.g., RabbitMQ)

13 of 13

https://github.com/SpiralArm/liftmodules-aws-sns