You are not logged in.
While I was researching the mORMot source, I found the following code:
constructor TWebSocketServer.Create(const aPort: RawUtf8;
const OnStart, OnStop: TOnNotifyThread; const ProcessName: RawUtf8;
ServerThreadPoolCount, KeepAliveTimeOut: integer;
ProcessOptions: THttpServerOptions);
begin
....
if ServerThreadPoolCount > 4 then
ServerThreadPoolCount := 4; // don't loose threads for nothing
// start the server
inherited Create(aPort, OnStart, OnStop, ProcessName, ServerThreadPoolCount, ....
....
end;
Why do we need to limit ServerThreadPoolCount? Although I found the following explanation in the comments of Create, to be honest, I still don’t quite understand it:
....
// - in the current implementation, the ServerThreadPoolCount parameter will
// use two threads by default to handle shortliving HTTP/1.0 "connection: close"
// requests, and one thread will be maintained per keep-alive/websockets client
....
constructor Create(const aPort: RawUtf8;
const OnStart, OnStop: TOnNotifyThread; const ProcessName: RawUtf8;
ServerThreadPoolCount: integer = 2; KeepAliveTimeOut: integer = 30000;
ProcessOptions: THttpServerOptions = []); override;
Offline
Because websockets with this TWebSocketServer class use the non-async server, so each websocket client connection uses its own thread on the server.
The thread pool is only used for HTTP/1.0 requests, which should not be used very much.
This is what the documentation says.
Offline