Hello,
I have a question regarding the performance of Jersey. I observe that producing text/plain content is measurably slower than producing more complex application/xml. I see a similar slow-down when producing application/json, which is truly what I want to utilize. These results have been reproduced on several different machines. How do I achieve the same performance of application/xml instead using text/plain or application/json?
Currently, I am basing my experiences off of
http://gitorious.org/java-rest-example (I have updated the pom.xml to use jersey version 1.13).
Test 1:
-------
@GET
@Produces("application/xml")
public MessageDTO getMessage() {
return new MessageDTO("Hello World");
}
Response:
<message>
<content>Hello World</content>
</message>
Performance:
ab -kc 100 -n 100000
http://localhost:8080/java-rest-example/rest/helloworld
Requests per second: 46391.48 [#/sec] (mean)
Test 2:
-------
@GET
@Produces("text/plain")
public String getMessage() {
return "sup";
}
Response:
sup
Performance:
ab -kc 100 -n 100000
http://localhost:8080/java-rest-example/rest/helloworld
Requests per second: 17609.93 [#/sec] (mean)
(I have given the JVM time to warm up before performing any benchmarking.)