PHP sessions in a load balancing cluster - how?

后端 未结 10 1980
粉色の甜心
粉色の甜心 2020-11-29 17:44

OK, so I\'ve got this totally rare an unique scenario of a load balanced PHP website. The bummer is - it didn\'t used to be load balanced. Now we\'re starting to get issues.

10条回答
  •  半阙折子戏
    2020-11-29 18:16

    The way we handle this is through memcached. All it takes is changing the php.ini similar to the following:

    session.save_handler = memcache
    session.save_path = "tcp://path.to.memcached.server:11211"
    

    We use AWS ElastiCache, so the server path is a domain, but I'm sure it'd be similar for local memcached as well.

    This method doesn't require any application code changes.

提交回复
热议问题