users@jersey.java.net

[Jersey] Re: It's very hard to increase the number of worker threads in Jersey-Grizzly module.

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Wed, 30 May 2012 12:15:24 +0200

Hi,

---------------------------------------------------
// create HTTP server
HttpServer server = GrizzlyServerFactory.createHttpServer(....);

// create the thread pool configuration
ThreadPoolConfig config = ThreadPoolConfig.newConfig().
                                          setPoolName("mypool").
                                          setCorePoolSize(10).
                                          setMaxPoolSize(300);

// assign the thread pool
NetworkListener listener = httpServer.getListeners().iterator().next();
listener.getTransport().setWorkerThreadPoolConfig(config);
---------------------------------------------------

* depending on Grizzly version ThreadPoolConfig instance might be
created via ThreadPoolConfig.defaultConfig()....

WBR,
Alexey.

On 05/29/2012 08:14 PM, matrix3456_at_gmail.com wrote:
> I use jersey 1.12 right now and i experienced a server non-response
> case recently after the server was started for a while. Then i dig into
> this, and find out that some of my API take too long to connect to
> another service server due to the broken network.
>
> And the same time, the server runs very slow, seems like cannot accept
> any new connection. Actually all the worker threads are busying
> waiting. The default number of the worker thread is
> Runtime.getRuntime().availableProcessors() * 2 = 4 on my box. So i want
> to increase this number.
>
> The only way to accomplish this i found so far is to override
> createHttpServer method in GrizzlyServerFactory, the override the
> default value before starting the server. But GrizzlyServerFactory has
> a final class modifier, so i copy all the code into a new class in
> order to do this.
>
> Is there any config options beside this?