-
Notifications
You must be signed in to change notification settings - Fork 84
Persistent connections exhaust connections to memcached server #100
Comments
This isn't all that easy, since we create the service and the calls are only executed when the service is instantiated. I'm not sure why the
The only way we could fix this is by extending the |
Actually it is not a bug. When you have persistent connection, you should only add your servers once. See the first user comment here: http://php.net/manual/en/memcached.construct.php#93536 |
True, I also believe this is not a bug of the memcached extension, but incorrect behavior of the Cache Bundle. See also other comments in the manual, like this one:
It is also documented behavior in the manual:
|
Thanks for confirming this. I'll see if I can come up with a workaround. |
Closing here for the reason stated in #156. |
Hi,
when persistent connection to memcached is used, it behaves incorrectly and creates more and more persistent connections to memcached, which may lead to memcache connection limit exhausting in a short while.
The problem was introduced in #83 with version 1.3.0.
The issue is in
MemcachedDefinition
:The
addMethodCall('addServer', ...)
adds new server(s) to the connection pool. This is not a problem without the persistent connection, because the pool is created only for the one request and the connection is closed shortly afterwards.However, when the connection is created as persistent, servers are added to already existing pool, so after a while, you ends with many (same) memcached servers in the connection pool and new persistent connection being created to them every time new server from the pool is chosed. As the connections are created as persistent and new servers are added every request, it easily reaches almost any connection limit the memcached server has.
The addServer() should be IMHO called only if the Memcached instance does not contain the server setup yet (eg.
count($memcached->getServerList())
is 0).The text was updated successfully, but these errors were encountered: