开发者

PHP Sessions on Auto-Scaling Servers

I'm working on a PHP web app deployed to Amazon Web Services. We have load balancers in front of auto-scaled application servers.

The problem we're facing at the moment is handling sessions. While sticky sessions would be a reasonable solution, we'd like to persist sessions for quite a long time (weeks ideally). This is likely to impair the performance of the load balancer over time. Also, using auto-scaling will mean that, from time to time, we'll remove a server and thus lose all of the active sessions on it. Of course, we could just use a开发者_高级运维 common database to store sessions, but I'm a bit concerned about performance if every request requires another round-trip to the DB.

I'd be grateful if you could suggest any solutions that have worked for you, or any ideas that we could try.

Thanks in advance for your help, Ross


I would use a custom session solution where the sessions are stored in the datatabase.

That way all webservers will have access to the same session store and also you can decide for your self how long a session should be kept.

You could either build something that works with PHP normal sessions or a completely stand alone class to handle them.

I did something similar to share a session between asp and asp.net over different serves and it works.

If performance is an issue, use a separate database, memcached or mysql cluster (also memory stored) or maybe a mongoDB for the sessions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