I'm sure some will argue that speed is not the most important characteristic of a REST framework, and things like stability, maturity, advanced features matter more. Well, they may or may not be right, but in any case performance is an important aspect.
While surely I missed someone's pet JAX-RS framework, I think I have selected the three mainstream ones:
- CXF - I use it for several years, I have always been a happy user
- Jersey - The reference implementation from Sun/Oracle
- Resteasy - The JBoss implementation of JAX-RS
- I have implemented a single Hello service annotated with JAX-RS annotations, this is in a separate maven module and used by framework-specific webapps.
- All web modules are configured with Jackson 2
- For simplicity, the services are registered in spring, however Jersey does not allow it the way Resteasy and CXF do
- All tests are performed using Jetty 9.2.2.
- For warm-up, I gave each test 1M requests on a single thread.
- The test tool was the Apache httpd benchmark utility 'ab'. Each result was performed separately with 100.000 requests and 1,2,4,8,16 concurrent threads.
- Source code of the tests available on github.
- All tests performed on the same laptop. Fedora 20, Oracle Java 1.7.0_45, AMD E2-1800 wreck
CommentsI was kind of surpried to see how much better Resteasy performed and looked under the hoods of the frameworks to figure out what they do when I hit the URL. Well, after a few hours of digging I concluded that most of it is the abstraction layer. CXF is not only for REST but also for JAX-WS, it can consume messages with JMS and so on, and that abstraction layer takes it.
I have also implemented a very thin experimental JAX-RS 2.0 implementation to see how that works and with the same tests it outperformed the mainstream frameworks with roughly 2000 request/second. I would not dare to replace CXF with that :-D but kind of interesting to think about it.