Using PHP-MySQL Persistent Connections to Run WordPress Blog使用PHP - MySQL的持久连接运行的WordPress所博客

When connecting to MySQL database, WordPress weblog based on PHP scripting will use non-persistent connection by default.当连接到MySQL数据库,在WordPress博客基于PHP脚本将使用非持久连接默认情况下。 That is, WordPress will trigger PHP to generate a new connection to MySQL server for each dynamic page request, and subsequently close the database connection once the web page building is completed.这是,在WordPress会触发PHP中生成一个新的连接到MySQL服务器为每个动态页面的请求,并随后关闭数据库连接,一旦网页建设,是完成。 Repetitive opening and closing of MySQL connections causes overheads and uses up precious CPU, memory and system resources on the web host.重复的开幕和闭幕的MySQL连接的原因和间接利用了宝贵的CPU ,内存和系统资源在网上东道国。

Using persistent connection to connect to MySQL database server is not always a good option.使用持久性连接来连接到MySQL数据库服务器并不总是一个好的选择。 Each connections takes up resources, including memory, buffers, table or thread caches internally in MySQL and sockets, open files or IO activity at OS level.每个连接占用的资源,包括内存,缓冲器,表或线程缓存国内在MySQL和插座,打开文件或印务局的活动在操作系统的水平。 Thus when a lot of persistent connections are opened but not closed after transactions are completed, the resources on system may drain up and degrade performance of web server, or in worst case, cause HTTP failure.因此,当大量的持久连接开放的而不是封闭后,交易完成后,资源,系统可能会流失和降解性能的Web服务器,或在最坏的情况下,事业的HTTP失败。 Furthermore, if a persistent connection is stalled, inactive or became defunct or no longer in used, it is not terminated, and MySQL server will only close it to release the resource occupied by the connection after about 28800 seconds (8 hours) by default unless changed the timeout parameters in my.cnf configuration files.此外,如果持续的连线是停滞不前,成为无效或停业或不再在使用,这是没有终止, MySQL服务器将只将它关闭,以释放所占用资源的连接后约二八八〇 〇秒( 8小时)默认情况下,除非改变了超时参数的my.cnf配置文件。 This few factors may bring troubles such as MySQL refusing new DB connections or slow server if the applications do not properly handle persistent connections.这几个因素可能带来的麻烦,如MySQL的拒绝新分贝的关系,或缓慢,服务器,如果申请不妥善处理持久连接。 Thus if you’re not experience webmasters, please do not attempt to change Wordpress to use persistent connections.因此,如果您没有经验的网站管理员,请不要试图改变WordPress所使用的持久连接。

However, for bloggers who have busy and large blog, and facing constraints in upgrading web host system specifications, and do not want to use static page caching plugin such as WP-Cache, persistent connection is a available option to tune and optimize the web server to see if the webpage serving can be faster.然而,对于博客谁也忙,博客规模较大,面临的制约因素,在提升Web主机的系统规格,以及不想使用静态网页缓存插件,如可湿性粉剂-快取记忆体,持续的连线是一个可行的选择,以调整和优化Web服务器看看网页服务,可以更快。 Persistent connection allows connection to be open once and will not be closed when the execution of the script ends.持久连接允许连接到开放后并不会关闭时,执行该脚本结束。 Instead, the link is kept in pool and will remain open for future use.反之,链接是存放在游泳池和将继续开放,供今后使用。 Thus, using persistent connections will eliminate the process of opening and closing the connection.因此,使用持久连接,将消除的过程中打开和关闭连接。 This will indirectly reduce MySQL connection related server overheads such as authentication to establish connection where only once is needed, saving extra network traffic, and resources used to handle extra connection.这将间接地减少MySQL连接相关的服务器,如间接验证建立连接的地方只有一次是需要,节省额外的网络流量,以及所用的资源来处理额外的连接。 Beside, there could be some connection level caches, which need to be filled up for proper performance, and potentially reduce the number of connections to the database.旁边的,可能会有一些方面的水平高速缓存,需要加以填补了适当的表现,以及潜在的数目减少连接到数据库。

By default, WordPress is using mysql_connect() function that establishes a new database connection on every page.默认情况下,在WordPress是使用mysql_connect ( )函数,建立一个新的数据库连接的每一页上。 The persistent connection feature will require mysql_pconnect() function which uses the exact same API, but has built-in connection pooling to keep connections alive between requests.持续连接功能将需要mysql_pconnect ( )函数使用完全相同的空气污染指数,但已内置在连接池,以保持连接活着之间的请求。 So to switch to use persistent connection to run WordPress, the mysql_connect() function has to be replaced with mysql_pconnect().因此,切换到使用持久连接运行的WordPress , mysql_connect ( )函数已被取代,与mysql_pconnect ( ) 。

