Re: AS Libraries for stay-open CGIs
Re: AS Libraries for stay-open CGIs
- Subject: Re: AS Libraries for stay-open CGIs
- From: Jed Verity <email@hidden>
- Date: Fri, 16 Feb 2001 12:38:02 -0800
Just my $0.02 on the subject:
I decided to utilize the stay-open script server as the primary source of
CGI libraries because the "load script" function was consistently timing out
when called within a CGI script on operating systems prior to 9.x (versions
of AS prior to 1.4.3). I don't know if anyone else has had the same
experience...
Jed
On 2/16/01 11:05 AM, email@hidden uttered these immortal words:
>
Richard,
>
>
May I ask what these scripts do? If it's a shopping cart system, we must
>
trade notes.
>
>
I have implemented exactly what you are after. Here are my insights.
>
>
1) You do not want "a single stay-open library of utility handlers accessible
>
to all the CGIs." This will choke under load because it would not be
>
multithreaded, and my understanding is that it would use a FILO (same as
>
LIFO, but the acronym order highlights the problem) system for responding to
>
requests, leading to slowness or worse, timeouts.
>
>
2) You do not want to hard code the same routines into multiple scripts...
>
WAIT! You already figured that out : )
>
>
3) You do not want to be concerned about the memory footprint because RAM is
>
cheap and any machine which is not upgradeable to enough RAM to run your
>
scripts is probably too slow to run scripts big enough to require library
>
handlers (did you follow that logic?). Memory is much less of an issue than
>
CPU cycles.
>
>
4) You do want to load the script object library into a property retained
>
between runs as I demonstrated in a recent post (email me if you missed that).
>
>
5) You may or may not want the CGIs to actually stay open (you need to save
>
them as such, but you may want a built in timer to quit them after 5-15
>
minutes; I have a script for that too). I and others (Cris especially) have
>
noted problems with idle handlers in stay open scripts. This may be fixed in
>
9.1 (Cris says it is, I have not tested). Of course, you could simply lose
>
any idle handlers ....
>
>
6) Optimizing Applescript for speed is a valuable learning experience. I now
>
have a vanilla handler which is 4 times faster than an osax.
>
>
Glad to see serious CGI discussion happening.
>
>
Jeff Baumann
>
email@hidden
>
www.linkedresources.com
>
>
10 days, 4 hours, 29 minutes.....
>
>
>
In a message dated 2/16/01 12:13:40 PM, Richard Hartman wrote:
>
>
> I am thinking about tidying up several (five or six) stay-open
>
> Applescript CGI's I wrote for a Webstar server. Replicated in each
>
> CGI of the collection are identical handlers which are currently
>
> hard-coded within each CGI, which produces a set of stand-alone CGIs,
>
> each requiring no other library or script resources.
>
>
>
> This is obviously a situation in which a single stay-open library of
>
> utility handlers accessible to all the CGIs is very attractive from
>
> the point of view of tidy coding and maintenance.
>
>
>
> However, particularly in a server environment in which CPU cycles are
>
> precious, there is a tradeoff between:
>
>
>
> 1. The inefficient memory usage in my current scheme (in which each
>
> CGI, for example, contains its own copy of utility routines such as a
>
> "getparent(thePath)" handler) and
>
>
>
> 2. CPU usage required by CGI-library interface requirements of the
>
> tidier Library-based scheme.
>
>
>
> I have a vague suspicion that the library overhead is pretty
>
> negligible (perhaps, utterly negligible?), but I was hoping someone
>
> might be able to shed some light and offer some observations that go
>
> beyond that suspicion. Anyone thought this through before or done any
>
> testing to quantify?
>
>
>
> Since memory is pretty cheap and we are only talking about perhaps a
>
> 10 megabyte stay-open CGI memory footprint, is a library solution
>
> worth implementing in this circumstance?
>
>
>
> Any pros or cons to a library solution that I should be aware of? (I
>
> have never before implemented one, although I have reviewed Bill
>
> Cheeseman's excellent discussion at
>
> http://www.AppleScriptSourcebook.com/tips/scriptserver.html. Thank
>
> you, Bill!).
>
>
>
> Will a library implementation likely survive a transfer to an OSX
>
environment?
>
>
>
>
>
> Grateful for any guidance or insight here,
>
>
>
> Richard Hartman
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
~)~)~)~)~)~)~)~)~)~)~)~)~)
Jed Verity