Re: AS as CGI
Re: AS as CGI
- Subject: Re: AS as CGI
- From: christian vick <email@hidden>
- Date: Wed, 19 Jun 2002 12:39:03 +0200
>
Thanks for pointing me! I have exactly what I need for now. I didn't realize
>
that the info for that was so basic, so I apologize for 'wasting' your time
>
on it.
>
>
Here's one question though that may not be as obvious:
>
>
If I do as the examples suggest, I will save my script as a stay open app
>
w/no startup screen. How does AS handle the situation where it is in the
>
middle of processing a request and another request comes in? Do both requests
>
get handled correctly and completely, or do I need to structure things a
>
special way in order to accomplish this.
Unfortunately AS CGI's are processing request in LIFO (last in first out).
This can produce two problems.
First, if you get a huge amount of request, it can happen that none of them
ever finishes. AS CGI's are very fast, but let's assume you involve an app
which needs 5 seconds to fulfill a request and you get _continuously_ more
than 1 request per 5 seconds, then you have a problem.
The first request in in progress, the second comes in. The first is halted
and the second is executed. A third request comes in, halting request 2,
executing request 3....and so on. The user which has send request 1 becomes
impatient and hits the submit button again, producing request 4.... A
request chain which is getting larger and larger..
I don't know how many request AS can buffer, but i guess at some point you
probably get a stack overflow or something other bad.
I've never seen this problem in practice but on high traffic it might become
reality. To be clear, halted request are not dropped, they are only halted
until the newer request has finished and they continue fine if they get time
to do so.
The other thing you have to think about are global variables:
Assumed a request (which works with a global) is in progress and a second
comes in (which modifies the global), then the value of the global is not
restored when the first request continues it's execution. This will produce
surprising results...
Local variables are fine. Every halted request stores and holds the right
values for later execution. But global values retain always the last set
value, no matter which request has set that value. So, later request
override the global values of halted request.
This would be no problem if you never get a second request while the first
is in the works, but even on a site with only 10 hits a day i would not use
globals in handlers which are related to request processing, it's just not
save.
On OS 9, using Webstar, you can save an AS CGI as ".cgi" or as ".acgi".
".acgi" means it executes asynchrony with the webserver, so the server can
continue with other stuff (i.e. serving web pages) while the CGI processes a
request.
".cgi" means the webserver is halted as long the CGI processes a request.
This way you can avoid the LIFO problem since no one can send a second
request to the server until the CGI has finished the previous request.
Depending on the situation, using ".cgi" may work. But if you get a fair
amount of CGI request the entire site might become sluggish.
On OS X i haven't looked at the LIFO thing yet. I'm sure it's the same. An
interesting question is if webstar is still able to do the synchron (".cgi")
processing, since every connection is a seperate thread there.
Greetings
cris
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.