You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shabu Khan <hi...@gmail.com> on 2008/05/16 19:22:29 UTC

CGI/HTML

Folks,
For some reason, the cgi perl script that I run via IE/Firefox does not
render the output immediately,  but waits until it has big chunk of the
HTML.   Does this have anything to do with the tomcat/cgi setup or header or
something, or perl mod defaults?

It works fine on a Apache/CGI/Perl setup but not on Tomcat/CGI/Perl?

Thoughts?

Thanks,



-- 
Shabu Khan | Mentis Systems Inc | W: (425) 649-1130 | C: (425) 301-1948 | F:
(425) 256-2819
http://www.linkedin.com/in/shabukhan

Re: CGI/HTML

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

Shabu,

Shabu Khan wrote:
| Earlier with Apache, I was able to see the output as it ran, just like
from
| the command line on the browser ...

Well, using Apache out in front of both your web application /and/ CGI
scripts certainly is an option, if the delay you are experiencing with
Tomcat+CGI is unacceptable.

- -chris

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

iEYEARECAAYFAkgt1ZoACgkQ9CaO5/Lv0PD80wCfSib3SUq9o2dTDWidl4kWvwre
oBAAoJ2rw0pR8KQNZ3K6TQHFnRkptvOn
=HisZ
-----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: CGI/HTML

Posted by Shabu Khan <hi...@gmail.com>.
Thanks Chris.
I don't see any 'buffer setting tweaks' in the code, from the command line
there is no delay it works just like a regular perl/shell script.

This is a code written by someone back in 2000, I ported it to Perl 5.8.5
from Perl 5.005 and to the new Kernel (Linux 2.6), the output shows-up on
the browser only after the code is executed completely (basically after the
script run is complete).

Earlier with Apache, I was able to see the output as it ran, just like from
the command line on the browser ...

On Fri, May 16, 2008 at 10:43 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Shabu,
>
> Shabu Khan wrote:
> | For some reason, the cgi perl script that I run via IE/Firefox does not
> | render the output immediately,  but waits until it has big chunk of the
> | HTML.   Does this have anything to do with the tomcat/cgi setup or
> header or
> | something, or perl mod defaults?
>
> This probably has to do with the size of the output buffer in either
> Perl or whatever mechanism is being used to shuttle information from
> your CGI script through Tomcat and any other layers you may have in
> between.
>
> I would check the CGI runner you are using to see if there is a buffer
> size tweaking setting.
>
> I didn't see anything like that in
> http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html so you might want
> to check the code.
>
> CGIServlet appears to have a small (2048 byte) buffer for output, which
> shouldn't be a problem. It looks like the loop that monitors the
> (external) CGI process at 500ms intervals to check up on the process
> while no output is being produced. While output is being produced, it
> should be constantly moving data from the CGI's stdout to the
> ServletOutputStream (which is unbuffered). The /input/ from the CGI is
> buffered up through the end of the headers, and then the writer is
> ignored and the input stream is unbuffered (not really sure how this
> works properly...). It's possible that you are hitting odd buffer
> boundaries where a buffer flush requires several of these half-second
> pauses before enough data is available.
>
> Have you timed your perl script independently to see if there actually
> is a delay in generating the content, rather than simply moving if from
> the CGI to through Tomcat?
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkgtx7EACgkQ9CaO5/Lv0PB4CACggNXDgd1RVziRT+L9KEFr60nC
> pVMAnim65WeLxS4QfhfKyeeD207ECWfm
> =Pnob
> -----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
>
>


-- 
Shabu Khan | Mentis Systems Inc | W: (425) 649-1130 | C: (425) 301-1948 | F:
(425) 256-2819
http://www.linkedin.com/in/shabukhan

Re: CGI/HTML

Posted by Shabu Khan <hi...@gmail.com>.
Thanks Bill.
Can this be tweaked to a lesser value then?

On Sat, May 17, 2008 at 6:21 PM, Bill Barker <wb...@wilshire.com> wrote:

