快速NIO,对Java的异步HTTP服务器 [英] Fast NIO, asynchronous HTTP Server for Java

查看:220
本文介绍了快速NIO,对Java的异步HTTP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继<一个href=\"http://stackoverflow.com/questions/1133156/simple-java-stand-alone-server-container-framework\">this问题我其实是在寻找我的项目之一正确的HTTP容器的阶段了。我看了看几个容器,但我仍然不知道哪一个将是最适合高负载AJAX的请求。 Apache的米纳看起来相当看好,但相对复杂也是如此。所谓AsyncWeb异步Web服务器的实现似乎已经合并,但米娜我找不到它的任何生产RELASE,但。在其他的问题,我建议简单的HTTP服务器我真的很喜欢,因为它是...好简单,清晰,干净,但我依然不知道这是否会适合的目的。

Following on this question I am actually in the phase of finding the right HTTP container for one of my projects, too. I looked at several containers but I'm still not sure which one will be best suited for high load AJAX only requests. Apache Mina looks quite promising, but relatively complex as well. The asynchronous web server implementation called AsyncWeb seems to have been merged with Mina but I couldn't find any production relase of it, yet. In the other question I recommended the Simple HTTP server which I really like because it is... well simple, clear and clean but I still don't know if it would fit the purpose.

此外我不知道哪个请求处理概念来选择:

Additionally I'm not sure on which request handling concept to choose:


  1. 创建为每个传入的连接(当然优化可以包括一个线程池和调度的队列),即做所有的工作的调度线程。它的优点是可能的是,我没有要处理许多同步问题,但它可能会降低对高负荷吞吐量急剧下降。

  1. Create a dispatcher Thread for every incoming connection (optimizations might of course include a thread pool and a dispatching queue), that is doing all the work. The advantage is probably, that I don't have to deal with that many synchronisation issues but it will probably lower the throughput on high loads drastically.

由于这将是一个高度模块化的应用程序中的流水线(有可能是一个更合适的词我猜;)方法可能以及工作:创建一个固定数量的线程,每一个特定的任务。
例如。一个请求处理 - >一个头反序列化(如果我得到的输入不同的格式,如subtmitted HTML表单,XML-RPC的,JSON等) - >之一控制调度(做我想做这些数据做) - >和一个用于在所希望的格式序列输出(JSON,XML,HTML等),并通过这些水平,直至完成移动每个请求。可能更难以实现,但是我有螺纹的数字(可以在硬件上dependend以及)和关注点分离的固定数目

Because it is going to be a highly modular application a "pipelining" (there might be a more fitting term I guess ;) approach might work as well: Create a fixed number of Threads, each for a certain task. E.g. one for request handling -> one for header deserialization (if I get input in different formats like subtmitted HTML Forms, XML-RPCs, JSON etc.) -> one for "Controller Dispatching" (doing whatever I want to do with these data) -> and one for serializing the output in the desired format (JSON, XML, HTML etc.) and move every request through these levels until it is completed. Probably more difficult to realize but I have a fixed number of Threads (the number can dependend on the hardware as well) and a clean separation of concerns.

与任何框架的任何经验可能适合和两个不同的处理方法?

Any experiences with any Framework that might fit and the two different handling approaches?

推荐答案

有上href=\"http://www.simpleframework.org/\" rel=\"nofollow\">简单的HTTP 颠覆存储库。

There is an example on the Simple HTTP subversion repository.

<一个href=\"http://simpleweb.svn.sourceforge.net/viewvc/simpleweb/trunk/src/demo/java/org/simpleframework/example/javafx/\" rel=\"nofollow\">http://simpleweb.svn.sourceforge.net/viewvc/simpleweb/trunk/src/demo/java/org/simpleframework/example/javafx/

它使用彗星和只能有一个线程调度更新到任意数量的客户展示了实时市场数据。简单有提供阻塞I / O语义与基于NIO围绕固定的ByteBuffer队列为每个连接的客户端异步分派的优势的透明传输层。所以,你得到predictable的内存消耗的顺利透明NIO输出。对像码头服务器也表现的测量结果表明大约X2的性能改善。

It demonstrates realtime market data using comet and only one thread dispatching updates to any number of clients. Simple has a transparent transport layer that provides blocking I/O semantics with the advantage of asynchronous dispatch with NIO based around fixed ByteBuffer queues for each connected client. So you get a smooth transparent NIO output with predictable memory consumption. Also performance measurements against servers like Jetty show about a x2 performance improvement.

<一个href=\"http://simpleweb.svn.sourceforge.net/viewvc/simpleweb/trunk/application/Plotter/ApacheBench/ScalabilityApacheBench.png?revision=1448\" rel=\"nofollow\">http://simpleweb.svn.sourceforge.net/viewvc/simpleweb/trunk/application/Plotter/ApacheBench/ScalabilityApacheBench.png?revision=1448

这篇关于快速NIO,对Java的异步HTTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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