To enable and use persistent connections with WordPress, simply login to your web host with SSH (or insecure Telnet), and change to the webroot home directory where WordPress blog is installed.启用和使用的持久连接与在WordPress ,只需登录到您的Web主机的SSH (或不安全的Telnet ) ,并更改到了Webroot家所在的目录WordPress所博客安装。 Then change directory into wp-includes directory.然后将目录更改到可湿性粉剂-包括目录。 Inside the wp-includes directory, there is wp-db.php file.内可湿性粉剂-包括目录,有可湿性粉剂- db.php文件。 Use any text editor such as vi to edit wp-db.php.使用任何文本编辑器,如六编辑可湿性粉剂- db.php 。 Search or locate the function of mysql_connect (or @mysql_connect ).搜索或找到的功能, mysql_connect (或@ mysql_connect ) 。 There is only one instance of mysql_connect.只存在一个实例mysql_connect 。 Just change the mysql_connect to mysql_pconnect , then save and exit the wp-db.php.只是改变mysql_connect以mysql_pconnect ,然后保存并退出可湿性粉剂- db.php 。 WordPress and PHP (as long as you don’t turn off the mysql.allow_persistent in PHP.INI) will immediately use persistent connections to connect to MySQL database.在WordPress和PHP (只要你不关闭mysql.allow_persistent在php.ini )将立即使用持久连接连接到MySQL数据库。 It’s worth to try out which setting is best for your environment.这是值得尝试的设置是最适合您的环境。

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 .



One Response to “Using PHP-MySQL Persistent Connections to Run WordPress Blog” 1回应“用PHP - MySQL的持久连接运行的WordPress博客”

  1. Edward何承天
    September 27th, 2007 22:14 2007年9月27日22时14分
    1

    This seemed to do the trick for.这似乎是这样做的伎俩。 Thanks so much for the info!感谢这么多的信息!

Leave a Reply离开的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <删除日期时间= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅无评论


Custom Search

New Articles新的条款,

Incoming Search Terms for the Article传入的搜索条件文章

php mysql persistent PHP的MySQL的持久性 - - mysql persistent connections MySQL的持久连接 - - php mysql timeout PHP的MySQL的超时 - - mysql persistent connection MySQL的持久连接 - - mysql persistent MySQL的持久性 - - Your applications are not closing MySQL connections properly 您的申请不关闭MySQL的连接正确 - - php mysql persistent connection PHP的MySQL的持久连接 - - wordpress connection open 在WordPress方面开放 - - mysql keep connections open MySQL的连接保持开放 - - php mysql persistent connections PHP的MySQL的持久连接 - - wordpress persistent connections 在WordPress持久连接 - - mysql persistent timeout MySQL的持久性超时 - - persistent connection 持久连接 - - mysql chiudere persistent connection MySQL的chiudere持久连接 - - wordpress mysql_connect 在WordPress mysql_connect - - php mysql persistant connection PHP的MySQL的持久连接 - - wordpress mysql connections 在WordPress MySQL的连接 - - Open and closing connections MySql 打开和关闭连接的MySQL - - mySQL persistent connect MySQL的持久连接 - - php persistent connection PHP的持久连接 - - how to connect php and mysql on windows vista 如何连接PHP和MySQL在Windows Vista - - wordpress mysql php 在WordPress的MySQL的PHP - - wordpress mysql_pconnect 在WordPress mysql_pconnect - - mysql persistent database connection low speed MySQL的持久数据库连接低速 - - php keep mysql connection alive PHP中保持MySQL连接活着 - - enable persistent connection in mysql 使持续的连线在MySQL - - persistent connections mysql 持久连接的MySQL - - wordpress blog problem with connecting to php mysql WordPress所博客的问题,与连接到PHP的MySQL - - all 全部 - - wordpress mysql persistent connections 在WordPress MySQL的持久连接 - - wordpress persistant connections 在WordPress持久连接 - - wordpress mysql connection opening not closing 在WordPress MySQL连接开放,没有闭幕 - - php mysql keep connection alive PHP的MySQL的保持连接活着 - - php mysql wordpress PHP的MySQL中的WordPress - - php persistent db connection PHP的持续DB连接 - - connection pooling mysql php.ini 连接池的MySQL的php.ini - - mysql persistant connections MySQL的持久连接 - - calling MySQL from a Wordpress page MySQL的要求从在WordPress页 - - Persistent database connections php turn off 数据库永久连接的PHP关闭 - - persistent security= mysql 持续安全的MySQL = - - PHP persistant connections persistent" mysql connections PHP的持久连接持久性“的MySQL连接 - - unable to connection using mysql_connect() 无法连接使用mysql_connect ( ) - - verify db connection php mysql 验证DB连接的PHP的MySQL - - wordpress connection 在WordPress连接 - - code of blog site by using php-mysql 守则博客网站使用PHP - MySQL的 - - php mysql open connection security PHP的MySQL的开放连接安全 - - wordpress will not connect mysql 在WordPress将无法连接的MySQL - - mysql persistent performance MySQL的持久性表现 - - php persistent mysql PHP的MySQL的持久性 - - php wordpress mysql requirements PHP中的WordPress MySQL的要求 - -