Incoming chat message que maximums

We are building a “large” chat bot. The bot has been verified.

When the queue of messages sent from Twitch to our bot exceeds Twitch’s buffer you reach a message que maximum and your bot is DC’d.

I read from a related post:

Large chat bots will often split groups of channels over multiple connections to solve this issue.

Trying to understand what the recommended solution is.

  • Do we instantiate multiple TMI clients using the same credentials and shard channels over those clients? For example:
let credentials = { identity: { username: 'user123', password: 'pass456' }}
let client1 = new tmi.client(credentials)
let client2 = new tmi.client(credentials)
client1.join('#foo')
client2.join('#bar')
  • Does each constructor return a unique connection with it’s own incoming message queue buffer or is the buffer shared between the two. Is the buffer throttled at the account level or at the connection level?

  • Are there limitations to how many TMI clients are instantiated from a single server using the same credentials?

Thanks

Yes

Each connectiong will recieve the messages for the rooms that that connection has JOINed

So
Connection 1 in rooms foo and bar
Connection 2 in rooms cake and pie
Connection 3 in rooms cake and lemon

Connection 2 will not recieved messages from foo and bar.
Connection 2 and 3 will recieved messages for cake as both connections are in cake
Connection 3 will get lemon but not pie.

So

Yes.

Then it’s just down to what the server can handle in terms of traffic not just the given process keeping up.

Broadly speaking:

Rate limit is by “IP” so you have a shared rate limit across all the connections from the same server, broadly speaking.

Discussing rate limit can get complicated very quickly.

Excellent. Thanks for this information. Follow up questions:

  • What is the available bandwidth for a given incoming message buffer per connection? How do I measure it or see it’s current capacity?

  • Are there any metrics that can be used after connecting to a channel to determine what bandwidth it will consume?

What I’d like to do is programmatically determine capacity for a given connection to move channels around and spin up new clients to stay under.

Thanks

It’s more a question or your ability to keep up.

The docs do not cover a limit and there is no way to monitor/know the limit.

You can count the chat messages incoming I suppose.
But otherwise nope.

You can devise your own method and see what works best for you and your setup.

Theres no “good” rule of thumb for it

Based on testing from a few years ago, 90 channels was about the upper practical limit for a single connection. Too many more channels than that and the connection would eventually be disconnected.

Caveats

  • Testing was done only in the top channels on Twitch (which was updated about every 30 seconds to ensure they were the absolute top channels at that moment), likely representing the top percentile of chat activity (among active live channels).
  • The testing was done a few years ago and has not been repeated since.
  • I do not know if there were any special events or mass spamming campaigns at the time.
  • I only still have the conclusions from the testing, not the actual data (e.g., what channels, how many active chatters, peak bandwidth or message rate).

You can’t predict what chat activity will look like over the next few milliseconds with complete accuracy, so I err on the side of extreme caution.

Thankyou for the information this is helpful.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.