473,902 Members | 3,774 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
37 4005

Chung Leong wrote:
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.
We're using ODBC instead of the direct MSSQL drivers for one, and we
are using the standard odbc_connect() function. Are there any known
problems using ODBC with MS SQL Server?

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.
Wouldn't the service login be the Web Server service login? So to
control the PHP login I would need to change the Web service login?

Jul 26 '06 #11
Joshua Ruppert wrote:
We're using ODBC instead of the direct MSSQL drivers for one, and we
are using the standard odbc_connect() function. Are there any known
problems using ODBC with MS SQL Server?
I'm not too familiar with ODBC. The SQL Server ODBC driver does
connection pooling. With standard CGI you'd get a new connection
everytime, whereas the connection would be reused in FastCGI. As your
application works in CGI but no in FastCGI, that's a good place to
look.

It could also be that you were experiencing deadlocks before, only that
IIS was terminating the process.

I'm sort of out of ideas. You might want to reproduce the condition (on
a test environment of course), then run sp_who/sp_who2 in Query
Analyser to see what is actually happening. It'd also be interesting to
see if the PHP processes would unfreeze if you stop SQLServer.
Wouldn't the service login be the Web Server service login? So to
control the PHP login I would need to change the Web service login?
Nevermind. I mistakenly thought the installer adds PHP as a service.

Jul 26 '06 #12
Chung Leong wrote:
Joshua Ruppert wrote:
We're using ODBC instead of the direct MSSQL drivers for one, and we
are using the standard odbc_connect() function. Are there any known
problems using ODBC with MS SQL Server?

I'm not too familiar with ODBC. The SQL Server ODBC driver does
connection pooling. With standard CGI you'd get a new connection
everytime, whereas the connection would be reused in FastCGI. As your
application works in CGI but no in FastCGI, that's a good place to
look.

It could also be that you were experiencing deadlocks before, only that
IIS was terminating the process.

I'm sort of out of ideas. You might want to reproduce the condition (on
a test environment of course), then run sp_who/sp_who2 in Query
Analyser to see what is actually happening. It'd also be interesting to
see if the PHP processes would unfreeze if you stop SQLServer.
No problem. I'm about at the end of my rope too. I've not been able to
reproduce the problem, but it (stranded PHP processes) actually happens
with or without FastCGI, but without FastCGI I'm able to kill the
stranded processes. So I'm able to keep the site running, my big
problem with FastCGI is that when the !@#$ hit the fan I had to reboot.

We are no strangers to SQL Server and resolving dead locks and
optimizing queries but these stranded processes have been a complete
mystery. The problem is that even if we can prove it's caused by a dead
lock, you can't avoid the occasional dead lock. The best you can do is
write the program so it recovers gracefully. We're thinking about
trying PHP 5 to see if that resolves the problem. We may even write a
low level app to clear out stranded processes. It seem like more of a
bug in PHP forever waiting instead of timing out.

Jul 26 '06 #13
Joshua Ruppert wrote:
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*******@a ttglobal.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*******@att global.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.
I always free my results as soon as I'm done with them, and close the
database when I've completed processing with it. I guess I've been
bitten too many times in almost 40 years of programming to depend on the
gc :-).

FastCGI will clean up dead processes when the gc runs. The problem is
it doesn't run immediately - there can be (and generally is) a delay
before it cleans everything up. But like you, I would expect closing
the connection would free the results, at least as far as the database
end goes. And even if they weren't cleaned up on the PHP end
immediately, they shouldn't affect other connections.

Could it be the database servers are just so loaded they can't get back
in a reasonable time? I've found typically response time is an
exponential curve - going from 1% load to 10% load won't affect response
time much - but going from 90% to 99% load has a very big effect. Load
could include CPU, disk, network, etc.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 27 '06 #14

Jerry Stuckle wrote:
Joshua Ruppert wrote:
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*******@at tglobal.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*******@attg lobal.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.

I always free my results as soon as I'm done with them, and close the
database when I've completed processing with it. I guess I've been
bitten too many times in almost 40 years of programming to depend on the
gc :-).

