Are connections persistant by default?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
Meta4
Registered User
Posts: 38
Joined: Thu Feb 09, 2006 6:57 pm

Are connections persistant by default?

Post by Meta4 » Wed Apr 12, 2006 6:17 pm

Are connections (particularly MySql4) persistant by default? From what I can see they're not, but I'm not sure I'm reading the code correctly.

Also, would using persistant connections be likely to reduce concurrent connections to the database?

TIA

Andy

espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom » Wed Apr 12, 2006 7:09 pm

Both mysql.php and mysql4.php use mysql_pconnect() for their connections, so yes, persistent connections are used, if enabled on the server. If the server has them disabled or the quantity limited by the PHP configuration, pconnects become regular connects.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer

User avatar
T0ny
Registered User
Posts: 1383
Joined: Sun Jan 29, 2006 8:42 pm
Location: Lancashire
Name: Tony

Post by T0ny » Wed Apr 12, 2006 7:32 pm

Although the contructor in mysql.php & mysql4.php defaults to persistent if no value is given for persistency

Code: Select all

function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
the actual creation of the database instance in includes/db.php specifies false for persistency

Code: Select all

$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
Unless I'm way off base, doesn't that mean that by default phpbb uses non-persistent connections :?:
Last edited by T0ny on Wed Apr 12, 2006 10:35 pm, edited 1 time in total.

Meta4
Registered User
Posts: 38
Joined: Thu Feb 09, 2006 6:57 pm

Post by Meta4 » Wed Apr 12, 2006 7:49 pm

That's exactly what I saw and thought Tony! Anyone care to clear things up for us?

Meta4
Registered User
Posts: 38
Joined: Thu Feb 09, 2006 6:57 pm

Post by Meta4 » Fri Apr 14, 2006 2:15 pm

Anyone?

fgh
Registered User
Posts: 10
Joined: Fri Feb 13, 2004 12:26 pm

Post by fgh » Tue Oct 10, 2006 9:48 pm

Meta4 wrote: That's exactly what I saw and thought Tony! Anyone care to clear things up for us?


I'm very surprised why nobody from the phpBB developer team give an official answer to this simple question.

Why are persistent connections disabled by default?

Why is this setting hardcoded in the db.php

Code: Select all

$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
and not a config-option in config.php?

Run anybody of you phpBB in persistent connection mode?

Does it bring a performance boost on big forums?

espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom » Wed Oct 11, 2006 4:18 am

fgh wrote: Why is this setting hardcoded in the db.php...and not a config-option in config.php?

Run anybody of you phpBB in persistent connection mode?

Does it bring a performance boost on big forums?


Some hosts dislike persistent connections. Others use PHP as a CGI, making them useless. It's not something that usually gets changed, either. And 95% of the people installing PHPBB would have no idea what it means, so they'd not be able to answer the question, "Do you want to use persistent connections?" to have it put in the config.php file.

Could it be part of the config? Certainly. But, it isn't a big thing. Changing db.php is not significantly different, though, than changing config.php, and more likely to be done by someone who knows what they're doing and why.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer

broodle
Registered User
Posts: 36
Joined: Thu Oct 13, 2005 7:24 pm

Post by broodle » Mon Oct 16, 2006 3:59 pm

sorry to bump this post but does this mean that by default all connections are not persistent? Because I have been having a lot of trouble lately with too many connections to the database and our host has shut down our site for a couple of days. I've been trying to get it back up but to no avail...

The error I'm getting is:

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /var/www/domains/sacredwrath.com/docs/db/mysql4.php on line 48

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /var/www/domains/sacredwrath.com/docs/db/mysql4.php on line 330

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /var/www/domains/sacredwrath.com/docs/db/mysql4.php on line 331
phpBB : Critical Error

so... basically even thought the constructor was written

Code: Select all

function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
, changing it to:

Code: Select all

function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = false)
doesn't really accomplish anything?

broodle
Registered User
Posts: 36
Joined: Thu Oct 13, 2005 7:24 pm

Post by broodle » Mon Oct 16, 2006 5:02 pm

This is what I'm getting from my host db admin:

Our Linux administrator has had to disable your account again. The reason this time is because of the number of MySQL connections it was using:

Examples:

sacredwrath.com GET / HTTP/1.1
sacredwrath.com GET /index.php?sid=874875310a2ee67391abc30936b885a8 HTTP/1.1 sacredwrath.com GET / HTTP/1.1 sacredwrath.com GET / HTTP/1.0 sacredwrath.com GET / HTTP/1.1 sacredwrath.com GET /calendar_scheduler.php?mode=hour&d=1160474400&sid=d45ea3ec
sacredwrath.com GET / HTTP/1.0
sacredwrath.com GET / HTTP/1.0

Any reason why this would be happening?

broodle
Registered User
Posts: 36
Joined: Thu Oct 13, 2005 7:24 pm

Post by broodle » Mon Oct 16, 2006 5:49 pm

I've found out that my host allows connections until the server is full... and it appears that the number of connections doesn't matter as my scripts will continue to request connections and tie up each one until the server is full.

Very strange this sounds like an infinite loop somewhere... /cry I don't know where this is coming from... :(

espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom » Wed Oct 18, 2006 4:59 am

A properly configured server will not allow more connections to the web server than it can handle on the MySQL server, if you're hosting sites that are SQL-intensive. Some hosts gamble by allowing lots of web conections, without having enough resources on the SQL side of the equation, figuring that most sites don't use anything but HTML.

In the case of your host, suggest that they limit the number of pconnections in their php.ini file to less than half of their MySQL server's connection limit (which will be 100, unless they've manually configured it for more), and PHP will not maintain more than that number of persistant connections.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer

Locked

Return to “2.0.x Support Forum”