You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2007/03/07 22:06:30 UTC

Is APR worth it (for me?)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

Apologies for the pretty vague question, but I was wondering if looking
at using APR is worth it for me. To answer that, you'll need to know a
bit about my setup.

I'm running Tomcat 5.5 on Linux, connected via mod_jk 1.2.21 to Apache
httpd 2.0.x.

I try to serve all static content using Apache, so sendFile isn't
exactly going to get me anywhere. I have Apache httpd handle SSL for me,
so increased speed through APR/OpenSSL isn't going to get me anywhere,
either.

However, the APR description page suggests that scalability is improved
through the use of socket-polling -- not something that I generally
think of as performance-enhancing.

Can someone comment on the applicability of APR in my case?

And before anyone asks about skipping Apache httpd altogether, I need it
to switch between multiple parallel Tomcats, so I can't dump it (nor do
I really want to).

Thanks in advance,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF7ylW9CaO5/Lv0PARAm3QAJwMPi8jJp6fwm3K3MXwo1K3PYpQ7gCggz4b
+naAvTqtBNaNk4U/fBPzlOg=
=TvzR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Bill Barker <wb...@wilshire.com>.
"Christopher Schultz" <ch...@christopherschultz.net> wrote in message 
news:45EF417F.6020108@christopherschultz.net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Chuck,
>
> Caldarale, Charles R wrote:
>>> From: Christopher Schultz [mailto:chris@christopherschultz.net]
>>> Subject: Is APR worth it (for me?)
>>>
>>> However, the APR description page suggests that scalability
>>> is improved through the use of socket-polling
>>
>> The scalability is improved due to not having to keep a thread around
>> for each persistent HTTP connection.
>
> I see.
>
>> The new NIO connector in Tomcat 6 also achieves this.
>
> ...without regard to the presence of APR, I would imagine.
>

There is a fairly old NIO/AJP Connector that ships with TC 5.5 & 6, but it 
sort of died due to lack of anybody caring it was there.

>> Do you have a simulated production environment where you can just try
>> the two connectors back-to-back?
>
> I do, but I don't have a load test scenario right now that I can use to
> get some good numbers. We currently serve very light load on a one-box
> wonder, so I would imagine that any performance improvement would not be
> observable in production today.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF70F/9CaO5/Lv0PARAn+nAJ9kLBN49mKT8x3rqXAt9Wq2ww+7yACgwEjj
> fKgknH/YsLK1flQVvVEVBOY=
> =al8l
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
>> Subject: Is APR worth it (for me?)
>>
>> However, the APR description page suggests that scalability 
>> is improved through the use of socket-polling
> 
> The scalability is improved due to not having to keep a thread around
> for each persistent HTTP connection.

I see.

> The new NIO connector in Tomcat 6 also achieves this.

...without regard to the presence of APR, I would imagine.

> Do you have a simulated production environment where you can just try
> the two connectors back-to-back?

