什么决定了同时连接的数量 [英] What determines number of simultaneous connections

查看:117
本文介绍了什么决定了同时连接的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java servlet环境中,有哪些因素是同时用户数量的瓶颈。

In a Java servlet environment, what are the factors that are the bottleneck for number of simultaneous users.


  1. 服务器每个端口允许的HTTP连接数

  2. 服务器可以连接的HTTP连接数允许跨多个端口(我可以在多个HTTP端口上有多个WAS配置文件)

  3. 池中的servlet数量

  4. 为WAS配置的线程数用于服务连接

  5. 服务器可用的RAM(假设应用程序中存在0内存泄漏,服务线程数之间是否有任何相关性)

  1. Number of HTTP connections the server can allow per port
  2. Number of HTTP connections the server can allow across several ports (I can have multiple WAS profiles on several HTTP ports)
  3. Number of servlets in pool
  4. Number of threads configured for WAS to use to service connections
  5. RAM available to server (is there any any correletation between number of service threads assuming 0-memory leak in application)

还有其他因素吗?

编辑:
为了使业务逻辑脱离图片,假设只有一个servlet在Log4j上打印一行。

Edited: To leave business logic out of the picture, assume have only one servlet printing one line on Log4j.


  • 我的Tomcat服务器可以同时处理6000个HTTP连接吗?为什么没有
    (文件处理?每个请求的CPU时间?)?

  • 我可以将线程池​​大小设置为5000(空闲线程是否花费CPU / RAM)?

  • 我可以将oracle连接池大小设置为500个连接(空闲
    连接需要CPU / RAM)?

为每个连接生成的垃圾量是否会产生影响?例如,如果对于每个HTTP连接,创建了20KB的对象并由Tomcat遗留下来......那么在处理2500个请求时将使用100MB堆,这可能会触发300毫秒的GC暂停。

Is the amount of garbage that is generated for each connection have an impact? For example, if for each HTTP connection 20KB of objects are created and left behind by Tomcat.. then by the time 2500 requests are processed 100MB heap would be used and this may trigger a GC pause of 300ms.

我们可以这样说:如果Tomcat使用0.2秒的CPU时间来处理单个HTTP请求,那么它将能够在一秒钟内处理大约500个http连接。所以,6000个连接需要5秒。

Can we say something like this: if Tomcat uses 0.2 sec of CPU time for processing a single HTTP request, then it would be able to handle roughly 500 http connections in a second. So, 6000 connections would need 5 seconds.

推荐答案

有趣的问题,如果我们将所有性能决定属性分开,最后它归结为你在servlet中做了多少工作,或者如果它有最高的I / O,CPU和内存需要多少时间。现在让我们向下移动并列出上面的语句; -

Interesting question, If we leave apart all the performance deciding attributes finally it boils down to how much work you are doing in the servlet or how much time it takes if it has highest I/O, CPU and memory. Now lets move down with you list with the above statement in mind;-


服务器每个端口允许的HTTP连接数

Number of HTTP connections the server can allow per port

limit ,但这又是由servlet完成请求的时间或请求需要多长时间来触发的第一个字节接收完成发送整个响应。因为如果它只需要1ms并且你正在使用Netty和持久连接,你可以达到一个非常高的>> 6000。

There are limit for file descriptors but that again gets triggered by how much time a servlet is taking complete a request or how much time it takes from request first byte receive to finish sending the entire response. Because if it take only 1ms and you are using Netty and persistent connection, you can reach a really high >> 6000.


servlet数量在池中

Number of servlets in pool

理论上>> 6000.但有多少线程正在处理您的请求?是否有一个线程池正在烧毁您的请求?所以你想增加线程,但多少可以说2000并发线程。您的CPU在上下文切换时表现不佳吗?它受I / O限制吗?如果是,那么上下文切换是有意义的,但是你会达到那些网络限制,因为很多线程在网络I / O上等待,所以最终你花了多少时间在一项工作上。

Theoretically >> 6000. But how many thread are processing your requests? Is there a thread pool that is burning your requests ? So you want to increase threads, but how much lets say 2000 concurrent threads. Is your CPU behaving poor with context switching ? Is it I/O bound? if yes it makes sense to context switch but then you will be hitting those network limits because a lot of thread waiting on network I/O, so ultimately how much time you spent on a piece of work.


DB

DB

如果是oracle,请用连接管理祝福你,你绝对是这里需要严格的监控。现在这只是另一个限制因素,可以被视为另一个阻塞I / O.根据I / O的定义,延迟/吞吐量很重要,并且当它变得比最小的工作更大时就成为瓶颈。

If it oracle, bless you with connection management, you definitely need rigorous monitoring here. Now this is just another limiting factor and can be considered as an just another blocking I/O. By definition of I/O, latency/throughput matters and becomes a bottleneck the moment it becomes the bigger than the smallest piece of work.

所以,最后,你需要分解所有servlet的以下或更多属性

So, finally, you need to break down following or more attributes for all the servlets


  1. 是否受CPU限制?如果是,它需要多少循环,或者可以安全地转换为某个时间单位。例如仅计算工作时间为1ms。

  2. 是否受I / O约束,如果是,则同样找到该单位。

  3. 和其他

  4. 您所拥有的一长串清单,例如: CPU,内存,GB / s

  1. Is it CPU bound? If yes, how much cycles it takes or can it be converted safely to some time unit. e.g. 1ms for just the compute piece of work.
  2. Is it I/O bound, If yes similarly find the unit.
  3. and others
  4. A long list of what you have, e.g. CPU, Memory, GB/s

现在你知道需要做多少工作而你所做的就是除以你所拥有的东西并保持调整,以便您找到最佳状态,并找出您未考虑的其他属性并考虑它们。

Now you know how much work needs to be done and all you do is divide by what you have and keep tuning , so that you find out the optimal and also find out what else attribute you have not considered and consider them.

这篇关于什么决定了同时连接的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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