[wp-hackers] Wordpress - Database persistent connection support
Rarylson Freitas
rarylson at gmail.com
Fri Aug 23 16:56:26 UTC 2013
> Interestingly, the "drawbacks" covered on
> http://php.net/manual/en/features.persistent-connections.php<http://php.net/manual/en/features.persistent-connections.php> seem
far worse
> for us than the giant red "warning".
Yes, it's true. Basically, there was two major problems with persistent
connections.
- If the applications opens a transaction and not commit. In a non
persistent connection, there was no problem, because the query will be
commit when we call mysql_close(). But it's an application bug, and not an
error in the persistent connection method;
- If the application pooling (for example, a PHP-FPM pooling) creates more
connections than the maximum allowed in MySQL, we'll get a "Too Many
Connections" error. But it's a configuration error (a project error). In
these case, the developer must either increase your MySQL simultaneous
connection limit or uses a more sophisticated pooling method (not your
simple mysql_pconnect method).
Because of this, I proposed this option must be configurable and the
default behavior must be "persistent connections = disabled".
> If this had a benefit to sites on overloaded shared servers, I would think
> someone (if not a hosting company) would have proposed it at some point in
> the last six years. This anecdotally suggests to me that there is limited
> benefit or even detriment for most sites.
It makes sense. However, my team successfully improved applications
performance (not in Wordpress, neither in PHP, but in others systems) in
the past using persistent connections.
Maybe there was few only beneficts using persistent connections in
Wordpress, but my application shows that, using non persistent connections,
a lot of TIME_WAIT stills in the netstat output (and we're using a reduced
TIME_WAIT timeout value).
> HyperDB also has hypothetical
> persistent connection support, but it is turned off by default and I am
> unsure if anyone uses it.
I already use WP Super Cache. Recently, I knew W3 Total Cache. Now, I'll
study about HyperDB.
Thanks for the tip!
> Please always patch current trunk, or at worst, latest stable (3.6).
> Indeed, 3.5.1 isn't even the latest stable in the 3.5 branch.
Thanks. If in the future, I propose some patch and it makes sense, I'll
make it based in the most recent Trunk Version.
--
*Rarylson Freitas
*Computer Enginner
On Fri, Aug 23, 2013 at 1:27 PM, Andrew Nacin <wp at andrewnacin.com> wrote:
> On Fri, Aug 23, 2013 at 12:03 PM, Rarylson Freitas <rarylson at gmail.com
> >wrote:
>
> > I see that Wordpress uses the mysql_connect funcion in wp-db.php file.
> So,
> > the db_connect() function always return a non persistent connection to
> the
> > database.
>
>
> I was discussing this with a few others this week. This is interesting, but
> it isn't clear how much it would help. It is my understanding that we would
> need to monitor connection limits and open connections, especially on
> shared servers. It might be nice to add a flag (as proposed) but it would
> make sense to figure out whether this makes sense as a default, and if not,
> why not, as that in itself could be informative to the dangers of using
> persistent connections.
>
> If this had a benefit to sites on overloaded shared servers, I would think
> someone (if not a hosting company) would have proposed it at some point in
> the last six years. This anecdotally suggests to me that there is limited
> benefit or even detriment for most sites. HyperDB also has hypothetical
> persistent connection support, but it is turned off by default and I am
> unsure if anyone uses it.
>
> So, I propose a patch (to Wordpress v.3.5.1).
>
>
> Please always patch current trunk, or at worst, latest stable (3.6).
> Indeed, 3.5.1 isn't even the latest stable in the 3.5 branch.
>
> Nacin
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list