473,883 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FastCGI and DB connections / global variables?

When I'm using FastCGI do I need to code differently than I do when
using regular CGI? Because the PHP.exe processes don't go away do
global variables stick around from page request to page request,
creating the need for better managment / pooling of DB connections?

Josh

Jul 25 '06 #1
37 4003

Joshua Ruppert wrote:
When I'm using FastCGI do I need to code differently than I do when
using regular CGI? Because the PHP.exe processes don't go away do
global variables stick around from page request to page request,
creating the need for better managment / pooling of DB connections?

Josh
There is no difference from a programming standpoint. Global variables
are destroyed at the end of each request.

Jul 25 '06 #2
With that said I'm not sure what my problem is. I have a website that
has already been developed running Win2K and PHP 4, that I tried to
switch over to FastCGI. When I did this every thing ran fine for a
while, until we had a spike in traffic. (Since FastCGI was tried we
have moved to Win2K3.)

The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.

The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.

Is there anything that you could see (slow DB connections or otherwise)
that would cause this kind of behavior?

I used the PHPLens.com EasyWindows PHP Installer, but I'm having
trouble finding resources to help me fine tune FastCGI opperation.

Any suggestions are greatly appreciated.
Chung Leong wrote:
Joshua Ruppert wrote:
When I'm using FastCGI do I need to code differently than I do when
using regular CGI? Because the PHP.exe processes don't go away do
global variables stick around from page request to page request,
creating the need for better managment / pooling of DB connections?

Josh

There is no difference from a programming standpoint. Global variables
are destroyed at the end of each request.
Jul 25 '06 #3
Joshua Ruppert wrote:
The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.
Hmmm. What's the database server? Maybe a script has left a transaction
open by accident?
The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.
Sort off topic, but I think you'll find the kill util in the Windows
Resource Kit quite handy for situations like that.

Jul 25 '06 #4
Joshua Ruppert wrote:
With that said I'm not sure what my problem is. I have a website that
has already been developed running Win2K and PHP 4, that I tried to
switch over to FastCGI. When I did this every thing ran fine for a
while, until we had a spike in traffic. (Since FastCGI was tried we
have moved to Win2K3.)

The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.

The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.

Is there anything that you could see (slow DB connections or otherwise)
that would cause this kind of behavior?

I used the PHPLens.com EasyWindows PHP Installer, but I'm having
trouble finding resources to help me fine tune FastCGI opperation.

Any suggestions are greatly appreciated.

Is it possible you're getting into a deadlock situation? These are more
likely to show up when the database is busy, and you probably wouldn't
be able to cancel the task.

P.S. - please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 26 '06 #5

Chung Leong wrote:
Joshua Ruppert wrote:
The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.

Hmmm. What's the database server? Maybe a script has left a transaction
open by accident?
There are four Microsoft SQL Server 2000 servers running behind a
single IIS page server.

As for an open transaction, that was my first thought too. I've
systematically check for and clean up open transactions before each use
and then at the end of each script. I did that because it was easy to
do a global search and replace on the open transaction statements.
The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.

Sort off topic, but I think you'll find the kill util in the Windows
Resource Kit quite handy for situations like that.
Thanks for the tip, though do you think FastCGI would respond properly
to a process being killed through the back door like that, and replace
it properly?

Jul 26 '06 #6

Jerry Stuckle wrote:
Joshua Ruppert wrote:
With that said I'm not sure what my problem is. I have a website that
has already been developed running Win2K and PHP 4, that I tried to
switch over to FastCGI. When I did this every thing ran fine for a
while, until we had a spike in traffic. (Since FastCGI was tried we
have moved to Win2K3.)

The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.

The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.

Is there anything that you could see (slow DB connections or otherwise)
that would cause this kind of behavior?

I used the PHPLens.com EasyWindows PHP Installer, but I'm having
trouble finding resources to help me fine tune FastCGI opperation.

Any suggestions are greatly appreciated.

Is it possible you're getting into a deadlock situation? These are more
likely to show up when the database is busy, and you probably wouldn't
be able to cancel the task.

