简体   繁体   English

如何确定Web应用程序的会话数过多

[英]How to determine as to how many sessions are too many for a web application

I have Jboss application server running Oracle Commerce. 我有运行Oracle Commerce的Jboss应用服务器。 I have 5 Page serving instance[VM Servers] and around 300 users browsing site at any given time. 我有5个页面服务实例[VM Servers],并且在任何给定时间都有大约300个用户在浏览网站。 I am trying to come up with a number for Session timeout, so that customer have enough time to browse and checkout, but then also do not want too many open sessions that would hold up the memory. 我正在尝试为会话超时提供一个数字,以便客户有足够的时间浏览和签出,但同时也不要太多打开的会话来占用内存。 So my question is there a rule of thumb to determine the session timeouts? 所以我的问题是确定会话超时的经验法则吗?

Jboss 7, Java 7 with 8gb memory for each jvm. Jboss 7,Java 7,每个jvm具有8GB内存。 Currently session timeout is set at 10 mins. 当前会话超时设置为10分钟。 Would like to increase it to 30 mins. 希望将其增加到30分钟。

Here are the things I can think of: - Session size. 这是我能想到的事情:-会话大小。 - Thread pools - the number of concurrent threads to be server. -线程池-要作为服务器的并发线程数。 This is configurable by the application server. 这可以由应用程序服务器配置。 There are several thread pools available for the JBoss for example you have several pool for the servlet container separate for the EJB container and so on. JBoss有多个线程池可用,例如,您有多个servlet容器的池,这些池分别与EJB容器分开,依此类推。 You can read some details here. 您可以在此处阅读一些详细信息。 https://developer.jboss.org/wiki/ThreadPoolConfiguration#jive_content_id_Deploying_Threading_Components - Your use case. https://developer.jboss.org/wiki/ThreadPoolConfiguration#jive_content_id_Deploying_Threading_Components-您的用例。 How many concurrent users you expect. 您期望多少个并发用户。

If you run out of threads all further requests will be queued (I think this depends a bit on the Executor) but in the general case it is like that. 如果线程用完了,所有其他请求都将排队(我认为这在某种程度上取决于Executor),但通常情况下就是这样。 This puts a strain on the Memory. 这给存储器带来了压力。 So you should not operate above the maximum pool size. 因此,您不应在最大池大小以上进行操作。

The size of the session and the number of concurrent users you expect will help you out to figure out how your memory will grow over time. 会话的大小和您期望的并发用户数将帮助您确定内存随时间增长的方式。 You should take into account pick hours and how the site usage has grow in the last couple of years. 您应考虑挑选时间以及最近几年网站使用量的增长情况。

Here it should be noted that since you have online application you should prefer small HEAP size over large Heap size because of the garbage collector. 在这里应该注意的是,由于您具有在线应用程序,因此由于垃圾回收器的原因,您应该更喜欢小HEAP大小而不是大堆大小。 Probably it will be a good idea to use the new G1 Garbage collector. 使用新的G1垃圾收集器可能是个好主意。

Edit based on last comment: One naive way to measure the heap without very strong precision with help of profiler is: 1. Start server , make a test run with single user in order to initialize all the classes. 根据最新评论进行编辑:在探查器的帮助下,一种没有很强的精度来测量堆的简单方法是:1.启动服务器,以单个用户进行测试运行以初始化所有类。 2. Force garbadge collection and take a benchmark 3. Run for large sample of parallel users and observer your peak memory and how much the GC is able to free (force the GC again) when your pick memory is reached. 2.强制垃圾收集并进行基准测试。3.为大量并行用户样本运行,并观察您的峰值内存以及达到选择内存后GC可以释放的容量(再次强制GC)。

Now this is a naive approach. 现在,这是一种幼稚的方法。

A more complex approach would be to calculate the size of the session with the help of some object allocation monitoring tool (Use again profiler). 一种更复杂的方法是借助某些对象分配监视工具(再次使用事件探查器)来计算会话的大小。

Additionally you should consider to check the memory of the JVM by enable GC logging. 另外,您应该考虑通过启用GC日志记录来检查JVM的内存。 It will give a good idea when it get exhausted. 精疲力尽时,这将是一个好主意。 Another indicator is the CPU utilization. 另一个指标是CPU利用率。 It depends on the user activity and the application what is needed, if you have enough memory you can increase the number of parallel session as long as you have enough CPU power to handle the requests. 这取决于用户活动和应用程序需要什么,如果您有足够的内存,只要您有足够的CPU能力来处理请求,就可以增加并行会话的数量。

(i know this is an old post but this may help someone) (我知道这是一个旧帖子,但这可能会对某人有所帮助)

Cdesai, 克德赛

If you want to provide users with ample amount of time to browse and checkout without worrying about timeouts, you may consider using JavaScript to keep the session alive. 如果要为用户提供足够的时间来浏览和签出而不用担心超时,则可以考虑使用JavaScript来保持会话的活动状态。 As long as the window is up and the javascript is running the session remains active. 只要窗口打开并且javascript正在运行,会话就保持活动状态。 Once the window is closed or navigated away then your session timeout will continue with its countdown. 窗口关闭或导航后,您的会话超时将继续倒计时。 Should the user come back and the session timeout hasn't expired then the Javascript will ping the server to restart the countdown. 如果用户回来并且会话超时尚未到期,则Javascript将对服务器执行ping操作以重新开始倒计时。 This also helps with too many active sessions bogging down the server. 这也有助于使过多的活动会话陷入服务器瘫痪。 I use a similar setup but my session timeout is set low, 5 minutes, and the keepAlive function is at a two minute interval. 我使用类似的设置,但会话超时设置为5分钟,设置为低,而keepAlive函数的间隔为两分钟。

 function keepAlive() { var httpRequest = new XMLHttpRequest(); httpRequest.open('GET', "/restricted_file_url"); httpRequest.send(null); } setInterval(keepAlive, 840000); //My session expires at 15 minutes 

see Ivar's solution here 在这里查看Ivar的解决方案

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

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