>
> "Christopher Schultz" <ch...@christopherschultz.net> wrote in message
> news:482DC7B1.8070003@christopherschultz.net...
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Shabu,
> >
> > Shabu Khan wrote:
> > | For some reason, the cgi perl script that I run via IE/Firefox does not
> > | render the output immediately,  but waits until it has big chunk of the
> > | HTML.   Does this have anything to do with the tomcat/cgi setup or
> > header or
> > | something, or perl mod defaults?
> >
> > This probably has to do with the size of the output buffer in either
> > Perl or whatever mechanism is being used to shuttle information from
> > your CGI script through Tomcat and any other layers you may have in
> > between.
> >
> > I would check the CGI runner you are using to see if there is a buffer
> > size tweaking setting.
> >
> > I didn't see anything like that in
> > http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html so you might want
> > to check the code.
> >
> > CGIServlet appears to have a small (2048 byte) buffer for output, which
> > shouldn't be a problem. It looks like the loop that monitors the
> > (external) CGI process at 500ms intervals to check up on the process
> > while no output is being produced. While output is being produced, it
> > should be constantly moving data from the CGI's stdout to the
> > ServletOutputStream (which is unbuffered). The /input/ from the CGI is
>
> Not strictly true.  By default Tomcat has an 8Kb output buffer (in
> o.a.c.c.OutputBuffer ;) before actually sending the output to the Socket.
>
> > buffered up through the end of the headers, and then the writer is
> > ignored and the input stream is unbuffered (not really sure how this
> > works properly...). It's possible that you are hitting odd buffer
> > boundaries where a buffer flush requires several of these half-second
> > pauses before enough data is available.
> >
> > Have you timed your perl script independently to see if there actually
> > is a delay in generating the content, rather than simply moving if from
> > the CGI to through Tomcat?
> >
> > - -chris
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.9 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> >
> > iEYEARECAAYFAkgtx7EACgkQ9CaO5/Lv0PB4CACggNXDgd1RVziRT+L9KEFr60nC
> > pVMAnim65WeLxS4QfhfKyeeD207ECWfm
> > =Pnob
> > -----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
>
>


-- 
Shabu Khan | Mentis Systems Inc | W: (425) 649-1130 | C: (425) 301-1948 | F:
(425) 256-2819
http://www.linkedin.com/in/shabukhan

Re: CGI/HTML

Posted by Bill Barker <wb...@wilshire.com>.
"Christopher Schultz" <ch...@christopherschultz.net> wrote in message 
news:482DC7B1.8070003@christopherschultz.net...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Shabu,
>
> Shabu Khan wrote:
> | For some reason, the cgi perl script that I run via IE/Firefox does not
> | render the output immediately,  but waits until it has big chunk of the
> | HTML.   Does this have anything to do with the tomcat/cgi setup or
> header or
> | something, or perl mod defaults?
>
> This probably has to do with the size of the output buffer in either
> Perl or whatever mechanism is being used to shuttle information from
> your CGI script through Tomcat and any other layers you may have in 
> between.
>
> I would check the CGI runner you are using to see if there is a buffer
> size tweaking setting.
>
> I didn't see anything like that in
> http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html so you might want
> to check the code.
>
> CGIServlet appears to have a small (2048 byte) buffer for output, which
> shouldn't be a problem. It looks like the loop that monitors the
> (external) CGI process at 500ms intervals to check up on the process
> while no output is being produced. While output is being produced, it
> should be constantly moving data from the CGI's stdout to the
> ServletOutputStream (which is unbuffered). The /input/ from the CGI is

Not strictly true.  By default Tomcat has an 8Kb output buffer (in 
o.a.c.c.OutputBuffer ;) before actually sending the output to the Socket.

> buffered up through the end of the headers, and then the writer is
> ignored and the input stream is unbuffered (not really sure how this
> works properly...). It's possible that you are hitting odd buffer
> boundaries where a buffer flush requires several of these half-second
> pauses before enough data is available.
>
> Have you timed your perl script independently to see if there actually
> is a delay in generating the content, rather than simply moving if from
> the CGI to through Tomcat?
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkgtx7EACgkQ9CaO5/Lv0PB4CACggNXDgd1RVziRT+L9KEFr60nC
> pVMAnim65WeLxS4QfhfKyeeD207ECWfm
> =Pnob
> -----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: CGI/HTML

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

Shabu,

Shabu Khan wrote:
| For some reason, the cgi perl script that I run via IE/Firefox does not
| render the output immediately,  but waits until it has big chunk of the
| HTML.   Does this have anything to do with the tomcat/cgi setup or
header or
| something, or perl mod defaults?

This probably has to do with the size of the output buffer in either
Perl or whatever mechanism is being used to shuttle information from
your CGI script through Tomcat and any other layers you may have in between.

I would check the CGI runner you are using to see if there is a buffer
size tweaking setting.

I didn't see anything like that in
http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html so you might want
to check the code.

CGIServlet appears to have a small (2048 byte) buffer for output, which
shouldn't be a problem. It looks like the loop that monitors the
(external) CGI process at 500ms intervals to check up on the process
while no output is being produced. While output is being produced, it
should be constantly moving data from the CGI's stdout to the
ServletOutputStream (which is unbuffered). The /input/ from the CGI is
buffered up through the end of the headers, and then the writer is
ignored and the input stream is unbuffered (not really sure how this
works properly...). It's possible that you are hitting odd buffer
boundaries where a buffer flush requires several of these half-second
pauses before enough data is available.

Have you timed your perl script independently to see if there actually
is a delay in generating the content, rather than simply moving if from
the CGI to through Tomcat?

- -chris

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

iEYEARECAAYFAkgtx7EACgkQ9CaO5/Lv0PB4CACggNXDgd1RVziRT+L9KEFr60nC
pVMAnim65WeLxS4QfhfKyeeD207ECWfm
=Pnob
-----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