You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Igor Tatarinov <ta...@prairie.NoDak.edu> on 1998/02/04 17:39:06 UTC
A question on ka requests
Hi all,
I have a simple question. Why is it that Apache treats requests coming
from a keep-alive connection differently from requests from a regular
connection?
I mean, why doesn't it clean its pools after each ka request like it does
after each regular request.
Now we have two parameters MaxKeepAliveRequests and MaxRequestsPerChild.
As I understand, if MaxKeepAliveRequests is set to 0 (and
MaxRequestsPerChild is not very small) it is very easy to make Apache
consume a lot of memory (create a bunch of ka connections and request
a small file so that you don't need a lot of bandwidth).
As for my problem, I want to have some cleanup done after each request
(whether it's ka or not doesn't matter). Any way I can do it?
or am I missing something?
igor
Re: A question on ka requests
Posted by Brian Behlendorf <br...@organic.com>.
At 01:59 PM 2/4/98 -0800, Dean Gaudet wrote:
>There's no excuse for a modern language to have any ambiguities, we
>learned how to avoid that in the 60s.
You were around in the 60s? You're older than you look.
(just pointing out that second-order or higher languages and ambiguities
are inextricably linked :)
Brian
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
specialization is for insects brian@organic.com
Re: A question on ka requests
Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
>
> If the compiler has to think hard to resolve it then so does the
> programmer. How can you code without knowing what the compiler is going
> to do with your code? You and the compiler have to agree.
>
> Two examples off the top of my head. < and > for templates. This has to
> be one of the worst things they could have done. < and > *were not nested
> elements prior to this stupidity*! They could have used (: and :) and it
> would have worked just fine without ambiguities.
Yep. And >> causing hiccups really winds me up. But it is completely
obvious what the problem is once you've hit it once or twice.
> And here's a snippet related to the completely lame x(y) intializers:
>
> char i,j;
>
> struct S {
> S();
> S(int);
> S(int,int);
> };
>
> S foo( int(i), int(j) ); // S foo( int i, int j ) or S foo = S(i,j);?
> // ^^^^^^^^^^^^^^^^^^^^^
This has the horrible look of one of those compromises you have to
accept to make templates work properly.
> I would be so much happier if languages (this includes C!) didn't allow
> people to declare and initialize a variable in the same statement. I
> can almost live with it in C (despite the two Apache bugs I've found/fixed
> due to it). But in C++ they had to make it worse by letting you
> initialize with function-like parameters! That leads to crap like the
> above.
Yeah. No doubt Mr. Stroustrup can justify it.
> What more do you want me to say? I'm at least willing to +0 using
> this abomination.
Most civil :-)
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache
Re: A question on ka requests
Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
> S ack()
> {
> return( S() ); // missing expr after cast or return S()?
> // ^^^^^^^^^^
> }
>
> The standard disambiguates those constructs explicitly, the ^^^^^ is
> the correct disambiguation. This example courtesy of Anthony Scian,
> the C++ guru at WATCOM.
Give me a break! If clashing with an error is counted as ambiguity,
well, I surrender!
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
If the compiler has to think hard to resolve it then so does the
programmer. How can you code without knowing what the compiler is going
to do with your code? You and the compiler have to agree.
Two examples off the top of my head. < and > for templates. This has to
be one of the worst things they could have done. < and > *were not nested
elements prior to this stupidity*! They could have used (: and :) and it
would have worked just fine without ambiguities.
And here's a snippet related to the completely lame x(y) intializers:
char i,j;
struct S {
S();
S(int);
S(int,int);
};
S foo( int(i), int(j) ); // S foo( int i, int j ) or S foo = S(i,j);?
// ^^^^^^^^^^^^^^^^^^^^^
S ack()
{
return( S() ); // missing expr after cast or return S()?
// ^^^^^^^^^^
}
The standard disambiguates those constructs explicitly, the ^^^^^ is
the correct disambiguation. This example courtesy of Anthony Scian,
the C++ guru at WATCOM.
I would be so much happier if languages (this includes C!) didn't allow
people to declare and initialize a variable in the same statement. I
can almost live with it in C (despite the two Apache bugs I've found/fixed
due to it). But in C++ they had to make it worse by letting you
initialize with function-like parameters! That leads to crap like the
above.
What more do you want me to say? I'm at least willing to +0 using
this abomination.
Dean
On Thu, 5 Feb 1998, Ben Laurie wrote:
> Dean Gaudet wrote:
> > See C98 or whatever it's called, they probably added this.
> >
> > Long live C. At least you know what the hell the compiler is going to
> > generate, rather than having to guess which bugs and which interpretation
> > of the various ambiguities your particular C++ compiler happens to have.
> > There's no excuse for a modern language to have any ambiguities, we
> > learned how to avoid that in the 60s. C++ is far worse than C in this
> > regard.
>
> Phooey. There are syntactic ambiguities in C++ that the compiler has to
> think hard to resolve, but I'm not aware of any ambiguities that a
> programmer has to care about.
>
> Cheers,
>
> Ben.
>
> --
> Ben Laurie |Phone: +44 (181) 735 0686|Apache Group member
> Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
> and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
> A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
> London, England. |"Apache: TDG" http://www.ora.com/catalog/apache
>
Re: A question on ka requests
Posted by Ben Laurie <be...@algroup.co.uk>.
Dean Gaudet wrote:
> See C98 or whatever it's called, they probably added this.
>
> Long live C. At least you know what the hell the compiler is going to
> generate, rather than having to guess which bugs and which interpretation
> of the various ambiguities your particular C++ compiler happens to have.
> There's no excuse for a modern language to have any ambiguities, we
> learned how to avoid that in the 60s. C++ is far worse than C in this
> regard.
Phooey. There are syntactic ambiguities in C++ that the compiler has to
think hard to resolve, but I'm not aware of any ambiguities that a
programmer has to care about.
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache
Re: A question on ka requests
Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
I just run the fixed CVS and found that there are no memory leaks anymore.
Great!
igor
Re: A question on ka requests
Posted by Marc Slemko <ma...@worldgate.com>.
On Wed, 4 Feb 1998, Dean Gaudet wrote:
> Probably for the same reason that we don't set MaxRequestsPerClient to
> something reasonable. Like 0.
>
> I'm hoping someone will come up with the reason... 'cause this is
> something I do to my server configs, especially when I'm looking at
> performance.
Show me that more than 0.01% of your hits will make use of it (the only
thing I can think of is some robots, and slowing them down can be a good
thing anyway...) and I'll buy it.
I just don't see the need for it and it introduces possible issues with
broken runaway clients.
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> Dean, have you checked if there is no memory leak after your fix?
No.
> If so, I suggest removing MaxRequestPerKA as a parameter or at least
> making it zero (infinity) or very large by default since this noticeably
> improves performance on simple benchmarks like zb (and possibly others
> that use ka)
>
> So it will not hurt anybody but may help Apache to get higher performance
> ratings from consumer magazines who (I guess) never change
> any config params before running their benchmarks.
Probably for the same reason that we don't set MaxRequestsPerClient to
something reasonable. Like 0.
I'm hoping someone will come up with the reason... 'cause this is
something I do to my server configs, especially when I'm looking at
performance.
Dean
Re: A question on ka requests
Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
Dean, have you checked if there is no memory leak after your fix?
If so, I suggest removing MaxRequestPerKA as a parameter or at least
making it zero (infinity) or very large by default since this noticeably
improves performance on simple benchmarks like zb (and possibly others
that use ka)
So it will not hurt anybody but may help Apache to get higher performance
ratings from consumer magazines who (I guess) never change
any config params before running their benchmarks.
igor
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> Dean Gaudet wrote:
> >
> > On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> >
> > > But the real reason for all this is that C doesn't allow you to declare
> > > a variable exactly at the moment when you need it.
> >
> > I don't understand how this means that it's suddenly fine to go and
> > INITIALIZE a variable far before the exact moment that you need it.
>
> I am not sure I understood this comment right but instead of
> int function() {
> config *c=getconfig();
> ... (100 lines of code that doesn't use c) ...
> 1 line that uses c
> }
>
> you can write (in C++, not in C)
> int function() {
> ...(100 lines ...)
> config *c=getconfig()
> 1 line that uses c
> }
And in C you can write:
int function()
{
config *c;
...(100 lines ...)
c = getconfig()
1 line that uses c
}
> So instead of moving initialization to declaration, C++ allows moving
> declaration to initialization.
I'm fully aware of that.
Dean
Re: A question on ka requests
Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
Dean Gaudet wrote:
>
> On Wed, 4 Feb 1998, Igor Tatarinov wrote:
>
> > But the real reason for all this is that C doesn't allow you to declare
> > a variable exactly at the moment when you need it.
>
> I don't understand how this means that it's suddenly fine to go and
> INITIALIZE a variable far before the exact moment that you need it.
I am not sure I understood this comment right but instead of
int function() {
config *c=getconfig();
... (100 lines of code that doesn't use c) ...
1 line that uses c
}
you can write (in C++, not in C)
int function() {
...(100 lines ...)
config *c=getconfig()
1 line that uses c
}
I understand that in C you can just use braces to achive the second case
but that wouldn't work if you need c later.
So instead of moving initialization to declaration, C++ allows moving
declaration to initialization.
igor
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> But the real reason for all this is that C doesn't allow you to declare
> a variable exactly at the moment when you need it.
I don't understand how this means that it's suddenly fine to go and
INITIALIZE a variable far before the exact moment that you need it.
> It really sucks for example, to have a loop variable declared somewhere
> 200 lines above your loop.
>
> So the conclusion is:
>
> LONG LIVE C++!
>
> (classes are cool but even small things like this one make it better than
> C, in my opinion)
See C98 or whatever it's called, they probably added this.
Long live C. At least you know what the hell the compiler is going to
generate, rather than having to guess which bugs and which interpretation
of the various ambiguities your particular C++ compiler happens to have.
There's no excuse for a modern language to have any ambiguities, we
learned how to avoid that in the 60s. C++ is far worse than C in this
regard.
Dean
>
> igor
>
> Dean Gaudet wrote:
> >
> > Have I mentioned lately that I really hate auto initializations?
> >
> > type variable = initializer;
> >
> > In my opinion, using initializers tends to:
> >
> > - create long lines that need to be broken
> >
> > - create inefficient code, because sometimes the value isn't needed at
> > at until after an initial test that leaves the function immediately.
> > And if the initializer does something like get_module_config (like
> > a lot of them do) then it's a total waste of time.
> >
> > - create silly bugs caused by values being initialized far from their
> > use
> >
> > Dean
Re: A question on ka requests
Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
But the real reason for all this is that C doesn't allow you to declare
a variable exactly at the moment when you need it.
It really sucks for example, to have a loop variable declared somewhere
200 lines above your loop.
So the conclusion is:
LONG LIVE C++!
(classes are cool but even small things like this one make it better than
C, in my opinion)
igor
Dean Gaudet wrote:
>
> Have I mentioned lately that I really hate auto initializations?
>
> type variable = initializer;
>
> In my opinion, using initializers tends to:
>
> - create long lines that need to be broken
>
> - create inefficient code, because sometimes the value isn't needed at
> at until after an initial test that leaves the function immediately.
> And if the initializer does something like get_module_config (like
> a lot of them do) then it's a total waste of time.
>
> - create silly bugs caused by values being initialized far from their
> use
>
> Dean
Dean Gaudet wrote:
>
> On Wed, 4 Feb 1998, Igor Tatarinov wrote:
>
> > Yeah, right I wasn't careful in my comments. Each ka requests costs
> > only sizeof(request_rec)=340 (on my Solaris).
>
> Thanks for the hint. I fixed the leak.
>
> Have I mentioned lately that I really hate auto initializations?
>
> type variable = initializer;
>
> In my opinion, using initializers tends to:
>
> - create long lines that need to be broken
>
> - create inefficient code, because sometimes the value isn't needed at
> at until after an initial test that leaves the function immediately.
> And if the initializer does something like get_module_config (like
> a lot of them do) then it's a total waste of time.
>
> - create silly bugs caused by values being initialized far from their
> use
>
> Dean
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Igor Tatarinov, graduate student, Computer Science Dept, NDSU
e-mail: tatarino@prairie.nodak.edu or itat@acm.org
http://www.cs.ndsu.nodak.edu/~tatarino
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> Yeah, right I wasn't careful in my comments. Each ka requests costs
> only sizeof(request_rec)=340 (on my Solaris).
Thanks for the hint. I fixed the leak.
Have I mentioned lately that I really hate auto initializations?
type variable = initializer;
In my opinion, using initializers tends to:
- create long lines that need to be broken
- create inefficient code, because sometimes the value isn't needed at
at until after an initial test that leaves the function immediately.
And if the initializer does something like get_module_config (like
a lot of them do) then it's a total waste of time.
- create silly bugs caused by values being initialized far from their
use
Dean
Re: A question on ka requests
Posted by Igor Tatarinov <ta...@prairie.NoDak.edu>.
Yeah, right I wasn't careful in my comments. Each ka requests costs
only sizeof(request_rec)=340 (on my Solaris). Which is probably no
big deal unless you are running a benchmark like I was doing and
noticing that your httpd processes are getting larger and larger.
Say, 100,000 ka requests increase the size of httpd by 34M.
So if there is a Web site with MaxPerKA=0 and MaxPerChild=100,000
a dozen concurrent ka connections would bring it down. And you don't
need a whole lot of bandwidth to do that, just make one request for a
small file per ka timeout.
Still, why are those 340 bytes lost and why both MaxPerKA and
MaxPerChild?
igor
Dean Gaudet wrote:
>
> >From child_main:
>
> while ((r = read_request(current_conn)) != NULL) {
>
> /* read_request_line has already done a
> * signal (SIGUSR1, SIG_IGN);
> */
>
> (void) update_child_status(my_child_num, SERVER_BUSY_WRITE, r);
>
> process_request(r);
>
> #if defined(STATUS)
> increment_counts(my_child_num, r);
> #endif
>
> if (!current_conn->keepalive || current_conn->aborted)
> break;
>
> destroy_pool(r->pool);
> (void) update_child_status(my_child_num, SERVER_BUSY_KEEPALIVE,
> (request_rec *) NULL);
>
> i.e. what are you referring to? It cleans the request pool. It doesn't
> clean the connection pool until the connection is done.
>
> If you can show a stock server consuming lots of memory on a keep alive
> connection I wouldn't mind seeing it.
>
> Dean
>
> On Wed, 4 Feb 1998, Igor Tatarinov wrote:
>
> > Hi all,
> >
> > I have a simple question. Why is it that Apache treats requests coming
> > from a keep-alive connection differently from requests from a regular
> > connection?
> >
> > I mean, why doesn't it clean its pools after each ka request like it does
> > after each regular request.
> >
> > Now we have two parameters MaxKeepAliveRequests and MaxRequestsPerChild.
> > As I understand, if MaxKeepAliveRequests is set to 0 (and
> > MaxRequestsPerChild is not very small) it is very easy to make Apache
> > consume a lot of memory (create a bunch of ka connections and request
> > a small file so that you don't need a lot of bandwidth).
> >
> > As for my problem, I want to have some cleanup done after each request
> > (whether it's ka or not doesn't matter). Any way I can do it?
> >
> > or am I missing something?
> > igor
> >
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Igor Tatarinov, graduate student, Computer Science Dept, NDSU
e-mail: tatarino@prairie.nodak.edu or itat@acm.org
http://www.cs.ndsu.nodak.edu/~tatarino
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: A question on ka requests
Posted by Dean Gaudet <dg...@arctic.org>.
>From child_main:
while ((r = read_request(current_conn)) != NULL) {
/* read_request_line has already done a
* signal (SIGUSR1, SIG_IGN);
*/
(void) update_child_status(my_child_num, SERVER_BUSY_WRITE, r);
process_request(r);
#if defined(STATUS)
increment_counts(my_child_num, r);
#endif
if (!current_conn->keepalive || current_conn->aborted)
break;
destroy_pool(r->pool);
(void) update_child_status(my_child_num, SERVER_BUSY_KEEPALIVE,
(request_rec *) NULL);
i.e. what are you referring to? It cleans the request pool. It doesn't
clean the connection pool until the connection is done.
If you can show a stock server consuming lots of memory on a keep alive
connection I wouldn't mind seeing it.
Dean
On Wed, 4 Feb 1998, Igor Tatarinov wrote:
> Hi all,
>
> I have a simple question. Why is it that Apache treats requests coming
> from a keep-alive connection differently from requests from a regular
> connection?
>
> I mean, why doesn't it clean its pools after each ka request like it does
> after each regular request.
>
> Now we have two parameters MaxKeepAliveRequests and MaxRequestsPerChild.
> As I understand, if MaxKeepAliveRequests is set to 0 (and
> MaxRequestsPerChild is not very small) it is very easy to make Apache
> consume a lot of memory (create a bunch of ka connections and request
> a small file so that you don't need a lot of bandwidth).
>
> As for my problem, I want to have some cleanup done after each request
> (whether it's ka or not doesn't matter). Any way I can do it?
>
> or am I missing something?
> igor
>