Jump to content

Limit single function's execution time


F1Fan

Recommended Posts

I have a site that connects to several databases. One is a critical connection, but the others are just for some non-essential reports. The problem is that when those secondary DBs are having issues, the entire site slows to a crawl.

 

So, what I'd like to do is attempt to connect to all the DBs, but put a time limit on those that aren't essential. If the connect function for any of those DBs takes too long, kill that function and move on.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/208226-limit-single-functions-execution-time/
Share on other sites

I've never done it but you can try this before the non-essential connections:

 

ini_set('mysql.connect_timeout', 2); // or however many seconds to wait

 

Then reset it to the default of 60 or another number for the critical connection.

Hmm, that's a good start. The problem is that the DBs are PostgreSQL (critical), Oracle, AS400 (DB2), and MS SQL (which is the reason this isn't posted in a specific SQL board). PostgreSQL and Oracle use pgsql and oci8 MDB2 drivers, and the AS400 and MS SQL use odbc.

 

I'm looking to see if there's an equivalent for each of those connections, but if you know and could tell me before I can search for it, that'd be cool!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.