danieleteti / delphiredisclient

Redis client for Delphi
Apache License 2.0
307 stars 133 forks source link

Growing of TCP connection #29

Closed cesco69 closed 3 years ago

cesco69 commented 3 years ago

Hi Daniele,

I'm using delphiredisclient (master) on a TWebModule.

on WebModule creation I create a new TIdTCPClient and connect to Redis, e.g.:

procedure TWebService.WebModuleCreate(Sender: TObject);-
begin
    FClient := TIdTCPClient.Create();
    FClient.Connect('REDIS_HOST', 6379);
end;

and on web module destroy, I disconnect and free the resource, e.g.:

procedure TWebService.WebModuleDestroy(Sender: TObject);
begin
    FClient.Disconnect;
    FClient.Free;
end;

All works... But this way I create a new connection on every new request and after a lot of time there is a growing number of TIME_WAIT sockets.

netstat -na | find "6379"

image

I would like to implement a global connection pool.

Has delphiredisclient something to manage a pool of TCP connections?

danieleteti commented 3 years ago

WebModules are recycled by WebBroker. The pool must be handled outside of the http request.

cesco69 commented 3 years ago

Yes @danieleteti I'm writing an connection pool for Redis Client https://codereview.stackexchange.com/questions/260418/delphi-tidtcpclient-connection-pool-in-a-multithread-environment take a look, maybe it can be a part of this project

danieleteti commented 3 years ago

Interesting. Would you like to contribute to the project?