Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HTTP Engine and Sockets

To support more concurrent browser, device, and service connections, choose a socket dispatcher for your operating system and size the HTTP connection pool accordingly. The dispatcher monitors sockets and tells BAS when connections are ready to send or receive data.

Choose a socket dispatcher

Target Recommended dispatcher Build selection
Linux epoll, especially for large connection sets BA_USE_EPOLL=1. Mako's Linux build.sh selects it automatically.
QNX poll, for connections beyond the generic select dispatcher's descriptor limit BA_USE_POLL=1. Mako selects it automatically with plat=qnx; standalone QNX library builds require the option explicitly.
Other compatible POSIX targets, such as macOS poll when more connections are needed than the generic dispatcher allows BA_USE_POLL=1 in the supplied POSIX makefiles.

The generic dispatcher uses select and remains available for existing ports and smaller connection sets. The poll dispatcher removes the FD_SETSIZE restriction from socket dispatch, timed reads, and connection waits. Increasing FD_SETSIZE is therefore unnecessary for these poll paths. Operating-system socket limits and available memory still determine the usable capacity.

Select one dispatcher and use its matching headers throughout the library and application. Clean and rebuild both when changing dispatchers, including any prebuilt libraries. See Configure the port, allocator, and threads for the build options and Building the Mako Server for Mako-specific guidance.

Plan connection capacity on QNX

Use poll for QNX applications that need many simultaneous HTTP, HTTPS, or persistent socket connections. Size the process file-descriptor limit and the network stack's socket capacity to leave room for listeners, files, and other application sockets. For Mako, set the numeric conncnt option in mako.conf to the required HTTP connection count; its default is 50. Allow memory for the connection pool and for TLS when using HTTPS. See Mako connection capacity.

Configure the HTTP pool

The HTTP engine uses a configured pool of HttpConnection objects to serve requests and keep HTTP/1.1 connections open between requests. The default pool contains 16 connections. Configure it before constructing HttpServer with HttpServerConfig::setNoOfHttpConnections.

  • size (U16) is the connection count. It must be at least the configured command count plus three and fit in U16.
  • The setter returns 0 on success or -1 when the count is too small.
  • Increasing the connection count also raises the configured maximum session count when that value was smaller.
  • HttpServer allocates the pool during construction. Configuration changes afterward do not resize that server's connection pool.

A larger pool allows more HTTP connections to remain open. It also requires more BAS memory and more resources from the network stack. Request/response buffers are associated with HttpCommand objects; TLS connections can require additional TLS buffers. The HTTP connection count alone is therefore not a complete memory budget.

Account for all sockets

The pool limit applies to connections managed by the HTTP engine. It does not limit separate Lua sockets, HTTP clients, WebSockets after connection takeover, or other application connections. Listener sockets and other dispatcher users also consume network-stack and dispatcher resources.

Choose a pool size that leaves room for these other users. Limits depend on the selected SoDisp port, build configuration, operating system, and TCP/IP stack. Poll and epoll avoid the generic select port's descriptor-set limit, but do not remove these other resource limits. Do not infer the available socket count from the HTTP configuration alone.

Idle connections and TCP cleanup

When a new connection needs a pool entry, HttpServer_getFreeCon first checks for a free entry and can reclaim an idle connected entry. If needed, it can also terminate a pending request to recover an entry. The pool does not grow automatically.

Keeping HTTP/1.1 connections open avoids unnecessary reconnects. Closing TCP connections can leave protocol state, including TIME_WAIT, in the network stack after the BAS pool entry becomes reusable. Its duration and resource cost are controlled by the TCP/IP implementation. Size the stack and the BAS pool together, using the actual application workload.