如何管理Web集群中的会话变量? [英] How to manage session variables in a web cluster?

查看:63
本文介绍了如何管理Web集群中的会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会话变量通常保存在Web服务器的RAM内存中。



在集群中,客户端发出的每个请求都可以由不同的集群节点处理。是吗?!



所以,在这种情况下...




  • 会发生什么与会话变量?它们不是存储在节点RAM内存中吗?

  • 如果没有我的会话变量或至少没有所有会话变量,其他节点将如何正确处理我的请求?

  • 此问题是由Web服务器(Apache,IIS)还是由语言运行时(PHP,ASP.NET,Ruby,JSP)处理?



编辑:是否有经典ASP 解决方案?

解决方案

以扩展@yogman的答案。 / p>

Memcached 真是太棒了!这是一个高性能的分布式对象缓存。



即使我提到了分布式,它基本上就像在一个备用/空闲服务器上启动一个实例一样简单,但是您可以对其进行配置

  memcached -d -u www -m 2048,如ip,port和使用多少ram一样。 -l 10.0.0.8 -p 11211 

(以守护程序模式运行memcached,作为用户www,2048 MB (2 GB)IP 10.0.0.8上具有端口11211的RAM。)



从那时起,您向memcached询问数据,如果尚未缓存数据,则拉从原始来源将其存储在memcached中。我确定您熟悉缓存基础知识。



在集群环境中,您可以将memcached链接到集群中,并在节点之间复制缓存。 Memcached可以在Linux,Unix和Windows上运行,可以在有可用RAM的任何地方启动它,并开始使用资源。



memcached的API应该为通常可用。我说应该是因为我只了解Perl,Java和PHP。但我敢肯定在Python中,人们也有能力利用它。有一个 memcached Wiki ,以防您需要指针或在评论中告诉我如果我太疯狂了。 ;)


Session variables are normally keept in the web server RAM memory.

In a cluster, each request made by a client can be handled by a different cluster node. right?!

So, in this case...

  • What happens with session variables? Aren't they stored in the nodes RAM memory?
  • How the other nodes will handled my request correctly if it doesn't have my session variables, or at least all of it?
  • This issue is treated by the web server (Apache, IIS) or by the language runtime (PHP, ASP.NET, Ruby, JSP)?

EDIT: Is there some solution for Classic ASP?

解决方案

To extend @yogman's answer.

Memcached is pure awesomeness! It's a high performance and distributed object cache.

And even though I mentioned distributed it's basically as simple as starting one instance on one of your spare/idle servers, you configure it as in ip, port and how much ram to use and you're done.

memcached -d -u www -m 2048 -l 10.0.0.8 -p 11211

(Runs memcached in daemon mode, as user www, 2048 MB (2 GB) of RAM on IP 10.0.0.8 with port 11211.)

From then on, you ask memcached for data and if the data is not yet cached you pull it from the original source and store it in memcached. I'm sure you are familiar with cache basics.

In a cluster environment you can link up your memcached's into a cluster and replicate the cache across your nodes. Memcached runs on Linux, Unix and Windows, start it anywhere you have spare RAM and start using your resources.

APIs for memcached should be generally available. I'm saying should because I only know of Perl, Java and PHP. But I am sure that e.g. in Python people have means to leverage it as well. There is a memcached wiki, in case you need pointers, or let me know in the comments if I was raving too much. ;)

这篇关于如何管理Web集群中的会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