httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sindhi Sindhi <sindhi....@gmail.com>
Subject Re: Apache pool management
Date Sat, 25 May 2013 08:05:15 GMT
You have answered all my questions and thanks a lot. Had two questions
more, appreciate your response.

1.
As of now, my httpd.conf file has the below lines-
# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

This means Apache does not read the httpd-mpm.conf file during startup. And
so it uses the default settings for "Max number of requests it can support"
and "Max number of threads it creates per child process"

Where can I find what default values Apache uses for the following -
- Upto how many concurrent requests will Apache support by default
- Max number of threads that one child process creates

For ex. if I want Apache to handle upto 400 concurrent requests at a time,
how will I know that this 400 is within the default settings that Apache
uses.

2.
My understanding is, once a request is completely processed, Apache frees
the pool of only this request and does not free any other request's pool.
And other request pools will be freed only when those requests are
completely processed. Kindly confirm my understanding to be correct.

I'm sorry if I'm asking something very fundamental, but I'm new to Apache
modules and Apache internals.

Thanks a ton!

On Sat, May 25, 2013 at 2:53 AM, Sorin Manolache <sorinm@gmail.com> wrote:

> On 2013-05-24 20:00, Sindhi Sindhi wrote:
>
>> Hi,
>>
>> I did an initial study to find out more information about Apache APR
>> pools.
>> Some links say pools are not thread safe, some say they are really useful,
>> so I'm a bit confused. Kindly advice.
>>
>> In certain links like the below, I read that pools are not thread safe.
>> Does this mean that when multiple requests are being handled by multiple
>> threads in Apache, data of one request could get overwritten/read/freed by
>> other requests?
>> http://mail-archives.apache.**org/mod_mbox/apr-dev/200502.**mbox/%**
>> 3C1f1d9820502241330123f955f@**mail.gmail.com%3E<http://mail-archives.apache.org/mod_mbox/apr-dev/200502.mbox/%3C1f1d9820502241330123f955f@mail.gmail.com%3E>
>>
>> A lot of other links like the below state that pools are a big advantage
>> in
>> Apache memory management.
>> http://structure.usc.edu/svn/**svn.developer.pools.html<http://structure.usc.edu/svn/svn.developer.pools.html>
>> http://dev.ariel-networks.com/**apr/apr-tutorial/html/apr-**
>> tutorial-3.html<http://dev.ariel-networks.com/apr/apr-tutorial/html/apr-tutorial-3.html>
>>
>> To summarize my requirement, I have written a C++ output filter module
>> that
>> filters HTML. And this module will be invoked by multiple requests that
>> hit
>> the server at the same time. My concern about using the APR pool is, if I
>> use the request pools, when one request (say request1) is in the middle of
>> processing, I do not want this request's data to be corrupted by other
>> requests'(say request2) - like, request2 overwriting on request1's data or
>> request2 freeing the memory allocated by request1.
>>
>> If you can answer the below questions that will help me make a better use
>> or APR pool, kindly reply.
>> 1. Can I use the request pools in such a way that, each request owns its
>> pool and cannot be read/written/freed by other requests/pool manager? What
>> settings in httpd-mpm.conf will make this possible?
>>
>
> Yes. I think it works out-of-the-box and does not need any special
> settings.
>
>
>  2. I get the "ap_filter_t *f" as an input to my filter module, and I'm
>> using the f->r->pool to allocate memory that is used by my filter module.
>> So is this pool unique for every request?
>>
>
> Yes. Each request owns its pool. Concurrent requests are handled in
> different threads, but the threads cannot access another thread's request
> structure, and implicitly cannot access another request's pool.
>
> I don't know if pools are thread-safe. However, as stated here
> http://apr.apache.org/docs/**apr/1.4/group__apr__pools.html<http://apr.apache.org/docs/apr/1.4/group__apr__pools.html>
> **, sub-pool creation is thread-safe. The pool owned by a request is a
> sub-pool of the connection pool. So apache creates, in a thread-safe
> manner, the request pool for your exclusive use. So it should be safe.
> Personally I've never had concurrency issues with request pools.
>
> Sorin
>
>
>
>> Would appreciate a response.
>>
>> Thanks.
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message