saniaxxx26
saniaxxx26

Reputation: 472

scalability of tornado websocket chat

In the tornado websocket chat example, participants are stored in the set (link) , it is convenient in the case of a single server. But if run multiple instances of the application and nginx as a load balancer, how in this case, better to store the participants?

Upvotes: 8

Views: 2218

Answers (1)

MK Yung
MK Yung

Reputation: 4581

You may consider using the pubsub feature of Redis. (link)

Edit :

When your clients log on to your chatroom, they can subscribe to a channel, say chatroom. It does not matter which tornado instances they are using. Using this module you can keep asynchronously listening to the channel.

If another client sends a message to your chatroom (that is publish a message to the channel chatroom), all tornado instances will automatically sends the messages to those who subscribed to the channel. Then you can send the message via websocket.

You can take a look at this demo for the example.

Upvotes: 6

Related Questions