Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two applications with exactly the same code using memcached in identical ways. Does memcached tell the difference between the two apps, and is it safe to run them on the same server with a single memcached server?

share|improve this question
up vote 2 down vote accepted

Probably no, as both instances would use the same keys. Maybe you can find a way to prefix the keys of each application.

share|improve this answer
Hm, so there's a single set of keys per memcached instance. Thanks for the tip. – hayavuk Jan 11 '11 at 0:44

You could run two instances of memcache in the server listening in different ports. e.g.

memcached -p 11211 -d

memcached -p 11212 -d

You would only need to make a small change to one of the code copies so it connects to the other memcached port.

Without the two memcache instances and the small port change I wouldn't see a way for the applications not to collide.

share|improve this answer

you will clash the value for the same key.

memcache is not aware by who inserts data but what data is inserted. you can check by telnet localhost memcache port 11211 but it may be changed into your environment, then insert from your first app a key value , retrieve it with get and then do the same for the second app if the value changed for the same key is sure that you overwrite the value for that key.

I use the same memcache server but for each app I give a namespace.

share|improve this answer

This might help somebody...

Multiple memcache instances/servers on windows:

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – masegaloeh Oct 31 '14 at 9:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.