P.S. - please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
What do you mean by "top post"? Replying above the previous posts?

No, I have not observed a deadlock. The site is 99% read only, so that
greatly reduces the risk also. Isn't FastCGI suppose to clean up dead
processes?

Jul 26 '06 #7
Joshua Ruppert wrote:
There are four Microsoft SQL Server 2000 servers running behind a
single IIS page server.

As for an open transaction, that was my first thought too. I've
systematically check for and clean up open transactions before each use
and then at the end of each script. I did that because it was easy to
do a global search and replace on the open transaction statements.
Are you using mssql_pconnect( )? Try switching to mssql_connect() . That
would remove the one difference between FastCGI and CGI.

If you're using ADODB through COM, that could be the source of the
problem. PHP (version 4 at least) has a nasty habit of not releasing
COM objects correctly. After a while the leak builds up and the server
sort of dies.
Thanks for the tip, though do you think FastCGI would respond properly
to a process being killed through the back door like that, and replace
it properly?
I think it will. Windows does a decent job cleaning up dead processes.
And to the controlling process, there isn't a huge difference between a
child exiting normally or abnormally.

What you should do though is to not run PHP as a system process. Go
into services and run change the login to IWebUser or something.

Jul 26 '06 #8
Joshua Ruppert wrote:
Jerry Stuckle wrote:
>>Joshua Ruppert wrote:
>>>With that said I'm not sure what my problem is. I have a website that
has already been developed running Win2K and PHP 4, that I tried to
switch over to FastCGI. When I did this every thing ran fine for a
while, until we had a spike in traffic. (Since FastCGI was tried we
have moved to Win2K3.)

The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.

The only way I found to restart the PHP processes is to reboot the
machine, because task manager did let me kill the processes that were
started by FastCGI.

Is there anything that you could see (slow DB connections or otherwise)
that would cause this kind of behavior?

I used the PHPLens.com EasyWindows PHP Installer, but I'm having
trouble finding resources to help me fine tune FastCGI opperation.

Any suggestions are greatly appreciated.


Is it possible you're getting into a deadlock situation? These are more
likely to show up when the database is busy, and you probably wouldn't
be able to cancel the task.

P.S. - please don't top post. Thanks.

--
============= =====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@att global.net
============= =====


What do you mean by "top post"? Replying above the previous posts?
Yep. This is perfect. Thanks!
No, I have not observed a deadlock. The site is 99% read only, so that
greatly reduces the risk also. Isn't FastCGI suppose to clean up dead
processes?

OK, are you sure you're closing your connections at the end of the
script? Waiting for PHP's gc to do it may take a little time.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 26 '06 #9

Jerry Stuckle wrote:
Joshua Ruppert wrote:
Jerry Stuckle wrote:
>Joshua Ruppert wrote:

With that said I'm not sure what my problem is. I have a website that
has already been developed running Win2K and PHP 4, that I tried to
switch over to FastCGI. When I did this every thing ran fine for a
while, until we had a spike in traffic. (Since FastCGI was tried we
have moved to Win2K3.)

The root cause of the problems seems to be the response time of the DB
servers but I'm not certain. When the database servers became loaded,
the PHP processes seemed to hang while waiting for the database to
respond. Eventually this effected each of the PHP processes started by
FastCGI, completely taking down the site.
t>>The only way I found to restart the PHP processes is to reboot
the
>>machine, because task manager did let me kill the processes that were
started by FastCGI.

Is there anything that you could see (slow DB connections or otherwise)
that would cause this kind of behavior?

I used the PHPLens.com EasyWindows PHP Installer, but I'm having
trouble finding resources to help me fine tune FastCGI opperation.

Any suggestions are greatly appreciated.

Is it possible you're getting into a deadlock situation? These are more
likely to show up when the database is busy, and you probably wouldn't
be able to cancel the task.

P.S. - please don't top post. Thanks.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attg lobal.net
============== ====

What do you mean by "top post"? Replying above the previous posts?

