Tomcat / jBOSS会话 - 它们通常存储在哪里? [英] Tomcat / jBOSS sessions - where are they usually stored?

查看:141
本文介绍了Tomcat / jBOSS会话 - 它们通常存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前言:我不是java开发人员。

Preface: I'm not a java developer.

我对Tomcat / jBOSS和其他java应用服务器有疑问。会话(会话数据)存储在哪里?在PHP中,会话通常存储在数据库中,这意味着您可以在负载平衡环境中轻松共享会话数据。在Tomcat和其他应用程序服务器中,默认情况下会话似乎存储在内存中,这不适用于负载平衡环境。虽然PHP默认情况下会将会话存储在文件中,但需要几行才能将其连接到数据库。应用程序服务器也是如此吗?

I have a question about Tomcat / jBOSS and other java application servers. Where are sessions (session data) stored? In PHP, sessions are usually stored in the database which means you can easily share session data in a load balanced environment. In Tomcat and other application servers, session seem to be stored in memory by default which would not apply in a load balanced env. While it is true that PHP stores sessions in files by default, it takes a few lines to hook it up to a DB. Is the same true of applications servers?

基本上,内存中故事会话的优点是什么?这仍然是应用服务器的标准做法吗?谢谢大家!

Basically, what's the pros for storying sessions in memory? Is this still standard practice for application servers? Thanks all!

推荐答案


我对Tomcat / jBOSS和其他java应用服务器有疑问。会话(会话数据)存储在哪里?

I have a question about Tomcat / jBOSS and other java application servers. Where are sessions (session data) stored?

默认情况下,我会在内存中说。细节实际上是......应用服务器特定的实现细节。

By default, I'd say in memory. Details are actually... implementation details which are application server specific.


在PHP中,会话通常存储在数据库中,这意味着您可以在负载平衡环境中轻松共享会话数据。在Tomcat和其他应用程序服务器中,默认情况下会话似乎存储在内存中,这不适用于负载平衡环境。

In PHP, sessions are usually stored in the database which means you can easily share session data in a load balanced environment. In Tomcat and other application servers, session seem to be stored in memory by default which would not apply in a load balanced env.

, 不完全是。这意味着客户端请求必须被发送到集群环境中的同一节点(这被称为会话粘性),从负载平衡的角度来看,这不是问题。但从故障转移的角度来看,这是一个问题:如果群集中的节点发生故障,该节点管理的会话状态可能会丢失。为解决此问题,几乎所有应用程序服务器提供程序都实现会话故障转移(使用各种机制,如内存中复制,基于JDBC的持久性等)。但是,实现细节再次是特定于应用程序服务器的。请参阅 Tomcat WebLogic 处理这个问题。服务器端的 J2EE集群的兜帽文章是一个非常有趣的阅读。

Well, not exactly. What this means is that a client request has to be sent to the same node in a clustered environment (this is referred to as "session stickiness") and this is not an issue from a load balancing point of view. But this is an issue from a failover point of view: in case of failure of a node in a cluster, session state managed by the node can be lost. To solve this, almost all application server providers implement session failover (using various mechanism such as in-memory replication, JDBC-based persistence, etc). But, again, implementation details are application server specific. See for example how Tomcat or WebLogic deal with that. The Under the Hood of J2EE Clustering article on The Server Side is a very interesting reading too.


虽然默认情况下PHP会将会话存储在文件中,但需要几行才能将它连接起来到DB。应用程序服务器也是如此吗?

While it is true that PHP stores sessions in files by default, it takes a few lines to hook it up to a DB. Is the same true of applications servers?

正如我所说,并非所有应用程序服务器都提供基于JDBC的持久性。说到这一点,并回答你的问题,配置一般都很简单。但是使用数据库确实不是首选的解决方案(实际上,我不惜一切代价避免它)。

As I said, not all application servers will offer JDBC-based persistence. Having that said, and to answer your question, configuration is in general simple when they do. But using a database is really not the preferred solution (actually, I avoid it at all price).


基本上,故事的优点是什么记忆中的会话?这仍然是应用服务器的标准做法吗?

Basically, what's the pros for storying sessions in memory? Is this still standard practice for application servers?

简单地说:表现!序列化数据,调用数据库,写入磁盘,所有这些都需要付出代价。内存中复制显然可以避免一些开销。但它也有一些限制。例如,它不允许 WAN HTTP会话使用WebLogic进行状态复制。但是,只有少数人需要这个:)

Simply: performance! Serializing data, calling a database, writing to disk, all this has a cost. In-memory replication obviously allows to avoid some overhead. But it has some limitation too. For example, it doesn't allow WAN HTTP Session State Replication with WebLogic. But well, only few people need this :)

这篇关于Tomcat / jBOSS会话 - 它们通常存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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