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?
4 Answers
Probably no, as both instances would use the same keys. Maybe you can find a way to prefix the keys of each application.

- 118
- 1
- 1
- 4
-
Hm, so there's a single set of keys per memcached instance. Thanks for the tip. – Jan 11 '11 at 00: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.

- 25,244
- 15
- 63
- 92

- 11
- 1
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.

- 2,687
- 2
- 18
- 19
This might help somebody...
Multiple memcache instances/servers on windows: http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html

- 143
- 1
- 6
-
Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – masegaloeh Oct 31 '14 at 09:40
-
especially that it now returns 404 and is pretty useless and not following stackexchange rules. – tymik Nov 06 '17 at 14:48
-
It's on the internet archive: https://web.archive.org/web/20121205123921/http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html – luisdev Feb 15 '19 at 11:39