Why is IRC distributed across multiple servers?
I have been wondering for a long time why IRC networks have multiple servers. Wouldn't it be simpler just to use a single server?
One of the problems of having multiple servers is that netsplits can occur. Anybody who has been on IRC for a while will have witnessed one. Hundreds of people suddenly ripped out of the chat. This can also screw up channel and user modes, and 'some people' have been known to wait for netsplits in order to takeover channels or enter password protected channels.
So lets compare situation (A) a single IRC server everyone connects to with the current setup people use (B) multiple servers. Let's say you run an IRC network with u = 40,000 users and n = 20 server nodes that people connect to via round robin DNS (meaning that when people resolve the DNS it gives them a random server from the set of 20 to connect to). These are vaguely realistic numbers modelled after libera.chat.
So in (B) you have roughly u/n = 2000 clients connected to each server node, and each server node also connects to some number 1 <= b <= n-1 of the other servers. Maybe a typical server is connected to b = 3 other servers in the network. They need to do this to so that messages from clients connected to one server reach clients connected to other servers.
We can analyze the usage of 3 resources: bandwidth, RAM and CPU.
Imagine 10% of the clients send a message at one instant in time. What happens?
- Input: The server recieves 4,000 messages from 40,000 different TCP connections.
- Output: The server must send every message it gets to every other user: 4000 * (u - 1) = 159,996,000 messages sent out across all 40,000 connections.
- RAM/CPU: The server software has to maintain 40,000 connections, parsing data from them.
- Input: The server recieves a total of 4,000 messages as before, but it comes in as lots of small messages from its 2000 clients and in large packages from the b = 3 other servers.
- Output: The output is quite different. The server needs to relay the 400 messages it got to the 3,999 clients that didn't send it, but it also needs to relay these messages out to the b = 3 other servers it's connected to. So it sends out a total of 400 * (3999 + 3) = 1,600,800 messages. This is about 160x less than with a single server.
- RAM/CPU: The server software has to maintain 2000+3 connections. Far fewer, so this will take up much less RAM and CPU.
So distributing an IRC network across multiple servers means your server does not have to manage as many connections which will reduce RAM and CPU. Will output much less data over the network but will recieve the same amount of data in.