Increase memcached connections limit


The couchbase server starts a memcached process with connections limitation:

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

How to increase this limit?

Really nobody knows?

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.

On 4.0 there’s a REST endpoint which lets you configure some settings (including max connections) - see the examples at:

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.

It looks promising:
/opt/couchbase/bin/memcached-bin -X /opt/couchbase/lib/memcached/ -X /opt/couchbase/lib/memcached/,cyclesize=104857600;sleeptime=19;filename=/opt/couchbase/var/lib/couchbase/logs/memcached.log -l, -p 11210 -E /opt/couchbase/lib/memcached/ -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

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

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