Hi,
We are recently having some connection problems with our memcached
servers (1.2.6). It seems this problem related to a lot of concurrent
connections. Although we increased the number of open files to 10240
and start memcached with "-c 10240" parameter, we seemed to be having
problems when the number of connections is around 1000. We tested our
deployment outside of our php application with a simple script but
still we are getting connection timeouts.
Here is the script :
from functools import partial
import threading
from random import randint
import memcache
from memcache import Client
def rand_string():
return "".join([chr(97 + randint(0, 25)) for i in xrange(0,
randint(1, 30))])
def memcache_connect(thread_num, servers):
try:
c = Client(servers, 1)
for i in xrange(0, 50):
s = rand_string()
a = c.get(s)
if not a: a = "None"
if i == 45:
res = "%d testing %s %s" % (thread_num, s, a)
#print res
except Exception as e:
print "WE HAVE ERROR", thread_num, e
threads = []
for i in xrange(0, 400):
thread = threading.Thread(target=partial(memcache_connect, i,
["memcache2:11211"]))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print "THREAD DONE"
This code creates 400 concurrent connections (it's not 1000 since we
already have connections from the live system) and we see timeouts.
When we decrease this number to 200, timeout problems are gone.
Any help will be appreciated.
Thanks!
//kaan