java WebSphere 中跨 JVM 的会话复制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/939253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Session replication across JVMs in WebSphere
提问by Subramanian
We have an infrastructure set up where in the webservers are clustered and the application servers are not. The webservers route the request to the application servers based on round-robin policy.
我们建立了一个基础设施,其中 Web 服务器是集群的,而应用程序服务器不是。Web 服务器根据循环策略将请求路由到应用程序服务器。
In this scenario, the session data available in one application server is not available in the other application server. Is there anyway by which the session data from first application server can be made available in the second application ? The two application servers are physically separate boxes in different cells.
在这种情况下,在一个应用程序服务器中可用的会话数据在另一个应用程序服务器中不可用。无论如何,来自第一个应用程序服务器的会话数据是否可以在第二个应用程序中可用?两个应用程序服务器是不同单元中物理上独立的盒子。
One approach could be to use the database - is there any other means of accomplishing this session replication ?
一种方法可能是使用数据库 - 有没有其他方法可以完成此会话复制?
回答by dertoni
In WebSphere there are essentially two ways to replicate session data:
在 WebSphere 中,基本上有两种方法来复制会话数据:
- Persisting to a database
- Memory-To-Memory transfers
- 持久化到数据库
- 内存到内存传输
Which one is appropriate for your needs is highly dependent on your application scenario:
哪一种适合您的需求很大程度上取决于您的应用场景:
How important is the persistence of your session data, when all your application servers go down? How many session objects do you have at any one time simultaneously?
当您的所有应用服务器宕机时,会话数据的持久性有多重要?您在任何时候同时拥有多少个会话对象?
In a DB you can store many sessions without much problems, the other option is always a question of how much memory is available.
在数据库中,您可以存储许多会话而不会出现太多问题,另一个选项始终是可用内存的问题。
I would go with the database, if you already got one set up, which all application servers use anyway.
如果您已经设置了数据库,我会使用数据库,无论如何,所有应用程序服务器都使用它。
Here is the link to the WebSphere Information Centerwith the necessary details.
这是包含必要详细信息的WebSphere 信息中心的链接。
回答by Basil Vandegriend
One obvious solution is to enable clustering of your application servers. I assume from the way you worded your question you have rejected this option. Another option is to change the routing used by the web servers to use session affinity (requests for the same session go to the same app server).
一个明显的解决方案是启用应用服务器集群。我假设从您提出问题的方式来看,您已经拒绝了此选项。另一种选择是更改 Web 服务器使用的路由以使用会话亲缘关系(对同一会话的请求转到同一应用服务器)。
Other that that, I'd second the answer by dertoni.
除此之外,我会支持 dertoni 的答案。
回答by mransley
There are two options for clustering within WebSphere, session replication or database. If you have large session objects you are best off using database because it allows you to offload stale sessions to disk. If they are then represented then they can be extracted from the database, if you use session replication then those sessions need to stay in memory on not just your target server but also the other servers in the replication group. With large sessions this can lead to an out of memory condition.
WebSphere 中的集群有两个选项,会话复制或数据库。如果您有大型会话对象,最好使用数据库,因为它允许您将陈旧的会话卸载到磁盘。如果然后表示它们,则可以从数据库中提取它们,如果您使用会话复制,那么这些会话不仅需要保留在目标服务器上的内存中,还需要保留在复制组中的其他服务器上。对于大型会话,这可能会导致内存不足的情况。
With database session handling it is also very customisable and doesn't performance noticeably in the environments that I have used it.
通过数据库会话处理,它也是非常可定制的,并且在我使用它的环境中性能不明显。
回答by Salandur
maybe you can look at 'terracota'. its an caching framework, which can cache sessions and runs on a seperate server
也许你可以看看“兵马俑”。它是一个缓存框架,可以缓存会话并在单独的服务器上运行
回答by Ron
don't forget oracle coherence.
不要忘记 Oracle 一致性。

