Apache processing cgi requests

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Apache processing cgi requests

Graeme Geldenhuys-2
For all those Apache and CGI gurus...

[This might be off-topic]

I have written a CGI app for my client that decrypts a Macromedia
Flash files (*.swf) to a set path and name ("/flash/movie.swf"), I
then generate a html file to view that file, and the client (web
browser) gets served.  The average *.swf file size is around 100Kb.

This CGI app might serve around 30-40 people simultaneously at peak
times.  In our testing, I would have thought that even though all
30-40 people are viewing different *.swf files, some might get served
the wrong file (due to the decrypted file always having a constant
name).  Our testing proved otherwise, we always received the correct
swf movie?

This brings me to my question.  How does Apache handle CGI requests?
Does it queue them and serve them  (including all resources: images,
swf files, etc) one at a time or process them all at the same time?

Note: For the release version, I changed the decrypted file to use a
GUID Session ID in the output name - just to be sure there is no
potential problems!

I am using Apache 2 with the MPM worker on a Linux box. The worker MPM
provides a threaded implementation for Apache2.

Regards,
  Graeme.


--
There's no place like 127.0.0.1
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Apache processing cgi requests

Michael Van Canneyt


On Wed, 26 Jul 2006, Graeme Geldenhuys wrote:

> For all those Apache and CGI gurus...
>
> [This might be off-topic]
>
> I have written a CGI app for my client that decrypts a Macromedia
> Flash files (*.swf) to a set path and name ("/flash/movie.swf"), I
> then generate a html file to view that file, and the client (web
> browser) gets served.  The average *.swf file size is around 100Kb.
>
> This CGI app might serve around 30-40 people simultaneously at peak
> times.  In our testing, I would have thought that even though all
> 30-40 people are viewing different *.swf files, some might get served
> the wrong file (due to the decrypted file always having a constant
> name).  Our testing proved otherwise, we always received the correct
> swf movie?
>
> This brings me to my question.  How does Apache handle CGI requests?
> Does it queue them and serve them  (including all resources: images,
> swf files, etc) one at a time or process them all at the same time?

They are processed at the same time. Apache works threaded, so multiple
versions of your CGI script could be running at the same time. You could
simply have used the GetTempFileName function from SysUtils to avoid
concurrency problems. Although using a GUID as a filename is just as good.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Apache processing cgi requests

Graeme Geldenhuys-2
On 7/26/06, Michael Van Canneyt <[hidden email]> wrote:
> They are processed at the same time. Apache works threaded, so multiple
> versions of your CGI script could be running at the same time. You could
> simply have used the GetTempFileName function from SysUtils to avoid
> concurrency problems. Although using a GUID as a filename is just as good.
>
> Michael.

So I guess it was pure luck that we didn't pickup any issues.  Thanks
for your quick response!

Regards,
  Graeme.


--
There's no place like 127.0.0.1
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal