EPOLL Server

A Linux epoll acceptor for high concurrency. Handle thousands of connections on the sgcWebSockets server using a limited pool of threads instead of one thread per connection as Indy does by default.

EPOLL I/O Handler

A high-performance I/O mode for Indy-based servers on Linux. Enable epoll on the standard server through the IOHandlerOptions property and scale far beyond the one-thread-per-connection model.

Component class

TsgcWebSocketServer / TsgcWebSocketHTTPServer — enabled via IOHandlerOptions

Mechanism

Linux epoll thread-pool acceptor — Linux only

Platforms

Linux

Edition

Enterprise

Set the IOHandler type, go

Select iohEPOLL on the IOHandlerOptions property of an Indy server to switch from the default thread model to the epoll thread pool.

Server.IOHandlerOptions.IOHandlerType := iohEPOLL;
Server.IOHandlerOptions.EPOLL.EPOLLThreads := 0;
Server.IOHandlerOptions.EPOLL.WorkOpThreads := 0;
Server->IOHandlerOptions->IOHandlerType = iohEPOLL;
Server->IOHandlerOptions->EPOLL->EPOLLThreads = 0;
Server->IOHandlerOptions->EPOLL->WorkOpThreads = 0;
Server.IOHandlerOptions.IOHandlerType = iohEPOLL;
Server.IOHandlerOptions.EPOLL.EPOLLThreads = 0;
Server.IOHandlerOptions.EPOLL.WorkOpThreads = 0;

What's inside

How the epoll thread pool works and how to tune it for your workload.

Thread-pool I/O

Handle thousands of connections using a limited pool of threads instead of one thread per connection. Asynchronous (overlapped) requests are dispatched across the pool rather than dedicating a thread to each socket.

EPOLLThreads

Threads used for EPOLL asynchronous requests. The default value 0 means the count is calculated from the number of processors. On Delphi 7 and 2007 the default is 32 because cpucount is not supported. Adjust manually when needed.

WorkOpThreads

By default each request for a connection can run on a different pool thread. Set WorkOpThreads to pin every connection to the same thread. This impacts performance, so set a value greater than zero only when you require this feature.

When to use

Recommended when you need to handle thousands of connections. If your server handles a maximum of around 100 concurrent connections, you can stay with the default Indy thread model.

Disconnect detection

EPOLL detects a dead socket only on write. To raise OnDisconnect, enable CleanDisconnect := True on TsgcWebSocketClient, or enable a server-side heartbeat that pings clients periodically.

Linux connection limit

Raise the open-file-descriptor cap to increase the number of concurrent open connections. ulimit -n 10000 sets the maximum number of open file descriptors to 10000.

Specifications & references

Authoritative sources for the mechanism this mode relies on.

Documentation & Demos

Deep-link to the online help, grab the ready-to-run demo project, and read the full manual.

Online Help — EPOLL Full feature reference with code samples for Delphi, C++ Builder and .NET.
Demo Project — Demos\Server Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
User Manual (PDF) Comprehensive manual covering every component in the library.

Scale to Thousands of Connections on Linux

Download the free trial and switch your Delphi server to the Linux epoll thread pool.