I want my ircd to hold over 1024 connections

Last Updated on Wednesday, 05 September 2012 14:43 Written by Admin Saturday, 09 August 2008 15:49



This is easier said than done. The maximum amount of connections (also called file descriptors [fd's] or open files) depends on multiple things... Before you read all of this you should understand that the following requires help of your sysadmin (unless you have root access yourself) and it's not easy so it might be better to do just like most people do: run multiple servers.

** The global maximum **
With Linux 2.4 and Linux 2.6 everything should be ok already, so just skip this step :)
With Linux 2.2 you'll have to do something like: echo 8192 >/proc/sys/kernel/file-max although I really recommend you to use Linux 2.4 or 2.6 because there are several other limits of 2.2* that might affect you.
With FreeBSD you should do something like: sysctl kern.maxfiles=8192 (and add it to your /etc/sysctl.conf of course). You probably also need to increase kern.ipc.nmbclusters, and perhaps some other ones as well I'm unaware off. [FEEDBACK is welcome.. if you know how to properly tweak freebsd to get 4096 or 8192 connections, let me know at syzop AT unrealircd DOT com].

** The ulimit value **
Unless you are root you cannot upgrade your ulimit -n value, so..
FreeBSD: sysctl kern.maxfilesperproc=4096 and then everything is ok (well, you prolly want to add that to sysctl.conf as well and don't forget to relogin, otherwise the changes will have no effect).
Linux: what you probably want is edit /etc/security/limits.conf and add 2 lines like:
username hard nofile 4096
username soft nofile 4096

Where 'username' is your login name (eg: syzop)
Assuming your pam is configured correctly, relogin (yes you have to login again) and type ulimit -n, it should now show 4096.
If it didn't, then your pam isn't loading the session limit module (or something else), you'll have to add a line like session required pam_limits.so to /etc/pam.d/login, /etc/pam.d/sshd, /etc/pam.d/su, and perhaps some others as well (cron???). But please be careful, since you can lock yourself out if you make a mistake, so be sure to keep 1 terminal logged in etc ;).

** The header files **
FreeBSD? Then you are already set :).
Linux? Then you'll have to do this step too...
Search for __FD_SETSIZE in /usr/include/bits/typesizes.h or /usr/include/bits/types.h and change the value.
At my system it was a matter of changing this line:
#define __FD_SETSIZE 1024
to this:
#define __FD_SETSIZE 4096

*** UnrealIRCd ***
Now you've finished everything, doublecheck that ulimit -n displays the correct value, and then you can specify this value at the MAXCONNECTIONS question (eg: 4096) of ./Config (and then do make.. etc).

*** Test results ***
I've done several tests with 10K (yes, 10000) clients on Linux 2.4* and it went fine. But to handle this amount of clients you need a good box like with a ghz proc, and more important: with enough (free) memory... at least 512Mb, and preferably 1Gb+ (not only for unreal, but also for socket buffers, etc).

I'm aware of a few "live nets" that in fact hold ~3000 users on 1 server. Why I'm only aware of a few? Well, as said.. most networks just use multiple servers.

If you are on W9X or ME, forget about it.. you really need at least NT or higher (W2K, XP, 2003, ..).
The current windows version of UnrealIRCd can handle 4096 connections by default which should be enough for most servers/networks.
If you want more, you would have to compile your own ircd, then change MAXCONNECTIONS in include/config.h to the value you want and compile it. Note that if you experience any problems/odd issues, you should mention this change in the bugreport since this has not been tested extensively.