简体   繁体   English

带有Jetty的Java Web服务器 - TCP连接需要很长时间

[英]Java Web Server with Jetty - TCP Connections Taking Long

I have an application with fairly high traffic (20K req/min) running on the JVM with a Jetty servlet container on Ubuntu. 我有一个在JVM上运行相当高的流量(20K req / min)的应用程序,在Ubuntu上有一个Jetty servlet容器。 Below is my Jetty configuration: 以下是我的Jetty配置:

10 20 2000 2 10 20 2000 2

When I analyze the network traffic, I realize that sometimes it is taking long to establish TCP connections on the port that Jetty is running. 当我分析网络流量时,我意识到有时需要很长时间才能在Jetty运行的端口上建立TCP连接。 The long connections are varying between 3.0s and 9.0s. 长连接在3.0s和9.0s之间变化。 The port is configured to accept MAX number of TCP connections. 端口配置为接受MAX个TCP连接。 Do you know what might be causing the delay in accepting connections? 你知道什么可能导致接受连接的延迟吗?

Thanks 谢谢

Unfortunatly you didn't give more technical background. 不幸的是,你没有提供更多的技术背景。

I assume you face a very high system load, since the connections are established the backlog (parameter for listen system call [ServerSocket]) is high enough. 我假设你面临一个非常高的系统负载,因为连接建立了backlog(监听系统调用[ServerSocket]的参数)足够高。

Accepting connections always involve a switch to kernel mode, this may cause a high system load and can be resolved only by scaling the application (using load balancing ) ie you need bigger machines or more of them. 接受连接总是涉及切换到内核模式,这可能会导致高系统负载,并且只能通过扩展应用程序(使用负载平衡)来解决,即您需要更大的机器或更多的机器。

I believe you're using a "connection per request" model. 我相信你正在使用“每个请求连接”模型。 If so, try to look into following: 如果是这样,请尝试查看以下内容:

  • make persistent connections, where the same requester reuses the connection 建立持久连接,同一请求者重用连接
  • switch to UDP messages 切换到UDP消息
  • use a load balancer+cluster on two+ boxes 在两个+框上使用负载均衡器+集群

Kernel/application tuning may help, but at 20K/min => 330 TPS I'd say you have to look at different architectural solution, not just tuning. 内核/应用程序调优可能会有所帮助,但在20K / min => 330 TPS时我会说你必须看看不同的架构解决方案,而不仅仅是调优。 Establishing a TCP connection is a pretty heavy operation, which involves kernel machinery, and thus context switch. 建立TCP连接是一项非常繁重的操作,涉及内核机制,因此涉及上下文切换。

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

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