473,378 Members | 1,119 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

FCGI app reloading on every request

I'm converting a web app from CGI to FCGI. The application works fine
under FCGI, but it's being reloaded for every request, which makes FCGI
kind of pointless. I wrote a little FCGI app which prints when the program is
loaded and when it gets a request. And indeed, the program gets reloaded for
each HTTP request. Something is probably misconfigured. But what?

I'm using Apache with "mod_fcgid", configured via Plesk. Plesk
sets up "/etc/httpd/conf.d/fcgid.conf" with:

# added by psa-mod-fcgid-configurator
<IfModule mod_fcgid.c>
IdleTimeout 3600
ProcessLifeTime 7200
MaxProcessCount 64
DefaultMaxClassProcessCount 8
IPCConnectTimeout 30
IPCCommTimeout 45
DefaultInitEnv RAILS_ENV production
</IfModule>

which seems reasonable enough, even though I'm not using
Rails or Ruby.

On the Python side, I'm using Python 2.5 on Linux, with Alan
Saddi's "fcgi.py" module.

Everything seems to work correctly, and there are no errors in the Apache
error log. But performance is terrible because the Python code
is reloaded for each request. I can only get about five transactions
a second through, on an dedicated server, with each transaction
doing a simple MySQL request. All the time is going into program loading;
the database is mostly idle.

John Nagle
Sep 4 '07 #1
7 2436
John Nagle schrieb:
I'm converting a web app from CGI to FCGI. The application works fine
under FCGI, but it's being reloaded for every request, which makes FCGI
kind of pointless. I wrote a little FCGI app which prints when the
program is loaded and when it gets a request. And indeed, the program
gets reloaded for
each HTTP request. Something is probably misconfigured. But what?
The most likely reason is that your FastCGI server voluntarily choses
to exit after one request. Can you share the mainloop of your
application?

Regards,
Martin
Sep 4 '07 #2
Martin v. Löwis wrote:
John Nagle schrieb:
> I'm converting a web app from CGI to FCGI. The application works fine
under FCGI, but it's being reloaded for every request, which makes FCGI
kind of pointless. I wrote a little FCGI app which prints when the
program is loaded and when it gets a request. And indeed, the program
gets reloaded for
each HTTP request. Something is probably misconfigured. But what?


The most likely reason is that your FastCGI server voluntarily choses
to exit after one request. Can you share the mainloop of your
application?

Regards,
Martin
It turns out that's not the problem.

What's actually happening is that FCGI isn't running at all.
My .fcgi file is being executed by Apache's CGI handler, and
"fcgi.py" recognizes this, then reads the parameters as if
a CGI program. So it works just like a CGI program: one
load per request. Not sure why Apache is doing that yet.
I'm looking at Apache configuration files now.

The main loop is in "fcgi.py", which calls the
user application as a function. The user app doesn't have the
option of exiting after one request, short of aborting without
returning a result.

John Nagle
Sep 4 '07 #3
John Nagle wrote:
>
What's actually happening is that FCGI isn't running at all.
My .fcgi file is being executed by Apache's CGI handler, and
"fcgi.py" recognizes this, then reads the parameters as if
a CGI program. So it works just like a CGI program: one
load per request. Not sure why Apache is doing that yet.
I'm looking at Apache configuration files now.
Are you running mod_fastcgi oder mod_fcgid?

Disclaimer: I don't claim to be an expert in that. My web2ldap source
distribution contains two examples configuration files for each of the
modules above for FastCGI over Unix Domain Socket( see directory
<web2ldap-dir>/etc/httpd/, comments of sample-mod_fcgid.conf
misleading). web2ldap can also be deployed as (multi-threaded)
FastCGI-server.

Ciao, Michael.
Sep 4 '07 #4
Michael Ströder wrote:
John Nagle wrote:
> What's actually happening is that FCGI isn't running at all.
My .fcgi file is being executed by Apache's CGI handler, and
"fcgi.py" recognizes this, then reads the parameters as if
a CGI program. So it works just like a CGI program: one
load per request. Not sure why Apache is doing that yet.
I'm looking at Apache configuration files now.


Are you running mod_fastcgi oder mod_fcgid?
I'm using mod_fcgid.

