Re: gethostbyaddr() bottleneck?
"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
news:g9hama$dd1 $1@registered.m otzarella.org.. .
LOL in your face!
Ries
"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
news:g9hama$dd1 $1@registered.m otzarella.org.. .
Joe Butler wrote:
>
(Top posting fixed)
>
I will respond when you learn not to top post - as you were so
nicely asked.
>"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
>news:g9gobe$6b 4$3@registered. motzarella.org. ..
I don't think the assumptions are flawed.
I just did a test:
print "blah blah..."
print "</body></html>";
sleep(5);
print "something else";
Now, when I monitor the network packets, my page completes as
expected
and renders in a timely fashion. 5 seconds later, I get
"something
else" and that is appended to the end of the rendered page and the
network packets comfirm that it is 5 seconds after the first
packet
for the page was delivered. The browser did still show, "page
loading" in the status bar, though.
Without the sleep, it seems that "something else" can get stuck
into
the same final page network packet. So, I'm guessing that, for
efficiency, if Apache has some buffered data due to be sent out,
and
more unbuffered output is generated before that has been sent,
that it
will be appended to the data that has not yet been passed on to
the
network transmission.
So, it seems that it is worthwhile doing a lookup after the final
page
flush, as there is nothing to loose. Particularly if you are not
outputing more data to the user, but simply doing some extra work,
such as logging (for 50 users a day).
This was a linux Apache and the browser was Firefox 1.5.
>news:g9gobe$6b 4$3@registered. motzarella.org. ..
>>Joe Butler wrote:
>>>"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
>>>news:g9f5m0$ d4s$1@registere d.motzarella.or g...
>>>>RJ_32 wrote:
>>>>>Jerry Stuckle wrote:
>>>>>>RJ_32 wrote:
>>>>>>>Jerry Stuckle wrote:
>>>>>>>>RJ_32 wrote:
>>>>>>>>>When there is no rDNS record on an IP address, then it
>>>>>>>>>migh t take a
>>>>>>>>>whil e for
>>>>>>>>>the reverse lookup to timeout. I'm thinking of how on a
>>>>>>>>>tracer t you can
>>>>>>>>>observ e the delay.
>>>>>>>>>>
>>>>>>>>>If so, then calling gethostbyaddr() can delay the serving
>>>>>>>>>of the web
>>>>>>>>>page ,
>>>>>>>>>righ t? Because gethostbyaddr() is not forked into a
>>>>>>>>>separa te process.
>>>>>>>>>So I
>>>>>>>>>suppos e I'd need to call gethostbyaddr() as the very last
>>>>>>>>>task for a
>>>>>>>>>script .
>>>>>>>>>Does that sound right? Or is there another way around the
>>>>>>>>>dela y?
>>>>>>>>>>
>>>>>>>>Why are you even trying to call gethostbyaddr() ? What do
>>>>>>>>you need it
>>>>>>>>for in your page?
>>>>>>>just for a log to get an idea of where the visitors are
>>>>>>>coming from.
>>>>>>>>
>>>>>>>I'd alternatively thought of maybe running a separate batch
>>>>>>>so to
>>>>>>>speak when I
>>>>>>>wanted to inspect the log.
>>>>>>>>
>>>>>>>>And even if it's the last thing on your page, it will still
>>>>>>>>delay
>>>>>>>>deliver y of the page content.
>>>>>>>Then would flush() solve that?
>>>>>>>>
>>>>>>>>
>>>>>>No, it won't. But then this is the wrong approach. That's
>>>>>>what server
>>>>>>logs are for.
>>>>>>>
>>>>>I'm expecting only 50 invited visitors or so. Making my own log
>>>>>is more
>>>>>convenie nt to get a quick look at who showed up, what UA they
>>>>>have etc.
>>>>>>
>>>>>Why would flush() not work? What's the purpose of it then? It
>>>>>does work that
>>>>>way in Tomcat or Resin servlet containers, eg
>>>>>>
>>>>Flush will output current data in the PHP buffers. But you still
>>>>have the web server's buffers, and, since the request is not
>>>>complete, the browser may or may not show the information. This
>>>>is not Tomcat or Resin. And BTW - those don't guarantee all of
>>>>the output will be displayed by the browser immediately.
>>>>Additionall y, the browser will still wait for the request to be
>>>>completed .
>>>>>
>>>>Web servers already have logs to track all of that, and there
>>>>are lots of tools around to give you the information you want.
>>>>>
>>>so, you are saying the assumptions of code like the following are
>>>flawed?
>>>>
>>>blah blah blah...
>>>>
>>> print '</body></html>';
>>>>
>>> ob_end_flush();
>>>>
>>> // do this after the html so it does not delay
>>> // the page loading and can be used next time.
>>> // we are only seeing if it returns the name of a machine
>>> // on the network rather than the ip address, so that
>>> // for whitehall, it's easier to identify the machine that may
>>> // be locking the diary.
>>> if(!isset($_SES SION['strRemoteName'])){
>>> // only do this once, since it won't change during a session.
>>> $_SESSION['strRemoteName']= GetRemoteAddrNa me();
>>> }
>>>>
>>><end of file>
>>>>
>>That is correct. The assumptions are flawed.
>>>
>>And please don't top post.
>>>
>>>
>>>"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
>>>news:g9f5m0$ d4s$1@registere d.motzarella.or g...
>>>>RJ_32 wrote:
>>>>>Jerry Stuckle wrote:
>>>>>>RJ_32 wrote:
>>>>>>>Jerry Stuckle wrote:
>>>>>>>>RJ_32 wrote:
>>>>>>>>>When there is no rDNS record on an IP address, then it
>>>>>>>>>migh t take a
>>>>>>>>>whil e for
>>>>>>>>>the reverse lookup to timeout. I'm thinking of how on a
>>>>>>>>>tracer t you can
>>>>>>>>>observ e the delay.
>>>>>>>>>>
>>>>>>>>>If so, then calling gethostbyaddr() can delay the serving
>>>>>>>>>of the web
>>>>>>>>>page ,
>>>>>>>>>righ t? Because gethostbyaddr() is not forked into a
>>>>>>>>>separa te process.
>>>>>>>>>So I
>>>>>>>>>suppos e I'd need to call gethostbyaddr() as the very last
>>>>>>>>>task for a
>>>>>>>>>script .
>>>>>>>>>Does that sound right? Or is there another way around the
>>>>>>>>>dela y?
>>>>>>>>>>
>>>>>>>>Why are you even trying to call gethostbyaddr() ? What do
>>>>>>>>you need it
>>>>>>>>for in your page?
>>>>>>>just for a log to get an idea of where the visitors are
>>>>>>>coming from.
>>>>>>>>
>>>>>>>I'd alternatively thought of maybe running a separate batch
>>>>>>>so to
>>>>>>>speak when I
>>>>>>>wanted to inspect the log.
>>>>>>>>
>>>>>>>>And even if it's the last thing on your page, it will still
>>>>>>>>delay
>>>>>>>>deliver y of the page content.
>>>>>>>Then would flush() solve that?
>>>>>>>>
>>>>>>>>
>>>>>>No, it won't. But then this is the wrong approach. That's
>>>>>>what server
>>>>>>logs are for.
>>>>>>>
>>>>>I'm expecting only 50 invited visitors or so. Making my own log
>>>>>is more
>>>>>convenie nt to get a quick look at who showed up, what UA they
>>>>>have etc.
>>>>>>
>>>>>Why would flush() not work? What's the purpose of it then? It
>>>>>does work that
>>>>>way in Tomcat or Resin servlet containers, eg
>>>>>>
>>>>Flush will output current data in the PHP buffers. But you still
>>>>have the web server's buffers, and, since the request is not
>>>>complete, the browser may or may not show the information. This
>>>>is not Tomcat or Resin. And BTW - those don't guarantee all of
>>>>the output will be displayed by the browser immediately.
>>>>Additionall y, the browser will still wait for the request to be
>>>>completed .
>>>>>
>>>>Web servers already have logs to track all of that, and there
>>>>are lots of tools around to give you the information you want.
>>>>>
>>>so, you are saying the assumptions of code like the following are
>>>flawed?
>>>>
>>>blah blah blah...
>>>>
>>> print '</body></html>';
>>>>
>>> ob_end_flush();
>>>>
>>> // do this after the html so it does not delay
>>> // the page loading and can be used next time.
>>> // we are only seeing if it returns the name of a machine
>>> // on the network rather than the ip address, so that
>>> // for whitehall, it's easier to identify the machine that may
>>> // be locking the diary.
>>> if(!isset($_SES SION['strRemoteName'])){
>>> // only do this once, since it won't change during a session.
>>> $_SESSION['strRemoteName']= GetRemoteAddrNa me();
>>> }
>>>>
>>><end of file>
>>>>
>>That is correct. The assumptions are flawed.
>>>
>>And please don't top post.
>>>
>>>
I just did a test:
print "blah blah..."
print "</body></html>";
sleep(5);
print "something else";
Now, when I monitor the network packets, my page completes as
expected
and renders in a timely fashion. 5 seconds later, I get
"something
else" and that is appended to the end of the rendered page and the
network packets comfirm that it is 5 seconds after the first
packet
for the page was delivered. The browser did still show, "page
loading" in the status bar, though.
Without the sleep, it seems that "something else" can get stuck
into
the same final page network packet. So, I'm guessing that, for
efficiency, if Apache has some buffered data due to be sent out,
and
more unbuffered output is generated before that has been sent,
that it
will be appended to the data that has not yet been passed on to
the
network transmission.
So, it seems that it is worthwhile doing a lookup after the final
page
flush, as there is nothing to loose. Particularly if you are not
outputing more data to the user, but simply doing some extra work,
such as logging (for 50 users a day).
This was a linux Apache and the browser was Firefox 1.5.
(Top posting fixed)
>
I will respond when you learn not to top post - as you were so
nicely asked.
LOL in your face!
Ries
Comment