FastCGI will clean up dead processes when the gc runs. The problem is
it doesn't run immediately - there can be (and generally is) a delay
before it cleans everything up. But like you, I would expect closing
the connection would free the results, at least as far as the database
end goes. And even if they weren't cleaned up on the PHP end
immediately, they shouldn't affect other connections.

Could it be the database servers are just so loaded they can't get back
in a reasonable time? I've found typically response time is an
exponential curve - going from 1% load to 10% load won't affect response
time much - but going from 90% to 99% load has a very big effect. Load
could include CPU, disk, network, etc.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Ya, I've come a long way since the initial creation of this site but I
believe that it's pretty tight now, when it comes to db connection
cleanup.

The load on the DB servers was our first thought too, but to complicate
my research even more, I've seen the stranded processes even durring
low traffic times. This makes absolutely no sense to me and seems to
point to a dead lock issue, but then we're back to the PHP libraries
not handling dead locks gracefully. Which I don't think I can do much
about, asside from having a separate app to monitor stranded processes.

Jul 28 '06 #15
Joshua Ruppert wrote:
Jerry Stuckle wrote:
>>Joshua Ruppert wrote:
>>>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
>>>server s but I'm not certain. When the database servers became loaded,
>>>the PHP processes seemed to hang while waiting for the database to
>>>respon d. Eventually this effected each of the PHP processes started by
>>>FastCG I, completely taking down the site.
>>>

t>>The only way I found to restart the PHP processes is to reboot
the
>>>machin e, because task manager did let me kill the processes that were
>>>starte d 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
>>>troubl e 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******* @attglobal.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
>processe s?
>
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*******@a ttglobal.net
=========== =======
Yes, I went through the scripts very methodically and systematically to
add the following to the end of each script
odbc_close($ connect);

and I also do a
odbc_free_re sult($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_re sult call before each odbc_close, but I would assume that a
close would also free the result set.

I always free my results as soon as I'm done with them, and close the
database when I've completed processing with it. I guess I've been
bitten too many times in almost 40 years of programming to depend on the
gc :-).

FastCGI will clean up dead processes when the gc runs. The problem is
it doesn't run immediately - there can be (and generally is) a delay
before it cleans everything up. But like you, I would expect closing
the connection would free the results, at least as far as the database
end goes. And even if they weren't cleaned up on the PHP end
immediately , they shouldn't affect other connections.

Could it be the database servers are just so loaded they can't get back
in a reasonable time? I've found typically response time is an
exponential curve - going from 1% load to 10% load won't affect response
time much - but going from 90% to 99% load has a very big effect. Load
could include CPU, disk, network, etc.
--
============= =====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@att global.net
============= =====


Ya, I've come a long way since the initial creation of this site but I
believe that it's pretty tight now, when it comes to db connection
cleanup.