Yep. This is perfect. Thanks!
No, I have not observed a deadlock. The site is 99% read only, so that
greatly reduces the risk also. Isn't FastCGI suppose to clean up dead
processes?


OK, are you sure you're closing your connections at the end of the
script? Waiting for PHP's gc to do it may take a little time.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Yes, I went through the scripts very methodically and systematically to
add the following to the end of each script
odbc_close($con nect);

and I also do a
odbc_free_resul t($result);

before each
$result = odbc_exec($conn ect, $query);

This was my first website to use PHP and so I had to go back and
retrofit it to do DB resource cleanup. I performed a search and replace
on the odbc_exec calls to add the odbc_free_resul t call before each.
The only thing I'm seeing as I write this is that I could do a
odbc_free_resul t call before each odbc_close, but I would assume that a
close would also free the result set.

Jul 26 '06 #10

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

Similar topics

0
2200
by: Henri Vilminko | last post by:
I installed the Zend PHP enabler for Sun ONE Web Server which is basically a wrapper to run PHP in fastcgi mode. The interpreter runs fine but there's one nasty problem: PHP doesn't use the PHPRC environment variable I set in the config to assign each virtual server a different php.ini file. phpinfo() shows PHPRC correctly among the environment vars but for some reason PHP uses the default compiled-in ini path anyway. Any ideas what might...
0
2109
by: Andrew Crowe | last post by:
Hi guys, I've got 3 W2K Advanced Server machines here running PHP5.0.0 on IIS5. Two of them run perfectly using FastCGI. The third is unstable with FastCGI, after it's been running for a day or so it starts randomly printing out the error "-2147417842 (0x8001010e)" on a blank page. (Restarting IIS clears this for another day) If I try to use the built in ISAPI module it will give the "PHP has encountered an access violation" error at...
4
4178
by: Peter Otten | last post by:
Is there a way to limit both width and height of a canvas text item? My current workaround seems clumsy: import Tkinter as tk root = tk.Tk() canvas = tk.Canvas(root, width=400, height=200, bg="white") canvas.pack() # simulate a clipped text item - never transparent :-( s = "The long and winding road.."
2
2959
by: Mark | last post by:
When I develop a web app, I open and close connections on each page, executing multiple commands as necessary within the single open connection. However, I recently ran into a group of people that create a global connection for their web applications and share it across sessions/users/pages. Both models "work", but the second method makes me cringe ... unfortunately I can't seem to put my cringe into words as to why one should open and...
4
1592
by: Matt Anderson | last post by:
When I use Xcopy to deploy my changes to IIS, it seems to drop the user connections; i.e., empties out their Session variables, etc. I thought ASP.NET was supposed to use shadow deployment and gracefully have new connections use the new code, while the old code is cached for current connections. Anyone?
5
3563
by: howachen | last post by:
hi, which package you perfer? mod_php on apache is okay but some people said fastcgi version of php is faster, is it true? thanks...
7
25732
by: Vincent Delporte | last post by:
Hello I'm interested in hearing reflections by seasoned web app developpers about the different ways to write PHP apps, and especially how they compare in terms of performance, whether it's the PHP part or connections to MySQL. As far as I know, there are different ways to write a PHP application: - CGI, ie. the usual way : some PHP code in web pages, and the PHP interpreter is loaded each time a PHP page is called
0
1347
by: davidwalker611 | last post by:
Hi My server uses lighttpd and fastcgi. I am using htdigest to authenticate users wanting to access certain pages and I am trying to use $_SERVER to find out the name of the user who has logged into such pages. However it appears that $_SERVER is not being defined. I have read that there is a problem with fastcgi and _SERVER variables such as PHP_AUTH_USER, but I haven't come across a solution to this problem. Any help would be...
1
6013
by: jobs | last post by:
Re: Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. New webservers. win2003. IIS6. asp.net 2.0/ sql server 2005 and Oracle 9i through a 64 bit Oracle client. Everything working fine until this. I started getting these errors as the new website activity started to heat up. Timeout expired. The timeout period elapsed prior to obtaining a
0
11154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7977
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.