TsgcWebSocketProxyServerProperties › ThreadPool

ThreadPool Property

Enables a thread pool that recycles worker threads instead of destroying them when proxied connections close.

Syntax

property ThreadPool: Boolean read GetThreadPool write SetThreadPool;

Default Value

False

Remarks

When ThreadPool is True, threads that finish serving a downstream connection are returned to a pool instead of being destroyed; they are marked inactive and consume no CPU cycles until reused, which dramatically reduces the cost of short-lived connections — a common case with browser-driven WebSocket proxies. Tune ThreadPoolOptions (MaxThreads, PoolSize) to control how many threads may be created. The pool covers only the downstream worker threads; upstream links to the server defined in Proxy use their own client connection per session.

Example


oProxy := TsgcWebSocketProxyServer.Create(nil);
oProxy.ThreadPool := true;
oProxy.ThreadPoolOptions.PoolSize := 32;
oProxy.Proxy.Host := 'upstream.example.com';
oProxy.Proxy.Port := 8080;
oProxy.Active := true;

Back to Properties