imports: | |
# .... | |
- { resource: services/session.yml } | |
framework: | |
# .... | |
session: | |
handler_id: session.handler.memcached |
aptitude install memcached php5-memcached |
parameters: | |
# ... | |
session_memcached_host: localhost | |
session_memcached_port: 11211 | |
session_memcached_prefix: sess | |
session_memcached_expire: 3600 |
services: | |
session.memcached: | |
class: Memcached | |
arguments: | |
persistent_id: %session_memcached_prefix% | |
calls: | |
- [ addServer, [ %session_memcached_host%, %session_memcached_port% ]] | |
session.handler.memcached: | |
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler | |
arguments: [@session.memcached, { prefix: %session_memcached_prefix%, expiretime: %session_memcached_expire% }] |
This comment has been minimized.
This comment has been minimized.
runs smooth, just tried it myself |
This comment has been minimized.
This comment has been minimized.
HUGE caveat here... Spent several hours figuring out what was going on. If you are using Apache prefork, giving the persistent_id when instantiating the service creates a connection to memcached that lasts for as long as the Apache worker child stays alive (this can be a good thing... less overhead). However, the addServer call does not check for duplicates; this causes the memcached server to be listed in the server list and a connection to be opened once for every single request served by the worker. The default Ubuntu settings are for a maximum of 400 workers, each able to handle 10000 requests before being killed. That means there might be as many as 4,000,000 open connections to the memcached server. When we hit the memcached open connection limit of 1024, we were no longer able to store or retrieve any sessions from that point forward because the old connections just wouldn't die. There are two possible fixes for this:
Short term (because it's easier) I've gone with #2 - testing shows it's stable for now. There's obviously a performance overhead that would be negated by implementing #1. |
This comment has been minimized.
This comment has been minimized.
@cmenning Could you please show up your #1 gist? |
This comment has been minimized.
This comment has been minimized.
https://gist.github.com/elmariachi111/5637669a028c29e3973a better late than never ;) |
This comment has been minimized.
This comment has been minimized.
@cmenning you just made my day! Thanks a lot man!! |
This comment has been minimized.
any changes in php.ini file?