How to manage many types of notifications in django channels

I am creating a chat like app where these live events could happen:

  • A new message is sent in the currently opened chat
  • A new message is sent in another chat (however, the user should be able to see the latest message of each discussion in real time. Kind of like messenger.com)
  • A new conversation is created with the user (can be initiated by another user)
  • A conversation is deleted (can be initiated by another user)
  • An unrelated notification is received

Since my app is not only a chat app, some of these might only be used in certain parts of the website. For instance, there is no need to listen for new messages sent while we are in profile settings (unless maybe for notification purposes).

My problem is that I dont know how to manage all these events efficiently. I read that having more than 2 websocket connections on client side is a bad practice. Therefore, having a different consumer/websocket connection for each of them wouldnt work. I thought about making maybe a single consumer called GlobalConsumer which would handle everything above. Is this the way to go?

I also have this other problem where I currently add a group for each conversation of every user. This means that if a 100 users each have 100 conversations, I could have a total of 100*100=10000 groups which doesnt sound efficient. Wouldnt it be better to send messages of all chats to a single userID group and have the chatID as parameter? This way, we would only have maximum 100 groups for 100 users.

What are the best practices in my situation?

See my reply at Using StreamingHttpResponse over HTTPS - #4 by KenWhitesell for some ideas along these lines.

Are all chats 1-1, or are they 1-many? In other words, when a person is sending a chat message, is it always to one recipient? And has the sender somehow identified the intended recipient? If so, then yes, creating a group-per-user works really well for that.