Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Output buffering on IIS7

Reply
Thread Tools

Output buffering on IIS7

 
 
David Hiskiyahu
Guest
Posts: n/a
 
      07-08-2012
I moved a rather simple program from an IIS 5.x that was running under ActivePerl on an old Win2000 32 bits machine to an IIS7 server running under ActivePerl 12.x on a new Windows 2008 64 bits server.

In the old place, the program would visit a number of databases in a loop, grab some data from each database, print it and go on to the next one.

$|=1 is obviously set in the beginning to let the data flush out.

While all was fine on the old server, the program just does not want to flush in the new place .. it only shows the first byte of output when it finishes running the entire code.

Looked at IIS7 settings, disabled Output Caching.
Disabled compression.

... still the same.
The output is delayed and starts to show only when the entire script finishes running.

Any clues, please?

 
Reply With Quote
 
 
 
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-09-2012
Ben, thanks for your prompt reply.
5.12.x is right .. my typo.

And yes, I did exactly that when I saw that I am fighting a buffering issue- made a mini-script that does a bit of sleeping and printing in a loop, more is not needed - and posted here when I saw that the problem is exactly that and not some of my script logic.

The old server prints a row every second.
The new server waits 5 seconds then prints all:

#!/usr/bin/perl
use CGI qw/:standard/;

select((select(STDOUT), $| = 1)[0]);

print header, start_html(-title => 'test.pl page', -bgcolor => '#ffffff');

print "<P>TEST BEGIN\n";
print "<br>Going to sleep 5 seconds\n";

sleep 1; print "<br>Slept 1 second\n";
sleep 1; print "<br>Slept 1 more second, 2 seconds so far\n";
sleep 1; print "<br>Slept 1 more second, 3 seconds so far\n";
sleep 1; print "<br>Slept 1 more second, 4 seconds so far\n";
sleep 1; print "<br>Slept 1 more second, 5 seconds so far\n";

print "<p>TEST END<p><hr>\n";

print end_html();
 
Reply With Quote
 
 
 
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-09-2012
And it is CGI.
 
Reply With Quote
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-09-2012
The script sleeps and prints as expected when running from a black DOS window in command mode .. so it is surely not Perl that delays the print.

Must be something in the IIS7 Web Server settings.
 
Reply With Quote
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-10-2012
Same exactly is happening with a similar PHP script, which probably means
that my thread should be kicked out of here ..:
<?php
Print "<br>Hello, World! \n";
flush();
$sleep = 2;
flush();
echo date('h:i:s') . " - going to sleep $sleep seconds now!\n";
flush();
sleep($sleep);
Print "<br>Hello again! \n";
flush();
sleep($sleep);
echo date('h:i:s') . " - going to sleep $sleep more seconds now!\n";
flush();
Print "<br>OK, slept enough.\n";
flush();

$myFile = "hello.php";
$fh = fopen($myFile, 'r');
$source = fread($fh, filesize($myFile));
$source = htmlspecialchars($source);

print "<p><hr>Here is the code of this program:<pre>\n";
echo $source;
flush();
?>

 
Reply With Quote
 
l v
Guest
Posts: n/a
 
      07-11-2012
On 7/9/2012 4:30 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Ben, thanks for your prompt reply.
> 5.12.x is right .. my typo.
>
> And yes, I did exactly that when I saw that I am fighting a buffering issue - made a mini-script that does a bit of sleeping and printing in a loop, more is not needed - and posted here when I saw that the problem is exactly that and not some of my script logic.
>
> The old server prints a row every second.
> The new server waits 5 seconds then prints all:
>
> #!/usr/bin/perl
> use CGI qw/:standard/;
>
> select((select(STDOUT), $| = 1)[0]);
>
> print header, start_html(-title => 'test.pl page', -bgcolor => '#ffffff');
>
> print "<P>TEST BEGIN\n";
> print "<br>Going to sleep 5 seconds\n";
>
> sleep 1; print "<br>Slept 1 second\n";
> sleep 1; print "<br>Slept 1 more second, 2 seconds so far\n";
> sleep 1; print "<br>Slept 1 more second, 3 seconds so far\n";
> sleep 1; print "<br>Slept 1 more second, 4 seconds so far\n";
> sleep 1; print "<br>Slept 1 more second, 5 seconds so far\n";
>
> print "<p>TEST END<p><hr>\n";
>
> print end_html();


Install Fiddler2 on your PC and enable it under IE's Tool menu. This
will allow you to trace the http traffic. If I recall correctly, IIS7
recognizes the browser type and behaves differently. IIS5 does not
perform this browser check.

I do not remember if there is a solution - I was investigating a
different problem when my company was upgrading from IE6 to IE7.

--
Len

 
Reply With Quote
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-11-2012
Len, thanks for the tip .. Fiddler is great!

As for this specific issue I am investigating, Fiddler2 confirms that there is no buffering inside the browser.

The ServerGotRequest and ServerBeginResponse timestamps prove that the buffering occurs on the server side.

So .. back to square 1, IIS7 is buffering output of my scripts, be them PHP or Perl, in same way .. regardless the explicit output flushing that is coded in the scripts, and I do not see how to stop that buffering.
 
Reply With Quote
 
brillisoft@gmail.com
Guest
Posts: n/a
 
      07-12-2012
Yes Ben, that's a popular and rather justified opinion about IIS.
Yet, one has to work with some corporate restrictions and live together with other developers on same team, plus inertia of things that worked for long time before - thus IIS.

Meanwhile, I found and fixed the problem.
Things changed from IIS 5.x to IIS 7.x, and now there is a web.config file collocated with the scripts there .. popped up there by some magic.

One needs to find that web.config file inside the folder where the script sits, edit it, and at the end of the tag containing the handler for *.pl or *.cgi, add a tag for responseBufferLimit="0", to achieve something like this:

<add name="Perl CGI for .cgi" path="*.cgi" verb="*" modules="CgiModule" scriptProcessor="C:\Perl64\bin\perl.exe &quot;%s&quot; %s" resourceType="Unspecified" requireAccess="Script" preCondition="bitness64" responseBufferLimit="0"/>

<add name="Perl CGI for .pl" path="*.pl" verb="*" modules="CgiModule" scriptProcessor="C:\Perl64\bin\perl.exe &quot;%s&quot; %s" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0"/>


PHP has a different solution, which I still did not find.

That's how toy Web Servers work.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
output buffering JD Python 5 11-11-2005 09:41 PM
Buffering the output of multiple controls =?Utf-8?B?U2NvdHRPbmVz?= ASP .Net 2 10-28-2004 02:09 PM
Preventing URLConnection from buffering entire output stream Mark Riordan Java 6 10-15-2004 06:00 PM
Output Buffering Shahid Juma ASP General 1 10-05-2004 02:03 PM
Output buffering problems during recursion Tim Mohler Perl 1 09-16-2003 12:35 AM



Advertisments