Increase memcached connections limit


#1

Hi,

The couchbase server starts a memcached process with connections limitation:

/opt/couchbase/bin/memcached ... -c 10000 ...

How to increase this limit?


#2

Really nobody knows?


#3

I need this information too. I know that it can be done, because I have seen allusions to it, i.e., “…build a wrapper that couchbase runs, modifies the command being run by erlang and then runs the actual memcached program with the new connection limit.”

It certainly is not obvious how the memcache command is run.

I know this topic is old, but I have been searching for a solution for this long on Couchbase 2.2.0, and the problem is becoming more serious by the day.


#4

On 4.0 there’s a REST endpoint which lets you configure some settings (including max connections) - see the examples at: https://issues.couchbase.com/browse/MB-11066?focusedCommentId=103901&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-103901

Prior to 4.0 there isn’t an end-user exposed setting for this. You can inject additional parameters into ns_server using an Erlang command, but that can be tricky and error-prone.

If you’re on 2.x The simplest solution is probably just to rename /opt/couchbase/bin/memcached to something like /opt/couchbase/bin/memcached.bin and create a wrapper script in its place which adds a -c XXXXX to the passed in arguments before exec’ing memcached.bin.

Obviously this won’t take effect until you restart that memcached on that node (e.g. swap-rebalance out/in), and you’ll need to ensure that you re-apply such a wrapper script whenever you upgrade.


#5

It looks promising:
/opt/couchbase/bin/memcached-bin -X /opt/couchbase/lib/memcached/stdin_term_handler.so -X /opt/couchbase/lib/memcached/file_logger.so,cyclesize=104857600;sleeptime=19;filename=/opt/couchbase/var/lib/couchbase/logs/memcached.log -l 0.0.0.0:11210,0.0.0.0:11209:1000 -p 11210 -E /opt/couchbase/lib/memcached/bucket_engine.so -B binary -r -c 32768 -e admin=_admin;default_bucket_name=default;auto_create=false

But cbstats doesn’t agree:
max_conns_on_port_11209: 1000
max_conns_on_port_11210: 9222


#6

I would urge you to upgrade your Couchbase Server as not only would you pick up a lot of bug fixes and new features, the the default memcached connection limits are raised since 3.0.0
max_conns_on_port_11210: 30000
max_conns_on_port_11209: 5000


#7

I did not realize that there were CE releases of 4.0. That changes everything. Thanks!