Memcached connections maxed out
I am running a very large Rails app. We use a pool of Memcached servers and the Evan Reaver's gem memcached, and have two namespaces one for the object/fragments and one for sessions.
We use half the number of servers for sessions as we use for object/fragments.
For some mysterious reason the Rails app only opens around 20-30% of the maximum available connections set by the memcached开发者_StackOverflow中文版 daemon. It also seem to take the max connections from the first server listed.
Does anyone have any input for this weird behavior?
It turned out the solution was incredibly simple. You get only one connection per Ruby worker per server and memcache daemon.
The math to get the total number of possible connections from your Rails app across all web servers then can be calculated as simple as:
x number of Ruby workers
y number of web servers
z number of memcache daemons
= (x)(y)(z) gives you the number of total connections to all memcached daemons
Do note that: If you run memcache for session those connections are separate.
I wish all things would be this simple. :-)
精彩评论