The load on the DB servers was our first thought too, but to complicate
my research even more, I've seen the stranded processes even durring
low traffic times. This makes absolutely no sense to me and seems to
point to a dead lock issue, but then we're back to the PHP libraries
not handling dead locks gracefully. Which I don't think I can do much
about, asside from having a separate app to monitor stranded processes.
But deadlocks handling isn't a function of the PHP libraries - it's one
of the database. It would, for instance, be very cruel to pull the
calling program (and it's memory) out from under the DB in the middle of
a DB call. Which, BTW, is possibly why you can't cancel the tasks from
the OS.

I suspect if you recycle the database things would free up (with errors,
of course).

Sounds to me like maybe you need to troubleshoot this from the db end.

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

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

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*******@ attglobal.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*******@at tglobal.net
============ ======
Yes, I went through the scripts very methodically and systematically to
add the following to the end of each script
odbc_close($c onnect);

and I also do a
odbc_free_res ult($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_res ult call before each odbc_close, but I would assume that a
close would also free the result set.
I always free my results as soon as I'm done with them, and close the
database when I've completed processing with it. I guess I've been
bitten too many times in almost 40 years of programming to depend on the
gc :-).

FastCGI will clean up dead processes when the gc runs. The problem is
it doesn't run immediately - there can be (and generally is) a delay
before it cleans everything up. But like you, I would expect closing
the connection would free the results, at least as far as the database
end goes. And even if they weren't cleaned up on the PHP end
immediately, they shouldn't affect other connections.

Could it be the database servers are just so loaded they can't get back
in a reasonable time? I've found typically response time is an
exponential curve - going from 1% load to 10% load won't affect response
time much - but going from 90% to 99% load has a very big effect. Load
could include CPU, disk, network, etc.
--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attg lobal.net
============== ====

Ya, I've come a long way since the initial creation of this site but I
believe that it's pretty tight now, when it comes to db connection
cleanup.

The load on the DB servers was our first thought too, but to complicate
my research even more, I've seen the stranded processes even durring
low traffic times. This makes absolutely no sense to me and seems to
point to a dead lock issue, but then we're back to the PHP libraries
not handling dead locks gracefully. Which I don't think I can do much
about, asside from having a separate app to monitor stranded processes.

But deadlocks handling isn't a function of the PHP libraries - it's one
of the database. It would, for instance, be very cruel to pull the
calling program (and it's memory) out from under the DB in the middle of
a DB call. Which, BTW, is possibly why you can't cancel the tasks from
the OS.

I suspect if you recycle the database things would free up (with errors,
of course).

Sounds to me like maybe you need to troubleshoot this from the db end.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Ya I guess you are correct, you can't error trap a query that never
returns. I guess my quandry is why the proccesses aren't timing out.
Could I have found a loop hole in the PHP max_execution_t ime limit?

I'm a little confused about how to troubleshoot this from the DB side.
The only way I see to avoid dead locks is to write all queries without
any joins, or serialize the queries on the database. Is it possible to
serialize some or all queries? I started setting up alerts to create
log entries for deadlock situations, I'm now stumbling through how to
send eMail from SQL Server (that's turned into an entirely new
expedition). Is there any additional you would suggest for
troubleshooting on the db side? Any experience with SQL Server 2000?

Jul 29 '06 #17
Joshua Ruppert wrote:
Jerry Stuckle wrote:
>>Joshua Ruppert wrote:
>>>Jerry Stuckle wrote:
Joshua Ruppert wrote:
>Jerry Stuckle wrote:
>
>
>
>>Joshua Ruppert wrote:
>>
>>
>>
>>>Jerry Stuckle wrote:
>>>
>>>
>>>
>>>
>>>>Joshu a 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
>>>>>swit ch over to FastCGI. When I did this every thing ran fine for a
>>>>>whil e, 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
>>>>>server s but I'm not certain. When the database servers became loaded,
>>>>>the PHP processes seemed to hang while waiting for the database to
>>>>>respon d. Eventually this effected each of the PHP processes started by
>>>>>FastCG I, completely taking down the site.
>>>>>
>
>t>>The only way I found to restart the PHP processes is to reboot
>the
>
>
>
>>>>>machin e, because task manager did let me kill the processes that were
>>>>>starte d 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
>>>>>troubl e 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
>>>>likel y 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.
>>>>
>>>>--
>>>>======= ===========
>>>>Remov e the "x" from my email address
>>>>Jerry Stuckle
>>>>JDS Computer Training Corp.
>>>>js***** **@attglobal.ne t
>>>>======= ===========
>>>
>>>
>>>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
>>>greatl y reduces the risk also. Isn't FastCGI suppose to clean up dead
>>>processe s?
>>>
>>
>>
>>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******* @attglobal.net
>>========= =========
>
>
>Yes, I went through the scripts very methodically and systematically to
>add the following to the end of each script
>odbc_close ($connect);
>
>and I also do a
>odbc_free_ result($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_ result call before each odbc_close, but I would assume that a
>close would also free the result set.
>

I always free my results as soon as I'm done with them, and close the
database when I've completed processing with it. I guess I've been
bitten too many times in almost 40 years of programming to depend on the
gc :-).

FastCGI will clean up dead processes when the gc runs. The problem is
it doesn't run immediately - there can be (and generally is) a delay
before it cleans everything up. But like you, I would expect closing
the connection would free the results, at least as far as the database
end goes. And even if they weren't cleaned up on the PHP end
immediately , they shouldn't affect other connections.

Could it be the database servers are just so loaded they can't get back
in a reasonable time? I've found typically response time is an
exponenti al curve - going from 1% load to 10% load won't affect response
time much - but going from 90% to 99% load has a very big effect. Load
could include CPU, disk, network, etc.
--
=========== =======
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@a ttglobal.net
=========== =======
Ya, I've come a long way since the initial creation of this site but I
believe that it's pretty tight now, when it comes to db connection
cleanup.

The load on the DB servers was our first thought too, but to complicate
my research even more, I've seen the stranded processes even durring
low traffic times. This makes absolutely no sense to me and seems to
point to a dead lock issue, but then we're back to the PHP libraries
not handling dead locks gracefully. Which I don't think I can do much
about, asside from having a separate app to monitor stranded processes.

But deadlocks handling isn't a function of the PHP libraries - it's one
of the database. It would, for instance, be very cruel to pull the
calling program (and it's memory) out from under the DB in the middle of
a DB call. Which, BTW, is possibly why you can't cancel the tasks from
the OS.

I suspect if you recycle the database things would free up (with errors,
of course).

Sounds to me like maybe you need to troubleshoot this from the db end.

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


Ya I guess you are correct, you can't error trap a query that never
returns. I guess my quandry is why the proccesses aren't timing out.
Could I have found a loop hole in the PHP max_execution_t ime limit?

I'm a little confused about how to troubleshoot this from the DB side.
The only way I see to avoid dead locks is to write all queries without
any joins, or serialize the queries on the database. Is it possible to
serialize some or all queries? I started setting up alerts to create
log entries for deadlock situations, I'm now stumbling through how to
send eMail from SQL Server (that's turned into an entirely new
expedition). Is there any additional you would suggest for
troubleshooting on the db side? Any experience with SQL Server 2000?
Not a hole at all. It's the same as before - PHP can't time out the
script if it's out in a DB call. This could cause memory related to the
call (that the DB needs) to be released and other nasty things. The
same would be true (but to a lesser extent) in some system calls.

Queries don't cause deadlocks. Updates to the database cause deadlocks.
However, those deadlocked updates may hold locks which don't allow
other requests (including locks) to proceed.

Looks like you're going to have to read up on troubleshooting database
problems. There's some good info in the MySQL doc. And I'd suggest you
follow up on a MySQL newsgroup such as comp.databases. mysql.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 29 '06 #18
Joshua Ruppert wrote:
I'm a little confused about how to troubleshoot this from the DB side.
The only way I see to avoid dead locks is to write all queries without
any joins, or serialize the queries on the database. Is it possible to
serialize some or all queries? I started setting up alerts to create
log entries for deadlock situations, I'm now stumbling through how to
send eMail from SQL Server (that's turned into an entirely new
expedition). Is there any additional you would suggest for
troubleshooting on the db side? Any experience with SQL Server 2000?
Have you tried the "log long query" option in the ODBC driver? If it
works as stated, it should give you some insight into what is causing
the process to hang.

Jul 29 '06 #19
I was just doing some testing on the SQLServer ODBC driver for
something I was working and I noticed that retrieving rows through the
odbc functions is incredibly slow compare to using the mssql functions.
We're talking about an order of magnitude difference. I wonder if your
script was simply running very slowly and hadn't actually stalled. Try
timing how long it takes to retrieve all rows from a particularly large
table in a couple test scripts, once with ODBC and then with the mssql
functions.

Jul 30 '06 #20

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
4179
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
1594
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
3564
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
25735
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
6014
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
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9845
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10866
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
10978
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
7204
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();...
0
5892
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6084
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4724
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4305
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.