欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

related articles about LVS & Http Session

程序员文章站 2022-03-23 16:46:50
...
Session in http unde LVS
http://lists.community.tummy.com/pipermail/linux-ha-dev/2001-December/002993.html
引用

2. I can set up a separate URL for session based apps that sends all requests
to  a heatbeat duplicated session manager on the first tier using
Apache/webapps/Tomcat  to load balance to the next tier down. The load
balancing in webapps/mod_jk  assures that the session always returns to the
same machine the the cluster.  This solution increases the complexity of the
cluster and it's management.. If the load grows too much I can always
esatblish another set of session managers. I don't have to go hammer my
developers to comply with yet another set of demands out of systems. It's
hard enough to get compliance on logging and testing....


LVS: Cluster friendly versions of applications that need to maintain state
http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.cluster_friendly_applications.html
引用

    *

      What are sessions?

      When an application written on top of a stateless protocol like HTTP has a need of stateful transactions, it typically writes some data to disk between requests and retrieves these data again on the subsequent request. This mechanism is known as session handling. The session data typically get written to files or databases. Each followup-request sends some sort of token to the server so that the application can retrieve the correct file or correct record in the database.
    *

      The old-fashined way to identify sessions

      At the time when every webserver was a single PC, the session token identified a filename or a record in a database and everything was OK. When an application that relies on this mechanism is ported to a cluster environment, it stops working unless one deteriorates the cluster with a mechanism called persistence. Persistence is a quick and dirty way to get the old-fashioned token to work. It's not a very clever way though.
    *

      Why persistence is bad

      Persistence counteracts two purposes of a cluster: easy maintainance by taking single machines out at any time and optimized balancing between the members of a cluster. Above that, persistence consumes memory on the load balancers.
    *

      How to do it better

      Recall that there is a token being sent back and forth anyway, that identifies a filename or a database record. Extend this token to unambiguously point to the machine where the session data were created and install a session server on each host that delivers session data within the cluster to any of the peers on request. From that moment you can run your application truely distributed, you can take single machines out for maintainance any time: you turn their weight to 0 and wait for maybe an hour or three, depending on how long you want your sessions to last. You get better balancing, and you save memory on the balancer. Note, that unlike with a dedicated session server, you do not create a single point of failure with this method.


集群的可扩展性及其分布式体系结构之七--网络负载平衡常见问题
http://www-128.ibm.com/developerworks/cn/linux/cluster/cluster_system/balance/part3/
引用

LVS的存储一致性问题:
在一个通过LVS组建的Web集群环境中,所有涉及Session的应用都面临这样的矛盾:由于会话信息存储在服务结点上,因此一旦建立一次会话--例如登录bbs,之后的所有数据传输必须硬性的指向建立会话连接的节点(该Session以文件的形式保留在节点服务进程的路径下)。这样,会在调度算法上破坏原本正常运行的负载平衡。

但是如果把所有的文件读写放在同一个磁盘上或者指向同一个NFS服务器,可以解决文件读写不一致的问题。但又导致新的问题出现:提供I/O服务的节点成为集群的性能瓶颈!
怎么解决这一效率与功能之间的矛盾呢?可能的方式有:
1、 改写Apache服务器,使之适应LVS的分布式环境
2、 降低性能要求,使用NAS或者NFS服务进行磁盘共享
3、 撰写特殊的PHP或者脚本语言代码
4、 采用分布式文件系统