I do, but I don't have a load test scenario right now that I can use to
get some good numbers. We currently serve very light load on a one-box
wonder, so I would imagine that any performance improvement would not be
observable in production today.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF70F/9CaO5/Lv0PARAn+nAJ9kLBN49mKT8x3rqXAt9Wq2ww+7yACgwEjj
fKgknH/YsLK1flQVvVEVBOY=
=al8l
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Is APR worth it (for me?)

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Is APR worth it (for me?)
> 
> Makes sense. So, instead of a Java thread waiting in every single ajp
> connection, you're using one native listener thread waiting on a
> select(), right? It's sad that you can't do this in Java :(

You can, but only with NIO, not with the older comm APIs.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Rainer Jung <ra...@kippdata.de>.
Peter Kennard wrote:
> Hmm I woudl have thought otherwise, since after reading the protocol it 
> seems specificly designed to support keeping connection alive.
> 
> That a sender would keep a "pool" of available connections and when a 
> hit comes in "get" one which is already connected, and push the request 
> out, and the destination looks up the servlet and dispatches to it 
> (until the request is complete), and when complete, releases the still 
> open connection so the sender and can recycles it back into its pool 
> without "disconnecting" ie: socket remains open.  and there is some 
> huristic for culling excess connections after heavy traffic may hve 
> opened more than configured.
> 
> Anyway that is what I would do ;^>

And that's what it does :)

> If by "multiplexing" you thought interleaving routed packets for 
> simultaneous "hits" on one pipe I didn't mean that.

Yes, that's how I interpreted your question concerning "multiplexing".
> 
> PK

Regards,

Rainer

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Peter Kennard <pe...@livingwork.com>.
Hmm I woudl have thought otherwise, since after 
reading the protocol it seems specificly designed 
to support keeping connection alive.

That a sender would keep a "pool" of available 
connections and when a hit comes in "get" one 
which is already connected, and push the request 
out, and the destination looks up the servlet and 
dispatches to it (until the request is complete), 
and when complete, releases the still open 
connection so the sender and can recycles it back 
into its pool without "disconnecting" ie: socket 
remains open.  and there is some huristic for 
culling excess connections after heavy traffic 
may hve opened more than configured.

Anyway that is what I would do ;^>

If by "multiplexing" you thought interleaving 
routed packets for simultaneous "hits" on one pipe I didn't mean that.

PK


At 02:41 3/8/2007, you wrote:
>Peter Kennard wrote:
>>Doesn't AJP "multiplex" traffic, that is queued 
>>up requests are "serialized" through one 
>>connection that remains connected and it 
>>switches between servlets on the receiving end? 
>>and recycles the execution thread?
>
>No multiplexing on connections.
>
>Regards,
>
>Rainer
>
>>At 19:19 3/7/2007, you wrote:
>>>-----BEGIN PGP SIGNED MESSAGE-----
>>>Hash: SHA1
>>>
>>>Rémy,
>>>
>>>Rémy Maucherat wrote:
>>> > The scalability improvement is twofold for AJP:
>>> > - when running many Apache frontend servers (each with a sizeable
>>> > number of workers), Tomcat would need a huge amount of AJP worker
>>> > threads with the java.io connector
>>>
>>>Makes sense. So, instead of a Java thread waiting in every single ajp
>>>connection, you're using one native listener thread waiting on a
>>>select(), right? It's sad that you can't do this in Java :(
>>>
>>> > - threads will only be used for actually executing requests, thus
>>> > making concurrency in business logic a bit more predictable (if you
>>> > have 2000 threads, it's ok most of the time, as long as no lock gets
>>> > contested by too many threads, in which case it's far better if you
>>> > had only 200 threads)
>>>
>>>Definitely. Unless I'm mistaken, Java threads on Linux are pthreads,
>>>which are relatively heavy. Reducing them is certainly going to reduce
>>>memory, thread counts (wrt system limits), and thread dump lengths.
>>>
>>> > It also saves memory (no surprise). Socket polling will only be used
>>> > for keepalive: during the processing of a request, the connector uses
>>> > regular blocking IO.
>>>
>>>Cool. So, it /does/ sound like something worth looking into. APR
>>>installation looks like a snap, too, so it shouldn't be painful at all.
>>>
>>>Thanks for the explanation, Rémy.
>>>
>>>- -chris
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Rainer Jung <ra...@kippdata.de>.
Peter Kennard wrote:
> Doesn't AJP "multiplex" traffic, that is queued up requests are 
> "serialized" through one connection that remains connected and it 
> switches between servlets on the receiving end? and recycles the 
> execution thread?

No multiplexing on connections.

Regards,

Rainer

> 
> At 19:19 3/7/2007, you wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Rémy,
>>
>> Rémy Maucherat wrote:
>> > The scalability improvement is twofold for AJP:
>> > - when running many Apache frontend servers (each with a sizeable
>> > number of workers), Tomcat would need a huge amount of AJP worker
>> > threads with the java.io connector
>>
>> Makes sense. So, instead of a Java thread waiting in every single ajp
>> connection, you're using one native listener thread waiting on a
>> select(), right? It's sad that you can't do this in Java :(
>>
>> > - threads will only be used for actually executing requests, thus
>> > making concurrency in business logic a bit more predictable (if you
>> > have 2000 threads, it's ok most of the time, as long as no lock gets
>> > contested by too many threads, in which case it's far better if you
>> > had only 200 threads)
>>
>> Definitely. Unless I'm mistaken, Java threads on Linux are pthreads,
>> which are relatively heavy. Reducing them is certainly going to reduce
>> memory, thread counts (wrt system limits), and thread dump lengths.
>>
>> > It also saves memory (no surprise). Socket polling will only be used
>> > for keepalive: during the processing of a request, the connector uses
>> > regular blocking IO.
>>
>> Cool. So, it /does/ sound like something worth looking into. APR
>> installation looks like a snap, too, so it shouldn't be painful at all.
>>
>> Thanks for the explanation, Rémy.
>>
>> - -chris

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Peter Kennard <pe...@livingwork.com>.
Doesn't AJP "multiplex" traffic, that is queued 
up requests are "serialized" through one 
connection that remains connected and it switches 
between servlets on the receiving end? and recycles the execution thread?

At 19:19 3/7/2007, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Rémy,
>
>Rémy Maucherat wrote:
> > The scalability improvement is twofold for AJP:
> > - when running many Apache frontend servers (each with a sizeable
> > number of workers), Tomcat would need a huge amount of AJP worker
> > threads with the java.io connector
>
>Makes sense. So, instead of a Java thread waiting in every single ajp
>connection, you're using one native listener thread waiting on a
>select(), right? It's sad that you can't do this in Java :(
>
> > - threads will only be used for actually executing requests, thus
> > making concurrency in business logic a bit more predictable (if you
> > have 2000 threads, it's ok most of the time, as long as no lock gets
> > contested by too many threads, in which case it's far better if you
> > had only 200 threads)
>
>Definitely. Unless I'm mistaken, Java threads on Linux are pthreads,
>which are relatively heavy. Reducing them is certainly going to reduce
>memory, thread counts (wrt system limits), and thread dump lengths.
>
> > It also saves memory (no surprise). Socket polling will only be used
> > for keepalive: during the processing of a request, the connector uses
> > regular blocking IO.
>
>Cool. So, it /does/ sound like something worth looking into. APR
>installation looks like a snap, too, so it shouldn't be painful at all.
>
>Thanks for the explanation, Rémy.
>
>- -chris
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.7 (MingW32)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
>iD8DBQFF71aP9CaO5/Lv0PARAk7yAKCmhD9Xg5yH1yb5FNSrkeuP8uc0fQCeI9i8
>E2Yjiq1jJR9SNcAOMErVJjQ=
>=FEvG
>-----END PGP SIGNATURE-----
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rémy,

Rémy Maucherat wrote:
> The scalability improvement is twofold for AJP:
> - when running many Apache frontend servers (each with a sizeable
> number of workers), Tomcat would need a huge amount of AJP worker
> threads with the java.io connector

Makes sense. So, instead of a Java thread waiting in every single ajp
connection, you're using one native listener thread waiting on a
select(), right? It's sad that you can't do this in Java :(

> - threads will only be used for actually executing requests, thus
> making concurrency in business logic a bit more predictable (if you
> have 2000 threads, it's ok most of the time, as long as no lock gets
> contested by too many threads, in which case it's far better if you
> had only 200 threads)

Definitely. Unless I'm mistaken, Java threads on Linux are pthreads,
which are relatively heavy. Reducing them is certainly going to reduce
memory, thread counts (wrt system limits), and thread dump lengths.

> It also saves memory (no surprise). Socket polling will only be used
> for keepalive: during the processing of a request, the connector uses
> regular blocking IO.

Cool. So, it /does/ sound like something worth looking into. APR
installation looks like a snap, too, so it shouldn't be painful at all.

Thanks for the explanation, Rémy.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF71aP9CaO5/Lv0PARAk7yAKCmhD9Xg5yH1yb5FNSrkeuP8uc0fQCeI9i8
E2Yjiq1jJR9SNcAOMErVJjQ=
=FEvG
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is APR worth it (for me?)

Posted by Rémy Maucherat <re...@gmail.com>.
On 3/7/07, Caldarale, Charles R <Ch...@unisys.com> wrote:
> The scalability is improved due to not having to keep a thread around
> for each persistent HTTP connection.  (The new NIO connector in Tomcat 6
> also achieves this.)  Whether or not that aspect improves your
> performance due to less context switching, CPU cache loading/unloading,
> etc., will depend almost entirely on your workload.

He's talking about AJP here, and there's no AJP connector using the
NIO endpoint at the moment. The scalability improvement is twofold for
AJP:
- when running many Apache frontend servers (each with a sizeable
number of workers), Tomcat would need a huge amount of AJP worker
threads with the java.io connector
- threads will only be used for actually executing requests, thus
making concurrency in business logic a bit more predictable (if you
have 2000 threads, it's ok most of the time, as long as no lock gets
contested by too many threads, in which case it's far better if you
had only 200 threads)

It also saves memory (no surprise). Socket polling will only be used
for keepalive: during the processing of a request, the connector uses
regular blocking IO.

Rémy

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Is APR worth it (for me?)

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Is APR worth it (for me?)
> 
> However, the APR description page suggests that scalability 
> is improved through the use of socket-polling

The scalability is improved due to not having to keep a thread around
for each persistent HTTP connection.  (The new NIO connector in Tomcat 6
also achieves this.)  Whether or not that aspect improves your
performance due to less context switching, CPU cache loading/unloading,
etc., will depend almost entirely on your workload.

Do you have a simulated production environment where you can just try
the two connectors back-to-back?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org