使用 Jersey Jax-RS 在单个服务器上执行 15K 请求/秒的 Tomcat [英] Tomcat doing 15K req/second on a single server using Jersey Jax-RS

查看:32
本文介绍了使用 Jersey Jax-RS 在单个服务器上执行 15K 请求/秒的 Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 VPS 上进行测试,结果接近每秒 1 万个请求,那是一个简单的hello world"servlet,更不用说调用 membase.

I tried testing things on a VPS, and came close to 10K requests per second, and that was a simple 'hello world' servlet, let alone making a call to membase.

我的 VPS 是 2 x Intel Xeon X5570,四核Nehalem"架构.

My VPS was a 2 x Intel Xeon X5570, quad-core "Nehalem" architecture.

注意:我不是java专家,也不是tomcat专家,这是默认设置.

Note: I'm not a java expert, nor a tomcat expert, this was on default settings.

有没有其他人处理过如此高的流量,可以透露一些信息?

Does anyone else deal with such high traffic that could shed some light?

我使用了 apache bench,运行了 4-5 次,向服务器发出了大约 10 万个请求.

I used apache bench, and I ran it maybe 4-5 times, doing about 100K requests to the server.

原文:如何处理 2000+ 个请求/秒在 tomcat 上?

推荐答案

开启 NIO(非阻塞 IO).默认情况下这不是打开的.如果没有 NIO,每个 HTTP 连接都由单个线程处理,并且限制取决于可用线程的数量.使用 NIO,单个线程可以处理多个 HTTP 连接,并且限制取决于可用的堆内存量.使用大约 2GB,您可以连接多达 20K 个连接.

Turn on NIO (Non-Blocking IO). This is not by default turned on. Without NIO, every HTTP connection is handled by a single thread and the limit is dependent on the amount of threads available. With NIO, multiple HTTP connections can be handled by a single thread and the limit is dependent on amount of heap memory available. With about 2GB you can go up to 20K connections.

开启NIO就是改变protocol属性rel="noreferrer"> 元素在 Tomcat 的 /conf/server.xml"org.apache.coyote.http11.Http11NioProtocol".

Turning on NIO is a matter of changing the protocol attribute of the <Connector> element in Tomcat's /conf/server.xml to "org.apache.coyote.http11.Http11NioProtocol".

<Connector
    protocol="org.apache.coyote.http11.Http11NioProtocol"
    port="80"
    redirectPort="8443"
    connectionTimeout="20000"
    compression="on" />

这篇关于使用 Jersey Jax-RS 在单个服务器上执行 15K 请求/秒的 Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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