Category Archives: Java

Java AIO (NIO.2) vs NodeJS

I just installed OpenJDK 7 on Ubuntu 10.04 LTS under VirtualBox (one core, 256 MB). I wanted to run a quick test to see how the new JDK7 Async channel APIs were performing in comparison with node. A simple test of a hello world running on a single core shows that the JVM truly has what it takes to be the best runtime for network servers. Most notably, compare the distribution of response times, especially at 99%. The advantage the JVM is showing might be enough to comfortably fit Rhino onto it.…

Quick benchmark checkpoint on Java and NodeJS

Java (my nodejs-inspired NIO/Netty based HTTP server):

Server server = Http.createServer();
server.setRequestListener(new RequestListener() {
    @Override
    public void service(ServerRequest request, ServerResponse response) {
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put("Content-Type", "text/html; charset=utf-8");
        headers.put("Content-Length", "47");
        response.writeHeader(200, headers);
        response.end("<html><body><h1>hüllo world</h1></body></html>");
    }
});
server.listen(8080);

Javascript:

http.createServer(function(req, res) {
    res.writeHead(200, {"Content-Length": "47",
                        "Content-Type": "text/html; charset=utf-8"});
    res.write("<html><body><h1>hüllo world</h1></body></html>");
    res.end();
}).listen(8080);

My quick “smoke” benchmark results using ab (MBA, 2 cores, 10.6.6, 4 GB, 2.13 GHz). First Java:

$ ab -k -n 2000 -c 200  http://localhost:8080/
Time taken for tests:   0.127 seconds
Complete requests:      2000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    2000
Total transferred:      305850 bytes
HTML transferred:       95833 bytes
Requests per second:    15693.29 [#/sec] (mean)
Time per request:       12.744 [ms] (mean)
Time per request:       0.064 [ms] (mean, across all concurrent requests)
Transfer rate:          2343.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0      10
Processing:     1    5   2.9      5      16
Waiting:        1    5   2.9      5      16
Total:          1    6   3.4      5      19

and then nodejs (kriszyp/multi-node using node 0.2.5 on 2 nodes):

$ ab -k -n 2000 -c 200 http://127.0.0.1:8080/
Time taken for tests:   0.225 seconds
Complete requests:      2000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    2000
Total transferred:      300150 bytes
HTML transferred:       94047 bytes
Requests per second:    8876.38 [#/sec] (mean)
Time per request:       22.532 [ms] (mean)
Time per request:       0.113 [ms] (mean, across all concurrent requests)
Transfer rate:          1300.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.9      0      11
Processing:     0   18   3.7     18      28
Waiting:        0   18   3.7     18      28
Total:          0   18   4.5     18      39

So far, so good.…

Facebook BigPipe in an Async Servlet

Since Subbu wrote BigPipe using node.js, I had to see how the same thing would look like in a Java async servlet.

Stephan Schmidt had already written Facebook BigPipe for Java, but using a synchronous servlet model, not asynchronous. I decided to implement it using Jetty continuations and the Jetty HTTP client, but the code should be easy to adapt to servlet 3.0 AsyncContext.

The code initially constructs the page with a few empty divs that will contain the pagelets, for example:

<div id='pagelet3'></div>

I keep the connection open from the browser to the server while I render pagelets.…

Out of the Eclipse to Netbeans

I have been using emacs and the command line for now almost 20 years. Once in a while, I dip into IDEs, but always go back to the command line. My biggest gripe with IDEs is that it keeps me away from the actual build, and that I normally have to spend time duplicating building configuration in the IDE. The canonical source for build configuration should be the build system (Make, ant, maven, etc.). With an IDE one would have to always be things in sync, leading to errors and all sort of weird stuff.…

Painfully HTTP Java

I have been working on AtomPub and coding a prototype over the past few evenings to get Apache Abdera talking to CouchDB. I know there is an experimental adapter in Abdera for CouchDB, but it does not use CouchDB the way I need to.

I decided to write my own provider, workspace manager, adapter, etc. I have been using couchdb4j, the Java library binding used to talk to CouchDB, and json-lib, a JSON library for Java.

Why, it has been really especially extremely very painful!…

Sun Microsystems set to buy MySQL

This is truly amazing. Sun and Oracle are set to buy all letters on the LAMP stack, with now Sun buying MySQL for 1 billion dollars (thanks Pascal for the ping). Maybe now Monty and David will start competing with Larry Ellison’s extravagant yacht department. Seriously, 1 billion dollars is a record price for any open source company. Will Oracle now finally buy RedHat to put pressure on SUN?

I am hoping to see the JAVA ticker symbol company improve MySQL support, and licensing, for Java.…

Java EE 5, still too complex

The Java EE 5 architecture, with its use of annotations brings the Java world close to being agile. The architecture is absolutely fantastic and powerful, with superb messaging (JMS), persistence (EJB3), transactions (JTA), and integration (JCA) capabilities.

However, on the presentation side, for the web world, Java is still behind both .NET and agile frameworks like Rails or Django. JSF is cumbersome, and still too attached to the systems-programming intensive request-response Model2 that ended up in JSPs and Struts. Wicket and Tapestry are possibly the top component-based development web frameworks for Java.…

SOAP and RMI

Latest benchmark results on WebSphere 6.0.1 seem to indicate that SOAP/HTTP outperforms RMI/IIOP. Interesting, it makes me wonder if the reason comes down to IBM abandoning CORBA and placing the best developers on the SOA field. Otherwise there is really no other explanation I can think of. I’ll have to instrument some code to understand the why.…