Re: Forking high loaded servlet

2003-07-07 Thread Rodrigo Ruiz
Depending on the kind of request you are trying to accelerate, you could
also do some caching in the response.
Depending on what the servlet is intended to do, the strategies to apply can
vary a lot.
A description of the servlet execution would allow people to help you better
:)

Regards,
Rodrigo Ruiz

- Original Message -
From: Peter Lin [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Friday, July 04, 2003 5:31 PM
Subject: Re: Forking high loaded servlet



 I haven't followed this thread too closely, but what kind of concurrent
requests you looking at?  i ask this because the number of concurrent
threads in most cases is the result of hardware limitations.

 if you want to double the concurrent requests, get more cpu and multiple
gigabit ethernet cards.  trying to do it with servlet tricks (aside from
server.xml configuration) won't do much in the long run.

 peter


 Sergio Juan [EMAIL PROTECTED] wrote:

 - Original Message -
 From: Diego Castillo
 To:
 Sent: Friday, July 04, 2003 3:05 PM
 Subject: Forking high loaded servlet


  Hi all,
 
  I have a servlet that receives a heavy load. I would like to process
  multiple requests in parallel in order to increase throughput.
 
  Tomcat creates one single instance of the servlet. This is right
  according to servlet specification paragraph 3.2, but it does not suit
  my needs.
 
  I have tried extending SingleThreadModel and Tomcat does create multiple
  instances, but I get the exact same throughput.

 Tomcat automatically creates one thread per request. If your servlet does
 not have synchronization issues, it will be the same creating an object
per
 thread that using the same object (in fact a little heavier in the first
 case, because of the overhead of creating objects).
 
  I have also tried launching a new thread for handling HttpServletRequest
   HttpServletResponse, but as soon as the servlet exits service(), the
  response output stream gets closed by Tomcat.
 
 Same here.. you are launching a Thread inside of an already independent
 Thread.

  Is there any spec compliant strategy to increase the number of requests
  per second that a servlet can handle?
 
 In configuration you can set the processors number, but I think it is not
 the issue. If the problem is that you got a bottleneck in your host (CPU
or
 disk at nearly 100%) you should consider load balancing between multiple
 servers in different machines or using common programming performance
tricks
 (but I think you have already done that).

 Regards.

  Thanks in advance,
 
 
  Diego
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 Do you Yahoo!?
 SBC Yahoo! DSL - Now only $29.95 per month!


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE : Forking high loaded servlet

2003-07-07 Thread Diego Castillo
Hi Rodrigo,

My objective is developing an HTTP proxy that receives a request,
applies some business logic on it (analysis + modifications), and
forwards the result to another host. When the final host responds to the
modified request, the response is forwarded to the original client:

  ++ Request 1 +---+ Request 2 +--+
  | Client | --- | Proxy | --- | Host |
  ++  Reply 1  +---+  Reply 2  +--+

The proxy itself does not spend a long time analyzing and forwarding the
request, but the final host may do. The proxy needs to continue
forwarding requests while waiting for the final host to respond.

I am evaluating the feasibility of the proxy as a servlet that uses
Commons HttpClient for forwarding the requests. If performance tests are
not satisfactory, I will consider developing a CGI or even an Apache
module.

Hope this helps understand my requirement for a multithreaded servlet.

Regards,


Diego

-Message d'origine-
De : Rodrigo Ruiz [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 7 juillet 2003 11:53
À : Tomcat Users List
Objet : Re: Forking high loaded servlet

Depending on the kind of request you are trying to accelerate, you could
also do some caching in the response.
Depending on what the servlet is intended to do, the strategies to apply
can
vary a lot.
A description of the servlet execution would allow people to help you
better
:)

Regards,
Rodrigo Ruiz

- Original Message -
From: Peter Lin [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Friday, July 04, 2003 5:31 PM
Subject: Re: Forking high loaded servlet



 I haven't followed this thread too closely, but what kind of
concurrent
requests you looking at?  i ask this because the number of concurrent
threads in most cases is the result of hardware limitations.

 if you want to double the concurrent requests, get more cpu and
multiple
gigabit ethernet cards.  trying to do it with servlet tricks (aside from
server.xml configuration) won't do much in the long run.

 peter


 Sergio Juan [EMAIL PROTECTED] wrote:

 - Original Message -
 From: Diego Castillo
 To:
 Sent: Friday, July 04, 2003 3:05 PM
 Subject: Forking high loaded servlet


  Hi all,
 
  I have a servlet that receives a heavy load. I would like to process
  multiple requests in parallel in order to increase throughput.
 
  Tomcat creates one single instance of the servlet. This is right
  according to servlet specification paragraph 3.2, but it does not
suit
  my needs.
 
  I have tried extending SingleThreadModel and Tomcat does create
multiple
  instances, but I get the exact same throughput.

 Tomcat automatically creates one thread per request. If your servlet
does
 not have synchronization issues, it will be the same creating an
object
per
 thread that using the same object (in fact a little heavier in the
first
 case, because of the overhead of creating objects).
 
  I have also tried launching a new thread for handling
HttpServletRequest
   HttpServletResponse, but as soon as the servlet exits service(),
the
  response output stream gets closed by Tomcat.
 
 Same here.. you are launching a Thread inside of an already
independent
 Thread.

  Is there any spec compliant strategy to increase the number of
requests
  per second that a servlet can handle?
 
 In configuration you can set the processors number, but I think it is
not
 the issue. If the problem is that you got a bottleneck in your host
(CPU
or
 disk at nearly 100%) you should consider load balancing between
multiple
 servers in different machines or using common programming performance
tricks
 (but I think you have already done that).

 Regards.

  Thanks in advance,
 
 
  Diego
 
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 Do you Yahoo!?
 SBC Yahoo! DSL - Now only $29.95 per month!


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Forking high loaded servlet

2003-07-04 Thread Diego Castillo
Hi all,

I have a servlet that receives a heavy load. I would like to process
multiple requests in parallel in order to increase throughput.

Tomcat creates one single instance of the servlet. This is right
according to servlet specification paragraph 3.2, but it does not suit
my needs.

I have tried extending SingleThreadModel and Tomcat does create multiple
instances, but I get the exact same throughput.

I have also tried launching a new thread for handling HttpServletRequest
 HttpServletResponse, but as soon as the servlet exits service(), the
response output stream gets closed by Tomcat.

Is there any spec compliant strategy to increase the number of requests
per second that a servlet can handle?

Thanks in advance,


Diego


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Forking high loaded servlet

2003-07-04 Thread Sergio Juan

- Original Message - 
From: Diego Castillo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 04, 2003 3:05 PM
Subject: Forking high loaded servlet


 Hi all,

 I have a servlet that receives a heavy load. I would like to process
 multiple requests in parallel in order to increase throughput.

 Tomcat creates one single instance of the servlet. This is right
 according to servlet specification paragraph 3.2, but it does not suit
 my needs.

 I have tried extending SingleThreadModel and Tomcat does create multiple
 instances, but I get the exact same throughput.

Tomcat automatically creates one thread per request. If your servlet does
not have synchronization issues, it will be the same creating an object per
thread that using the same object (in fact a little heavier in the first
case, because of the overhead of creating objects).

 I have also tried launching a new thread for handling HttpServletRequest
  HttpServletResponse, but as soon as the servlet exits service(), the
 response output stream gets closed by Tomcat.

Same here.. you are launching a Thread inside of an already independent
Thread.

 Is there any spec compliant strategy to increase the number of requests
 per second that a servlet can handle?

In configuration you can set the processors number, but I think it is not
the issue. If the problem is that you got a bottleneck in your host (CPU or
disk at nearly 100%) you should consider load balancing between multiple
servers in different machines or using common programming performance tricks
(but I think you have already done that).

Regards.

 Thanks in advance,


 Diego


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Forking high loaded servlet

2003-07-04 Thread Antonio Fiol Bonnín
I completely agree with Sergio, but do not forget about code 
optimization, query optimization, database index optimization, ...

It is difficult to say where your bottleneck is but, in most cases I 
have seen, correcting an SQL query which is not doing the exact right 
thing or adding a few indexes on the right columns on your database may 
easily achive a 1:7 performance factor.

For example, a typical mistake I have seen concerning this:

// Issue a select query that will output about 1000 result rows
int rownum = 0;
while(result.next()  (rownum++  5)) {
   // read a row and do something
}
You could easily add a and rownum = 5 to your SQL and you would save:
- database processing time
- network transmit time between DB and appserver
- Java resultset building time
That is only a fairly trivial example, of course, but I have seen it 
quite a few times. And I have even seen worse...

As this is fairly off-topic, if you need more help, do not hesitate to 
contact me off-list.

Yours,

Antonio Fiol

Sergio Juan wrote:

- Original Message - 
From: Diego Castillo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 04, 2003 3:05 PM
Subject: Forking high loaded servlet

 

Hi all,

I have a servlet that receives a heavy load. I would like to process
multiple requests in parallel in order to increase throughput.
Tomcat creates one single instance of the servlet. This is right
according to servlet specification paragraph 3.2, but it does not suit
my needs.
I have tried extending SingleThreadModel and Tomcat does create multiple
instances, but I get the exact same throughput.
   

Tomcat automatically creates one thread per request. If your servlet does
not have synchronization issues, it will be the same creating an object per
thread that using the same object (in fact a little heavier in the first
case, because of the overhead of creating objects).
 

I have also tried launching a new thread for handling HttpServletRequest
 HttpServletResponse, but as soon as the servlet exits service(), the
response output stream gets closed by Tomcat.
   

Same here.. you are launching a Thread inside of an already independent
Thread.
 

Is there any spec compliant strategy to increase the number of requests
per second that a servlet can handle?
   

In configuration you can set the processors number, but I think it is not
the issue. If the problem is that you got a bottleneck in your host (CPU or
disk at nearly 100%) you should consider load balancing between multiple
servers in different machines or using common programming performance tricks
(but I think you have already done that).
Regards.

 

Thanks in advance,

Diego

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




smime.p7s
Description: S/MIME Cryptographic Signature


Re: Forking high loaded servlet

2003-07-04 Thread Peter Lin
 
I haven't followed this thread too closely, but what kind of concurrent requests you 
looking at?  i ask this because the number of concurrent threads in most cases is the 
result of hardware limitations.
 
if you want to double the concurrent requests, get more cpu and multiple gigabit 
ethernet cards.  trying to do it with servlet tricks (aside from server.xml 
configuration) won't do much in the long run.
 
peter


Sergio Juan [EMAIL PROTECTED] wrote:

- Original Message - 
From: Diego Castillo 
To: 
Sent: Friday, July 04, 2003 3:05 PM
Subject: Forking high loaded servlet


 Hi all,

 I have a servlet that receives a heavy load. I would like to process
 multiple requests in parallel in order to increase throughput.

 Tomcat creates one single instance of the servlet. This is right
 according to servlet specification paragraph 3.2, but it does not suit
 my needs.

 I have tried extending SingleThreadModel and Tomcat does create multiple
 instances, but I get the exact same throughput.

Tomcat automatically creates one thread per request. If your servlet does
not have synchronization issues, it will be the same creating an object per
thread that using the same object (in fact a little heavier in the first
case, because of the overhead of creating objects).

 I have also tried launching a new thread for handling HttpServletRequest
  HttpServletResponse, but as soon as the servlet exits service(), the
 response output stream gets closed by Tomcat.

Same here.. you are launching a Thread inside of an already independent
Thread.

 Is there any spec compliant strategy to increase the number of requests
 per second that a servlet can handle?

In configuration you can set the processors number, but I think it is not
the issue. If the problem is that you got a bottleneck in your host (CPU or
disk at nearly 100%) you should consider load balancing between multiple
servers in different machines or using common programming performance tricks
(but I think you have already done that).

Regards.

 Thanks in advance,


 Diego


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!