Handle sessions with load balancer?
Maybe this is obvious but if i have a load balancer or multiple servers in use, the user's session is coming from 1 server so if the user is pushed to say server 2 or server 3 then does that mean the user's session will expire or how to make it work as normal?
I have multi-session checks, so if a user logs-in fr开发者_Python百科om a different location it will auto sig them out like we see on bank websites. Does this effect servers? Is there anything I need to do at the database level?
EDIT: Using PHP codeignitor. Currently i have 1 dedicated server but in the process of adding 2 more servers hence before I add those I need to know if sessions will work or if it requires re-doing the session code again.
Store session data in a shared store (such as a memcached server) which all app servers can access.
If you have enough state in your app servers that you need your load balancer to send all requests from the same client to the same server for the duration of their session -- well, yes, you can make your load balancer do that for you, but the larger answer is that You're Doing It Wrong.
Since you're using PHP, you might find the blog entry at http://kevin.vanzonneveld.net/techblog/article/enhance_php_session_management/ (describing using memcached for PHP session storage) useful.
精彩评论