dev@grizzly.java.net

some test on 1.9.16 def threadpool :)

From: <rama.rama_at_tiscali.it>
Date: Wed, 24 Jun 2009 11:28:11 +0200 (CEST)

yes, i know, everyone is tired by my consideration on threadpool :)



let's see this example

----------
public class Suspend {

    public
Suspend() {
        GrizzlyWebServer gws = new GrizzlyWebServer();


        gws.addGrizzlyAdapter(new GrizzlyAdapter() {
                 
public void service(final GrizzlyRequest grizzlyRequest, final
GrizzlyResponse grizzlyResponse) {
                         System.out.
println("I AM "+Thread.currentThread().getName()+" HELLO");

                         try {
                             
grizzlyResponse.getWriter().println("hi");
                         }
catch (Exception e) {

                         }
                 }

        },new String[]{"/"});
        gws.setMaxThreads(64);
        
gws.getSelectorThread().setDisplayConfiguration(true);

        try {

            gws.start();
        } catch (IOException e) {
            
e.printStackTrace();
        }
    }

    public static void main
(String args[]) {
        new Suspend();
    }
}
----------
On start up
i get
Thread Pool: StatsThreadPool[name=http, min-threads=5, max-
threads=64, max-queue-size=2147483647, is-shutdown=false, port=8080]


Cool :)

Then, i do some refresh on browser, and i get

-------------------------------------------------------------------------------------

I AM http8080-WorkerThread(2) HELLO
I AM http8080-WorkerThread(5) HELLO

I AM http8080-WorkerThread(2) HELLO
I AM http8080-WorkerThread(5) HELLO

I AM http8080-WorkerThread(2) HELLO
I AM http8080-WorkerThread(5) HELLO

I AM http8080-WorkerThread(2) HELLO

Perfect


Now, lest' try with
something of different...

-------------------------------------------------------------------------------------

sudo ab -n 100 -c 10 http://192.168.2.143:8080/

Server Software:

Server Hostname: 192.168.2.143
Server Port: 8080


Document Path: /
Document Length: 4 bytes

Concurrency
Level: 10
Time taken for tests: 0.032 seconds
Complete
requests: 100
Failed requests: 0
Write errors: 0

Total transferred: 7900 bytes
HTML transferred: 400 bytes

Requests per second: 3108.39 [#/sec] (mean)
Time per request:
3.217 [ms] (mean)
Time per request: 0.322 [ms] (mean, across all
concurrent requests)
Transfer rate: 239.81 [Kbytes/sec]
received

-------------------------------------------------------------------------------------


The request are issued perfecty.

The issue is that i expect to have
10 threads running (concurrency 10) maybe a couple more...
but gws
spawn 64 thread.
If i put gws.setMaxThreads(64); to 100 it will spawn
100 :)
This is quite strange, someone can give to me some
clarification?
At this point using the new threadpool doesn't have any
advantage rather than using fixedthreadpool (that was even a bit
faster)
since even under a relative low concurrency level, it's unable
to spawn a limited number of threads.


best regards
Rama (the lover of
threadpool)








Con Tutto Incluso chiami e navighi senza limiti a soli 14,95 euro al mese. Gratis la Sim Tiscali Mobile con 50 euro di traffico! L’offerta è valida solo se attivi entro il 25/06/09

http://abbonati.tiscali.it/promo/tuttoincluso/