F1Fan Posted July 19, 2010 Share Posted July 19, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/208226-limit-single-functions-execution-time/ Share on other sites More sharing options...
AbraCadaver Posted July 19, 2010 Share Posted July 19, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/208226-limit-single-functions-execution-time/#findComment-1088358 Share on other sites More sharing options...
F1Fan Posted July 19, 2010 Author Share Posted July 19, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/208226-limit-single-functions-execution-time/#findComment-1088366 Share on other sites More sharing options...
F1Fan Posted July 19, 2010 Author Share Posted July 19, 2010 One other thing: will what you suggested throw a warning or a fatal error if it takes longer than the prescribed time limit? Quote Link to comment https://forums.phpfreaks.com/topic/208226-limit-single-functions-execution-time/#findComment-1088367 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.