3 ms·
Most operating systems have some highly efficient way of handling many open network connections, for example epoll on linux, kqueue on xBSD, event ports on sola
by arete 18y ago
Most operating systems have some highly efficient way of handling many open network connections, for example epoll on linux, kqueue on xBSD, event ports on solaris. These are much more efficient than select() with large numbers of open sockets and the Erlang VM will use the appropriate one for the host OS when run with the +Ktrue option.
The SMP Erlang VM (as of Erlang/OTP R11B, R12B highly recommended) runs, by default, one process scheduler per CPU. So on a dual-core machine you can have two sockets being read from/written to simultaneously. Erlang allows you to program to a very simple model of one Erlang process per socket, with the VM using select/epoll/kqueue/etc to determine which processes have incoming data and are thus runnable.
Native processes use a lot of resources on most operating systems, so you can't use a process-per-socket model. So many web servers use a pool of processes/threads and queue up incoming requests that exceed that limit. Others use relatively few processes and use epoll/kqueue/etc directly.
- Tichy 18y agoVery interesting, thanks - also for the other replies by davidw and wmf.