users@jersey.java.net

[Jersey] Re: Does jersey create a new resource instance for every call?

From: Tony Anecito <adanecito_at_yahoo.com>
Date: Thu, 20 Jan 2011 12:37:24 -0800 (PST)

Okay. I saw that this (creation of a new object) is standard for Jersey after I
sent the last message. The reason it is important not to call the constructor is
that is where connections to my EJB's was being made so I wanted it done only
once. Metro seems to be doing that and it appeared to be faster than Jersey till
I resolved this issue.
Anyway, I decided to use @Singleton and got a 50% performance improvement I was
looking for because the constructor was not being called all the time.
In my case my post time went from 8.2milliseconds to 3.5 milliseconds for round
trip as measured at the client.

Response time is important to me and conservative use of the CPU also. Creating
a new Resource object for every call is not practical in my case.

Regards,
-Tony



----- Original Message ----
From: Tony Anecito <adanecito_at_yahoo.com>
To: users_at_jersey.dev.java.net
Sent: Tue, January 18, 2011 8:41:01 PM
Subject: Does jersey create a new resource instance for every call?

Hi All,

I noticed that it appears that jersey servlet (1.5) in Tomcat 6.0.20 creates a
new instance of the resource object for every call. I say this becuase I noticed

my constructor of my resource object gets called for every get/post/put from my
jersey client. Is that correct? If so it seems to reduce scalability.
Is there a pool of resources objects I can configure for?

Thanks,
-Tony