tags:

views:

38

answers:

2

I want to use redis in my server application ( c module for nginx ) - ( check variable from redis for each request ). what should I use type of connection ( keep alive or separate connection for each request ( connect, do, close ) ) to redis ( I plan to use credis for connect to redis )? I use 2 servers.

A: 

If you can reuse the connection by keeping it alive, do so. If you have a few (or more) requests, it can easily become inefficient if you're disconnecting and reconnecting all the time.

Miki
A: 

It's best to share the connection if possible - efficiency is part of it, though I have had issues with connections dropping out when I tried to keep too many open.

For most things you can share a single connection, the only time you really need a dedicated connection is for things like subscribe or transactions where the result isn't returned immediately.

Tom Clarkson