简体   繁体   English

在多台服务器上运行时,Web应用程序会话如何工作?

[英]how do web application sessions work when running on more than one server?

This is a general question based on how web sessions work across multiple servers, my knowledge around web sessions is not very deep but afaik a web session is typically stored directly in memory of the running web server application so when a request comes in it doesn't have to make database requests to fetch the session data. 这是一个基于Web会话如何在多个服务器上工作的一般性问题,我对Web会话的了解不是很深,但是通常Web会话通常直接存储在正在运行的Web服务器应用程序的内存中,因此当请求进入时,它不会不必发出数据库请求来获取会话数据。 If a popular website needs multiple servers to handle the level of traffic it is receiving, when a request comes in I assume that it could get directed to any of the servers by some load balancer, but how does the server handling that request get the associated session data if the previous request was handled by a different server? 如果一个受欢迎的网站需要多个服务器来处理其接收的流量级别,则当请求传入时,我认为它可以由某个负载均衡器定向到任何服务器,但是处理该请求的服务器如何获得关联会话数据(如果先前的请求是由其他服务器处理的)? do multi server sites require special session handling infrastructure, or do the load balancers know some how to route requests from the same client to the same server? 多服务器站点是否需要特殊的会话处理基础结构,还是负载平衡器知道一些如何将请求从同一客户端路由到同一服务器?

This question on ServerFault is the same as this question. 关于ServerFault的此问题与此问题相同。 with a good answer. 一个很好的答案。 in overview there are 3 common methods: 概述中有3种常用方法:

  • Session information stored in cookies only 会话信息仅存储在cookie中
  • Load balancer always directs user to the same machine 负载平衡器始终将用户引导到同一台计算机
  • Shared backend database or key/value store. 共享的后端数据库或键/值存储。

See link for more indepth details of each. 请参阅链接,以获取每个的更详细的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM