Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

4 Answers 4

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. –  foxbunny 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: http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html

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 6 hours ago

Your Answer

 
discard

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.