Dean Christian Armada
Dean Christian Armada

Reputation: 7384

Web app with real-time messaging hangs when too many messages are being sent

I am practicing a group chat app using django channels and nginx. The problem is if I do a stress test like 300 users will send messages between 2-4 seconds within 2 minutes. The tab that has our web app will hang. How can I prevent this? Will nginx's gzip help?

Upvotes: 1

Views: 62

Answers (1)

Rubycon
Rubycon

Reputation: 18346

So from my understanding you send around 100 messages per sec during 2 mins.

The main 2 things here that can lead to CPU overload are:

  • Very intense network traffic
  • Heavy JavaScript code that renders all these messages

So you need to check both of them

For example, you can start by checking JavaScript part. Try to disable a code that shows all incoming messages in UI, so only network part will be active. See how it works. If it works good now, then you need to optimize this JavaScript part, maybe collect incoming messages in memory and show messages in UI each 3 seconds instead of each 100/1 seconds. This will save your rendering power.

Regarding network part - you can try to optimize a message payload - make it smaller.

Upvotes: 1

Related Questions