Nonblocking io webserver/framework for java

2019-03-31 05:58发布

Does anyone know of any node.js style webserver framework for java? I realized that having nonblocking callback behavior while handling a web request will require deep support at the webserver level. 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. However, I want the scalability of non-blocking io.

6条回答
萌系小妹纸
2楼-- · 2019-03-31 06:45

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. Remember that select() and friend were designed back when the unit of computation was a process, not a thread. 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.

查看更多
唯我独甜
3楼-- · 2019-03-31 06:49

Deft

Features

  • Specialized and optimized for thousands of simultaneous connections. (C10k) (C500k)
  • Using pure Java NIO (java.nio & java.nio.channels)
  • Asynchronous (nonblocking I/O)
查看更多
等我变得足够好
4楼-- · 2019-03-31 06:54

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.

查看更多
We Are One
5楼-- · 2019-03-31 06:56

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. I've blogged it at http://blog.maxant.co.uk/pebble/2011/05/22/1306092969466.html, in case that helps you.

查看更多
放我归山
6楼-- · 2019-03-31 07:02

My take on this is Play! Framework (See http://www.playframework.com/). It supports development in Java and Scala. Play is built on top of Netty (See http://netty.io/) which itself is a NIO (Non-blocking IO) client-server framework. 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)

查看更多
Explosion°爆炸
7楼-- · 2019-03-31 07:03

Currently two major frameworks you can use

  1. Play
  2. Vert.x (it was originally named node.x)
查看更多
登录 后发表回答