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

I'm working on a new server built with Unbuntu 10.04, running php-fastcgi, nginx, and memcached.

phpinfo() script loads and works great, same as a test memcached script. For any script using sessions, page load time rockets through the roof.

--- memcached.ini ---
extension=memcached.so
memcache.hash_strategy = "consistent"
memcache.max_failover_attempts = 100
memcache.allow_failover = 1
session.save_handler = memcached
session.save_path = "tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

Let me know if you need to see any other configs.

share|improve this question
    
Any Messages in your php logs? what if you run memcached in debug/foreground mode? does it say anything interesting? When I deployed memcached to our site, it just ran w/o much issue, and was instantly fast. Is there a firewall interfering with connections to localhost 11211 ? –  Jason Jun 5 '10 at 1:33
    
@Jason Nothing in the PHP error log. I didn't know that you could troubleshoot memcached in debug mode, so I will work in that direction, and get back to this. Thanks –  Ben Dauphinee Jun 5 '10 at 9:11

3 Answers 3

up vote 3 down vote accepted

The problem is in the session.save_path syntax between memcache.so and memcached.so:

extension=memcache.so
session.save_handler = memcache
session.save_path = "tcp://127.0.0.1:11211"

vs.

extension=memcached.so
session.save_handler = memcached
session.save_path = "127.0.0.1:11211"

Note the protocol in the memcache one, no protocol in the memcached one.

Also, make sure you actually have the .so you are trying to load. They're two separate packages via apt-get or yum or whatever flavor you use.

Any breakage due to loading the wrong module or using incorrect syntax causes a 30 second load delay in php while it tries to use your session mechanism and eventually times out.

Hope that saves someone some time. ;-)

share|improve this answer

Change PHP extension from memcached.so to memcache.so. This resolves all lag issues. Not sure if it's a Ubuntu bug or a bug with my setup, but it works great now.

share|improve this answer

php's memcached is NOT php's memcache! They are seperate implementations.

What does a simple 'session.save_path = "127.0.0.1:11211"' give you? Or

session.save_handler = memcache
session.save_path = "tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

Note the missing 'd' in the save_handler.

share|improve this answer
    
I have tried both memcache and memcached as save handlers, and it seems to make no difference. –  Ben Dauphinee Jun 8 '10 at 18:09
    
Hmm, pity. So normal memcache(d) connect/read/write on either is OK, only the session handler isn't? Strange... There is something going on there in that case, although you could temporarily write your own sessionhandler with memcached, pretty straightforward, but no definitive solution. –  Wrikken Jun 8 '10 at 19:06

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.