9

Recently, our PHP web app became unavailable for a few minutes since one of our Memcached nodes died (we use Memcachier as a Memcached provider).

This was our user.ini configuration (Heroku uses user.ini as a place where you define your configuration), which worked, but apparently didn't support failover:

session.save_handler=memcached
session.save_path=${MEMCACHIER_SERVERS} # I understand this is redundant, but I just kept it as-is because I didn't write the original user.ini
session.save_path="PERSISTENT=SFSESSID ${MEMCACHIER_SERVERS}"
session.gc_maxlifetime=1209600
session.gc_probability=1

memcached.sess_binary=1
memcached.sess_sasl_username=${MEMCACHIER_USERNAME}
memcached.sess_sasl_password=${MEMCACHIER_PASSWORD}

Our new user.ini configuration, which is aimed to provide failover capability

session.save_handler=memcached
session.save_path="PERSISTENT=SFSESSID ${MEMCACHIER_SERVERS}"
session.gc_maxlifetime=1209600
session.gc_probability=1

memcached.sess_sasl_username=${MEMCACHIER_USERNAME}
memcached.sess_sasl_password=${MEMCACHIER_PASSWORD}
memcached.sess_binary=1
memcached.sess_number_of_replicas=1
# I also tried memcached.sess_consistent_hash=1, to no avail

The MEMCACHIER_SERVERS env var looks like this: 123.45678.us-east-1.heroku.prod.memcachier.com:11211,123.45678.us-east-1.heroku.prod.memcachier.com:11211. I think this means we have 2 nodes.

The problem we are getting with the new configuration are timeouts, and lots of errors regarding PHP session functions (session_start(), session_write_close()).

Why is that happening?

Remember, we're not using Memcached inside our PHP code at all, but only as our session storage engine.

I did try contacting Memcachier support, but the customer representative could only provide recommended PHP code (which we don't need).

The Onin
  • 5,068
  • 2
  • 38
  • 55
  • Not quite sure about the environment, why don't you add a proxy to make it high available? – Yarco Feb 09 '17 at 11:02
  • Memcachier SaaS does that for us. – The Onin Feb 09 '17 at 11:15
  • what is the value of `session.gc_divisor`? Maybe the session garbage collection is started too often? – Anton Boritskiy Feb 09 '17 at 15:20
  • 2
    Having been in this exact situation, I would suggest moving off of the Memcachier addon to the MemcachedCloud addon--as soon as we switched, we haven't had a single issue since. If you're using a hosted service, you shouldn't have to worry about that kind of HA unless you're building a very large app or something that truly requires 100% uptime. – jdotjdot Feb 09 '17 at 21:16

1 Answers1

1

Since the bounty expired and the question will get closed soon, I'm gonna go ahead with @jdotjdot's suggestion and switch from Memcachier to MemcachedCloud addon.

The Onin
  • 5,068
  • 2
  • 38
  • 55