简体   繁体   English

性能:com.sun.net.httpserver.HttpServer与Jetty

[英]Performance: com.sun.net.httpserver.HttpServer vs. jetty


i'm working on a java web application which will sends and receives JSON strings. 我正在使用Java Web应用程序,它将发送和接收JSON字符串。 The JSON is generated through jersey and maps to a jaxb anotated pojo. JSON是通过jersey生成的,并映射到带有jaxb注释的pojo。

The application itself isn't very complex but needs to work under heavy traffic. 该应用程序本身不是很复杂,但是需要在高流量下工作。 I tried two approaches. 我尝试了两种方法。 First servlet based with jetty as container and second as console application with oracles HttpServer class (using jetty through "HttpServerFactory.create(..)"). 第一个基于Jetty的servlet作为容器,第二个基于oracles HttpServer类的作为控制台应用程序(通过“ HttpServerFactory.create(..)”使用jetty)。

I tested both versions with apaches ab tool. 我使用apache ab工具测试了两个版本。 Doing 10,000 request on a concurrency level of 100. To my surprise console application needed significantly less time to response and had a higher transfer rate. 在100个并发级别上执行10,000个请求。令我惊讶的是,控制台应用程序所需的响应时间大大减少,传输速率更高。 I expected the opposite result. 我期望相反的结果。

Is a plain console app realy a better solution in therms of performance for small applications? 在小型应用程序的性能方面,普通的控制台应用程序是否真的是更好的解决方案? Thanks. 谢谢。

Without more information it's almost impossible to tell why your console application performed faster than the Jetty server. 没有更多信息,几乎不可能说出您的控制台应用程序比Jetty服务器执行得更快的原因。

I would expect that an embedded Jetty instance could perform a little faster than a Jetty servlet as the embedded Jetty instance would be able to strip away parts of the servlet API that aren't needed (in that application) and thereby reduce overheads. 我希望嵌入式Jetty实例的性能比Jetty servlet快一点,因为嵌入式Jetty实例将能够剥离该应用程序中不需要的servlet API部分,从而减少开销。 I would not expect the difference to be significant. 我认为差异不会很大。

But : in a small benchmark like the one you performed, I'd be much more likely to suspect that a configuration issue (in either the server or the benchmark) is producing the difference in results. 但是 :在像您执行的小型基准测试中,我更有可能怀疑配置问题(无论是服务器还是基准测试)都会导致结果差异。

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

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