Acronis;792742 said:
The FD limit can vary from distro to distro but yeah it's usually 1024. This can be modified by the running app though. I'm not sure how to do it in C# but in C++ It's like this:
Code:
void SocketServer::SetFDlimit(int limit=65535)
{
#ifdef linux
struct rlimit fslimit;
fslimit.rlim_cur = limit;
fslimit.rlim_max = limit;
setrlimit(RLIMIT_NOFILE, &fslimit);
#endif
}
I'm sure C# must have an equivalent to that. There may be other unwanted side effects to raising it though, but I've been fine. I was able to sustain over 10k concurrent connections of random data on a test tcp server API I coded.
It looks like Mono has the beginnings of an API but setrlimit isn't implemented yet. See:
Mono Documentation
We don't need that API though. We could (and likely would prefer to) just call setrlimit ourselves (we already import libc for read).
Regardless, setrlimit isn't the problem. From what I've seen, both the soft and hard limits are 1024 by default in most modern distributions. Regular users cannot (even with setrlimit) increase their FD limit above the hard limit. Root could of course use setrlimit to set their own FD limit up to fs.file-max. The method of raising the FD limit (hard and the default soft) for a regular user (by root) varies by distribution, but usually involves root modifying limits.conf and possibly some files in pam.d/.
This is all sort of academic though. If someone has a RunUO server with around a thousand clients it's probably their box (they have root access or access to someone with root access) and not a shell on a friends server. They can easily modify limits.conf for the user RunUO runs under. If they choose to run RunUO as root, they can just use ulimit -n before starting the server.
EDIT:
For anyone curious, you can check the current number of file descriptors used by doing the following (change <PID> to the PID of your Mono/RunUO process):
I would estimate that a bare RunUO server would use 50-75 (listening socket, log files, Mono libraries, data files, etc).