[cgiapp] CGIApp + FastCGI
George Hartzell
hartzell at alerce.com
Mon Jun 15 16:50:13 EDT 2009
Jeff MacDonald writes:
> Hi,
>
> I'm cross posting this to CGIApp and FastCGI mailing lists, please
> don't hit me :)
>
> I've taken over the development of a Perl/CGI::App in house project.
>
> It has never lived its live in any sort of environment like FastCGI or
> mod_perl and now perl startup times are starting to eat away at
> performance. [Actually they are destroying preformance]
>
> I've tried running this application using both FastCGIServer and by
> using the AddHandler directive to allow dynamic restarting of the
> application.
>
> The Perl FastCGI module I am using with my application is
> CGI::Application::FastCGI
>
> If I ran it with only one -process the results were predictable. The
> application ran very quickly, screens came up as expected and it ran
> generally without errors.
>
> However, when I was gearing up to shift into production, and turned
> the processes up to 5 it because very unpredictable. It felt like for
> some reason, one session was grabbing variables from other sessions.
> Thus loading the wrong templates for some sessions, or using the
> results of one query object in the wrong session and all that. More or
> less made the system impossible to use.
>
> I'm not sure what guidelines I should be following to protect against
> memory sharing, or if that is even an appropriate description of my
> issue.
>
> If anyone can point me in a direction that would be helpful.
You almost certainly are carrying data over from one request to the
next, and with multiple processes running the one that services
request number N+1 might not be the same one that served request
number N, so you might not have the data that you expect.
The challenge of being neat and clean between requests exists for both
mod_perl and fastcgi. It's touched on briefly here:
http://cgi-app.org/index.cgi?SitePerformance
and if you search the site (from the search box on the front page) for
fastcgi and/or mod_perl, you'll see a couple of more references.
>From the Notes secition of the CGI::Application::FastCGI man page:
Note that cgiapp_init() will be called only once under lifecycle of
FastCGI. setup() will also only be called once. (you should not be
doing magical things in 'setup'.) So if you want to do something
for every REQUESTS, you should write the logic in cgiapp_prerun().
g.
More information about the cgiapp
mailing list