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?
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.
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.