users@jersey.java.net

[Jersey] Re: Slow performance with _at_Produces("text/plain")

From: Adnan <adnan.maks_at_gmail.com>
Date: Mon, 30 Jul 2012 20:12:37 +0530

Hi Phineas ,

Have you tried POJOMappingFeature (to be configured in web.xml and also at
client end if you are using jersey-client). That's makes my JSON streaming
faster.

If you did not use this feature, the streamed JSOn at server-end is first
converted to XML and then mapped to the POJO values. When you use this
feature, it does direct JSOn-POJO values conversion.

- Adnan


On Fri, Jul 20, 2012 at 12:15 AM, Phineas Dole <phineasdole_at_yahoo.com>wrote:

> 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.)
>



-- 
Thanks and Regards,
Adnan, Mohammed
Bangalore
cell:+91 9886529874