While trying to use memcache for SSL sessions SSLSessionCache memcache:127.0.0.1 I noticed the connection to the memcache server is not reused but dropped and recreated on every request. This can be checked using tcpdump. The cause of this behavior seems to be incorrect TTL setting in mod_socache_memcache.c: #ifndef MC_DEFAULT_SERVER_TTL #define MC_DEFAULT_SERVER_TTL 600 #endif This is than used when creating memcache server: rv = apr_memcache_server_create(p, host_str, port, MC_DEFAULT_SERVER_MIN, MC_DEFAULT_SERVER_SMAX, thread_limit, MC_DEFAULT_SERVER_TTL, &st); My guess is the author wanted a TTL of 600 seconds (10 minutes) which is reasonable, but the problem is the units for this parameter are in microseconds so the connection does not have a chance of reuse in next 600 microseconds. Changing this constant to 600 * 1000 * 1000 restores the intended behavior of caching the connection for 10 minutes.
Hi, looks good to me. See http://marc.info/?l=subversion-dev&m=139866123837158 for the same kind of issue in svn. Thanks
The parameter would preferably be configurable, so that a close from the memcache side (which may also have a timeout) does not produce an error. The TTL is an idle timeout, active only when the connection is unused, hence reset on each use. There is also no mechanism to test the connection before reusing it in mod_socache_memcache, unlike in mod_proxy. The timeouts with the memcache have to be synced (a little lower here). The current code inhibited that potential error.
I would also advocate a low (15/20 seconds) default (or at worse hard) timeout.
Change of default value + new option to configure the TTL (MemcacheConnTTL) proposed in r1696105 (In reply to Yann Ylavic from comment #2) > The timeouts with the memcache have to be synced (a little lower here). What do you mean? Can you elaborate?
Proposed for backport in r1696139
This is in 2.4.17