简体   繁体   English

用于java的非阻塞io webserver / framework

[英]Nonblocking io webserver/framework for java

Does anyone know of any node.js style webserver framework for java? 有谁知道java的任何node.js样式的webserver框架? I realized that having nonblocking callback behavior while handling a web request will require deep support at the webserver level. 我意识到在处理Web请求时具有非阻塞回调行为需要在Web服务器级别提供深度支持。 I am interested in node.js, but when I have a web server that ends up persisting data, I would like to take advantage of the static type system that Java offers. 我对node.js感兴趣,但是当我有一个最终持久化数据的Web服务器时,我想利用Java提供的静态类型系统。 However, I want the scalability of non-blocking io. 但是,我想要非阻塞io的可扩展性。

Grizzly may be what you're looking for. 灰熊可能是你正在寻找的。

Further, if you're interested in using the Servlet API, which also offers asynchronous support since 3.0 , then it may be good to know that decent servletcontainers supports NIO as well (often by just utilizing Grizzly under the covers) like Apache Tomcat 7 and Oracle Glassfish 3 . 此外,如果您对使用自3.0之后也提供异步支持的Servlet API感兴趣,那么可能很高兴知道正常的servletcontainers也支持NIO(通常仅使用Grizzly),如Apache Tomcat 7Oracle Glassfish 3

My take on this is Play! 我对此的看法是Play! Framework (See http://www.playframework.com/ ). 框架(见http://www.playframework.com/ )。 It supports development in Java and Scala. 它支持Java和Scala的开发。 Play is built on top of Netty (See http://netty.io/ ) which itself is a NIO (Non-blocking IO) client-server framework. Play建立在Netty之上(参见http://netty.io/ ),它本身就是一个NIO(非阻塞IO)客户端 - 服务器框架。 Play (and Netty) use Futures (result of an asynchronous operation/a read handle to something that may happen at some point of time in future) and Promises(a writable Future) to solve this problem (See http://en.wikipedia.org/wiki/Futures_and_promises ) Play(和Netty)使用Futures(异步操作的结果/读取句柄来处理将来可能发生的某些事情)和Promises(可写的Future)来解决这个问题(参见http://en.wikipedia) .org / wiki / Futures_and_promises

Maybe you don't want it at all. 也许你完全不想要它。 There's a lot of evidence emerging that 'scalable NIO' doesn't really deliver its benefits until an enormous number of clients. 有大量证据表明,“可扩展的NIO”在大量客户面前无法真正实现其优势。 Remember that select() and friend were designed back when the unit of computation was a process, not a thread. 请记住,当计算单位是一个进程而不是一个线程时,select()和friend被设计回来了。 Unless you are plannig on having hundreds of thousands of ocnnections from day one, I would definitely build in java.net first and then evaluate. 除非你计划从第一天开始就有数十万个连接,否则我肯定会首先在java.net中构建然后进行评估。

Deft 麻利

Features 特征

  • Specialized and optimized for thousands of simultaneous connections. 专为数千个同步连接而优化和优化。 (C10k) (C500k) (C10k)(C500k)
  • Using pure Java NIO (java.nio & java.nio.channels) 使用纯Java NIO(java.nio和java.nio.channels)
  • Asynchronous (nonblocking I/O) 异步(非阻塞I / O)

Currently two major frameworks you can use 目前您可以使用两个主要框架

  1. Play
  2. Vert.x (it was originally named node.x) Vert.x(最初名为node.x)

I asked myself the same question, and instead of searching around like I should have, I looked at how you might write a framework for deploying software components to a nio server, similar to the way you might deploy servlets and ejbs to a Java EE container. 我问自己同样的问题,而不是像我应该那样搜索,我看了你如何编写用于将软件组件部署到nio服务器的框架,类似于将servlet和ejbs部署到Java EE容器的方式。 I've blogged it at http://blog.maxant.co.uk/pebble/2011/05/22/1306092969466.html , in case that helps you. 我在http://blog.maxant.co.uk/pebble/2011/05/22/1306092969466.html上发布了博客,以防万一。

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

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