Open gsastry opened 10 years ago
Any redis clients will try to reconnect to the server every 2s if the connection is lost.
The client opens a connection per request, right? Is there any way to have it open a few connections that serve all the request, and keep the connections persistent?
No the client is always connected to the server. If you use a pool you can dispatch the connexion on many redis server, (or put the same server multiple times in the Seq of redis servers). If you only have one server, and don't need many connexion then you can use a RedisClient.
Thanks for your prompt and helpful replies. I wasn't aware that the connection is keep-alived. Is there any advantage to putting the same server multiple times in the Seq of redis servers? Will that round robin the request to different connections to the same server (essentially using a connection pool)?
BTW, do you mind pointing me to the code where it's specified as a keep-alive connection?
Yes it will round robin the connections. if your CPU is not already overloaded with just one you can add more for more throughput
Thanks. Just to confirm, the connections are set as keep-alive=true by default?
Thanks for posting these questions & answers :- ) It wasn't clear to me when & why to use the connection pool, and when not to — so I searched all GitHub issues for "connection" and then I found this topic.
I think it'd make sense to rewrite & include the stuff in this topic in the main readme.
(Some stuff from this topic: https://github.com/etaty/rediscala/issues/22 about how to avoid bad performance when writing async requests, could also be in the main docs perhaps)
Hi,
How can I have this client maintain a persistent connection (via a connection pool) to a redis server? Is this possible? I looked at the RedisClientPool but that looks like it round robins requests to a set of servers.