Distributing user load and doing server maintenance

This article assumes you have multiple servers.

Using DNS round robin
Most irc networks use a setup like this:
 * irc1.example.net has an IP address of 1.1.1.1
 * irc2.example.net has an IP address of 2.2.2.2
 * You may or may not also have a hub server, eg hub.example.net
 * irc.example.net will then point to both 1.1.1.1 and 2.2.2.2

As you can see, the DNS record irc.example.net points to the IP addresses of all the IRC servers that are meant for accepting clients, so the IP of irc1 (1.1.1.1) and irc2 (2.2.2.2). You tell users to connect to irc.example.net and new connections will automatically be distributed 50%/50% to irc1 and irc2. This feature is called round-robin DNS (see also wikipedia).

Also, if for some reason one of your irc servers goes offline, like irc1, then your users would still have a 50% chance each time to connect to irc2 which is still up. So it is also a resilient setup.

This example can be extended if you have many more users, like an irc3.example.net, irc4.example.net, and so on. The principle stays the same.

Doing server maintainance
Every once in a while you will have to take down or restart an IRC server, reasons could be:
 * Hardware maintenance
 * A kernel upgrade or distribution upgrade (eg Ubuntu 20.04 to 22.04)
 * An upgrade of UnrealIRCd

If you know ahead of time that there will be a down period, then you can take the server IP out of DNS round robin. So in the example we used earlier, if you are going to do maintainance on irc1 then you would take the IP address of irc1 (1.1.1.1) out of irc.example.net, so it only points to the IP address of irc2.

Any new users connecting to irc.example.net will then connect to irc2 (2.2.2.2). If you wait a while, like a couple of days or a week, then the number of users on irc1 will be much less. Only people on long running bouncers that have not disconnected in like a week would still be connected to irc1.

Now you do your maintainance. Take the server down, or do whatever you need to do. Start up the server again. Finally, you put the IP address of irc1 (1.1.1.1) back in the round robin DNS of irc.example.net so new users start to connect to irc1 too.

Upgrading a server without DNS round robin
If you have multiple servers and you are only upgrading like irc1 from UnrealIRCd version X to version Y, and there will likely only be a few seconds of downtime (the IRC server restart), then you could also not take it out of DNS round robin and just do the upgrade. This will be a bit messy since there will be more users (re)connecting than if you did the Doing server maintainance as explained earlier. But it is an option if you don't want to wait a week or don't really care about some users reconnecting (eg. at night).

More advanced DNS tricks
It is possible to use more dynamic DNS rules, like Amazon Route53. Then you can do things like: All of this is usually only done on big networks though, so it isn't used much and the instructions depend on the DNS provider, so is beyond the scope of this article.
 * If a server goes down, automatically take it out of DNS Round Robin (the irc.example.net)
 * Check the user load, and send more users to the IRC servers that have fewer users