This is running on a dedicated server at APlus.net,
running Red Hat Fedora Core 6, Python 2.5, and managed with Plesk 8.2.
I just turned on fcgid from the Plesk control panel ("Physical hosting
setup page for domain", checked "FastCGI"), and enabled the standard
FCGI configuration, which is actually mod_fcgid.

The Python app is launched from "cgi-bin" with a file ending in
".fcgi". It uses Alan Saddi's "fcgi.py" module to interface with
an FCGI server. Python programs that use "fcgi.py" will also run
as standard CGI programs, for debug purposes. And that's what's
happening. I modified my test Python program to patch
"fcgi.CGIrequest._end" with a version that logged its calls,
and that's being called. This indicates that "fcgi.py" is running
in CGI mode, not FCGI mode. My test program is reloaded for every
HTTP request, as indicated by debug output, so it really is running
in CGI mode, with the expected low performance.

What's wierd is that the ".fcgi" suffix files get executed at all.
I'd expect them to be either ignored or run properly with FCGI.

John Nagle
Sep 4 '07 #5
* John Nagle (Mon, 03 Sep 2007 21:26:01 -0700)
I'm converting a web app from CGI to FCGI. The application works fine
under FCGI, but it's being reloaded for every request, which makes FCGI
kind of pointless. I wrote a little FCGI app which prints when the program is
loaded and when it gets a request. And indeed, the program gets reloaded for
each HTTP request. Something is probably misconfigured. But what?
[...]
On the Python side, I'm using Python 2.5 on Linux, with Alan
Saddi's "fcgi.py" module.
Do you use fcgi.py or flup? Go for flup
"What's the difference between flup's fcgi module and your previous
fcgi.py?

Feature-wise, very little, as I do try to keep both implementations in
sync. The most significant difference is that flup's fcgi module uses
thread pooling, fcgi.py simply starts a new thread for each
connection/request. flup's code is refactored and modularized, to
minimize duplicated code between all 6 servers."

http://trac.saddi.com/flup/wiki/Flup...cebetweenflups
fcgimoduleandyourpreviousfcgi.py
Sep 4 '07 #6
Anything executable in the
cgi-bin directory is being launched as a CGI program. A file
named "example.foo", if executable, will launch as a CGI program.
Nothing launches with FCGI.
Perhaps you have a SetHandler declaration somewhere that makes all
files CGI by default? I would advise against Sethandler, and
recommend AddHandler instead.

Regards,
Martin
Sep 4 '07 #7
John Nagle wrote:
This is running on a dedicated server at APlus.net,
running Red Hat Fedora Core 6, Python 2.5, and managed with Plesk 8.2.
I just turned on fcgid from the Plesk control panel ("Physical hosting
setup page for domain", checked "FastCGI"), and enabled the standard
FCGI configuration, which is actually mod_fcgid.
[..]
What's wierd is that the ".fcgi" suffix files get executed at all.
I'd expect them to be either ignored or run properly with FCGI.
Then I would ask APlus.net what's really going on there.

Ciao, Michael.
Sep 5 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: aurora | last post by:
I am looking for a way for reloading updated modules in a long running server. I'm not too concerned about cascaded reload or objects already created. Just need to reload module xxx if the...
0
by: Kevin T. Ryan | last post by:
Hi All - I'm trying to develop web applications using python / Cheetah. I'm also trying to experiment with lighttpd (see www.lighttpd.net), which supports fast-cgi. So, I downloaded Robin...
8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
1
by: Marcia Gulesian | last post by:
Is there a way of reloading a page programatically - for example, <script language="javascript> document.location.reload() </script> BUT NOT HAVING TO MANUALLY CLICK A "RESET" BUTTOM.
3
by: Richard | last post by:
Hey there, I have a textbox and a listbox. When a user types a number in the textbox, I want to get all the records from a MS Access DB but without reloading the page. I now have something...
1
by: Daylor | last post by:
hi. i want to display page. then check every 10 seconds from the client, if a value in the server is changed WITHOUT RELOADING THE ALL PAGE. if value has change, i want the client to reload...
0
by: thorley | last post by:
Does any one know of a fcgi SEVER implementation for python? I've seen lots of great stuff for the client/application side, but not a server. By server, I mean the program that accepts requests...
2
by: Tamer | last post by:
Hi! Is there a way to change the protocoll type through Javascript without reloading (or making a request from the webserver) via Javascript? for example: http://mydomain.com...
0
by: Joshua Kugler | last post by:
bryan rasmussen wrote: They might have ported a version for Python 2.6. Versions <= 2.5 didn't have a socket.fromfd() on Windows, so FCGI and SCGI wouldn't work. j
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.