Using PHP-MySQL Persistent Connections to Run WordPress Blog WordPressÀÇ´Â PHP - MySQLÀ» ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» »ç¿ëÇÏ¿© ½ÇÇàÇÒ ºí·Î±×

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ÀÇ °¢ µ¿Àû ÆäÀÌÁö ¿äû¿¡ ´ëÇÑ ¼­¹ö MySQL¿¡ ´ëÇÑ »õ·Î¿î ¿¬°áÀ» »ý¼ºÇÏ·Á¸é, PHP°¡ ½ÇÇàµÇ¸ç ÀÌÈÄ¿¡ µ¥ÀÌÅͺ£À̽º ¿¬°áµÇ¸é À¥ ÆäÀÌÁö°¡ ¿Ï·áµÇ¸é ÁÖº¯ °Ç¹°ÀÌ´Ù. 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°ú ¼ÒÄÏ, ¿­·ÁÀÖ´Â ÆÄÀÏÀ̳ª ¿î¿µ üÁ¦ ¼öÁØ¿¡¼­ ¾ÆÀÌ¿À¿Í¿¡ ij½Ã°¡ ³»ºÎÀûÀ¸·Î Ȱµ¿ µî ÀÚ¿ø °É¸³´Ï´Ù. 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. µû¶ó¼­ ¿µ±¸ÀûÀÎ ¿¬°áÀ» ÇÒ ¶§ ¸¹ÀÌ ¾È ¿­¾úÁö¸¸ ÀÌÈÄ °Å·¡°¡ ¿Ï·áµÇ´Â Æó¼â, ½Ã½ºÅÛ ¸®¼Ò½º¸¦ À¯ÃâÇÏ´Â 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 ¼­¹ö ¿î¿µ ÁßÁö »óÅ¿¡¸¸ ¸®¼Ò½º¿¡ ´ëÇØ ±âº»ÀûÀ¸·Î 2¸¸8õ8¹éÃÊ (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. 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. ±×·¯³ª »ç¶÷Àº ¹Ù»Û ´ëÇü ºí·Î±×°¡ ºí·Î°Å¿Í À¥ È£½ºÆ® ½Ã½ºÅÛÀÇ »ç¾çÀ» ¾÷±×·¹ÀÌ µå¿¡ Á¦¾à¿¡ Á÷¸é, ±×¸®°í Á¤Àû ÆäÀÌÁö Æ÷½ºÆ®¿Í °°Àº Ç÷¯±×ÀÎÀ» ij½Ì - ij½Ã, ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» »ç¿ëÇÏÁö ¾ÊÀ¸·Á¸é »ç¿ë °¡´ÉÇÑ ¿É¼ÇÀ» Á¶Á¤Çϰí À¥ ¼­¹ö¿¡ ÃÖÀûÈ­ÀÌ´Ù º¼ ¼öÀÖÀ» °æ¿ì¿¡´Â ºü¸¥ °Ë»ö À¥ÆäÀÌÁö. 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. So to switch to use persistent connection to run WordPress, the mysql_connect() function has to be replaced with mysql_pconnect(). ±×·¡¼­ ¿öµå ÇÁ·¹½º, () ÇÔ¼ö´Â 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. ¿öµå¿Í ÇÔ²² »ç¿ëÇÏ¿© ¿µ±¸ ¿¬°áÀ» Ȱ¼ºÈ­ÇÏ·Á¸é, °£´ÜÈ÷ SSH¸¦ (¶Ç´Â ºÒ¾È ÅÚ³Ý) ±ÍÇÏÀÇ À¥ È£½ºÆ®¿¡ ·Î±×ÀÎ, ±×¸®°í ¾îµð·Î WordPressÀÇ ºí·Î±×¿¡ ¼³Ä¡µÇ¾îÀÖ´Â Webroot Ȩ µð·ºÅ丮·Î º¯°æÇÕ´Ï´Ù. Then change directory into wp-includes directory. wp¸¦ ´©¸¥ ´ÙÀ½¿¡ µð·ºÅ丮 º¯°æÇÒ - µð·ºÅ丮¸¦ Æ÷ÇÔÇÕ´Ï´Ù. Inside the wp-includes directory, there is wp-db.php file. the wp¸¦ ³»ºÎ -, °Å±â¿¡ wp¸¦ - db.php ÆÄÀÏÀÌ µð·ºÅ丮¸¦ Æ÷ÇÔÇÕ´Ï´Ù. Use any text editor such as vi to edit wp-db.php. ¸ðµç ÅØ½ºÆ® ÆíÁý±â °°Àº viÀÇ wp¸¦ ÆíÁýÇÏ·Á¸é - 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_pconnect·Î, ±×¸®°í ÀúÀåÇϰí wp¸¦ mysql_connect - 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. ¿öµå¿Í PHP (¸¸Å­)¿¡ ¿¬°áÇÏ´Â Áï½Ã µ¥ÀÌÅͺ£À̽º MySQL¿¡ Áö¼Ó Á¢¼ÓÀ» »ç¿ëÇÏ½Ç mysql.allow_persistent php.ini¿¡¼­ ÇØÁ¦ÇÏÁö ¾Ê½À´Ï´Ù. 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¡± ÇϳªÀÇ ÀÀ´äÀ¸·Î "¸¦ »ç¿ëÇÏ¿© ¿µ±¸ ¿¬°áÀ» ½ÇÇà WordPressÀÇ´Â PHP - MySQLÀÇ ºí·Î±×¿¡"

  1. Edward ¿¡µå¿öµå
    September 27th, 2007 22:14 9 ¿ù 27 ÀÏ 2007 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> ÀÌ·¯ÇÑ ÅÂ±× : title="">Àº <a href="" »ç¿ëÇÒ ¼öÀÖ½À´Ï´Ù <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 connections PHP°¡ MySQLÀ» ¿µ±¸ÀûÀÎ Á¢¼Ó - - wordpress persistent connection ¿µ±¸ÀûÀÎ Á¢¼Ó ¿öµå - - Your applications are not closing MySQL connections properly MySQLÀ» ¿¬°áÇÏ¿© ÀÀ¿ë ÇÁ·Î±×·¥À» Á¦´ë·Î º¯·ÐÇÏÁö ¾Ê½À´Ï´Ù - - mysql persistent connection MySQLÀº ¿µ±¸ÀûÀÎ Á¢¼Ó - - php persistent mysql connection MySQLÀº PHP¸¦ ¿µ±¸ ¿¬°á - - php mysql persistent connection PHP°¡ MySQLÀ» ¿µ±¸ÀûÀÎ Á¢¼Ó - - persistent connection mysql ¿µ±¸ÀûÀÎ Á¢¼ÓÀº MySQL - - wordpress mysql connection mysqlÀ» ¿¬°á ¿öµå - - php mysql persistent PHP°¡ MySQLÀ» ¿µ±¸ - - wordpress persistent connections ¿µ±¸ÀûÀÎ Á¢¼Ó ¿öµå - - mysql persistent connection php MySQLÀº ¿µ±¸ÀûÀÎ Á¢¼ÓÀº PHP - - php mysql auto reconnect PHP°¡ MySQLÀ» ÀÚµ¿ À翬°á - - mysql persistent connections MySQLÀº ¿µ±¸ÀûÀÎ Á¢¼Ó - - mysql connect wordpress MySQLÀº WordPressÀÇ ¿¬°á - - mysql persistent MySQL Áö¼Ó - - wordpress persistent mysql ¿µ±¸ MySQLÀº WordPressÀÇ - - persistent connections mysql ¿µ±¸ÀûÀÎ Á¢¼ÓÀº MySQL - - php mysql keep connection PHP´Â MySQLÀÇ ¿¬°áÀ» À¯Áö - - Reduce or eliminate persistent connections to reduce connection usage °¨¼Ò ¶Ç´Â Á¦°Å ¿µ±¸ÀûÀÎ Á¢¼Ó ¿¬°á »ç¿ëÀ» ÁÙÀ̱â À§ÇØ - - wordpress persistent db connection ¿µ±¸ÀûÀÎ DB ¿¬°á ¿öµå - - wordpress mysql persistent connection MySQLÀº ¿µ±¸ÀûÀÎ Á¢¼Ó ¿öµå - - mysql persistent or not ¿µ±¸ ¶Ç´Â ¾È¿¡ mysql - - mysql auto close connection MySQLÀ» ÀÚµ¿À¸·Î ÁÖº¯ ¿¬°á - - php.ini + mysql persistent connection php.ini ÆÄÀÏ + mysqlÀ» ¿µ±¸ÀûÀÎ Á¢¼Ó - - MySQL PHP persistant connection MySQLÀº PHP´Â ¿µ±¸ÀûÀÎ Á¢¼Ó - - Your applications are not closing MySQL connections properly MySQLÀ» ¿¬°áÇÏ¿© ÀÀ¿ë ÇÁ·Î±×·¥À» Á¦´ë·Î º¯·ÐÇÏÁö ¾Ê½À´Ï´Ù - - wordpress connection pool WordPressÀÇ ¿¬°á ¼ö¿µÀå - - mysql wordpress Microsoft MySQLÀº ¸¶ÀÌÅ©·Î ¼ÒÇÁÆ® ¿öµå - - wordpress mysql_pconnect mysql_pconnect ¿öµå - - mysql php persistent connections MySQLÀº PHP´Â ¿µ±¸ÀûÀÎ Á¢¼Ó - - MySQL Persistent Connections PHP MySQLÀº ¿µ±¸ÀûÀÎ Á¢¼ÓÀº PHP - - php mysql wordpress PHP°¡ MySQLÀ» WordPressÀÇ - - properly close mysql connections MySQLÀÇ ¿¬°áÀÌ Á¦´ë·Î ´Ý½À´Ï´Ù - - how to integrate friend connect using php Ä£±¸¸¦ ÅëÇÕÇÏ´Â ¹æ¹ý PHP¸¦ »ç¿ëÇÏ¿© ¿¬°á - - how to integrate friends connect in php Ä£±¸¸¦ ÅëÇÕÇÏ´Â ¹æ¹ýÀº PHP¿¡ ¿¬°á - - persistent connections php ¿µ±¸ÀûÀÎ Á¢¼ÓÀº PHP - - disable persistent connections mysql ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» ÇØÁ¦¿¡ mysql - - dynamic wordpress page using mysql table MySQLÀÇ Å×À̺íÀ» »ç¿ëÇÏ¿© µ¿Àû WordPressÀÇ ÆäÀÌÁö - - mysql faster db access with persistent connection ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» °¡Áø DB¸¦ MySQLÀÇ ºü¸¥ ¾×¼¼½º - - mysql persistent connections with php PHP·Î °è¼Ó MySQLÀ» ¿µ±¸ÀûÀÎ Á¢¼Ó - - Not closing the database connection properly, PHP Á¦´ë·Î µ¥ÀÌÅͺ£À̽º ¿¬°áÀ» ´Ý´Â, PHP´Â - - persistent connection to MySQL +php MySQL¿¡ Áö¼Ó Á¢¼Ó + PHP´Â - - php mysql persistent connections not working PHP°¡ MySQLÀ» ¿µ±¸ÀûÀÎ Á¢¼ÓÀ¸·Î ÀÛµ¿ÇÏÁö - - ) or mysql_connect( ) ¶Ç´Â mysql_connect ( - - how to open multiple connection in mysql + php MySQL¿¡ ¿©·¯ °³ÀÇ ¿¬°áÇÏ´Â ¹æ¹ýÀ» ¿­°í + PHP´Â - - integrate WordPress with MySQL MySQL°ú ¿¬µ¿ÇÏ¿© WordPressÀÇ ÅëÇÕ - - mysql_connect persistence connection mysql_connect Áö¼Ó¼º ¿¬°á - - optimizing mysql_pconnect mysql_pconnect ÃÖÀûÈ­ - - persistence wordpress style switcher ²ö±â WordPressÀÇ ½ºÅ¸ÀÏ ½ºÀ§Ã³ - - php open and close mysql persistent connections PHP¸¦ ¿­°í ´Ý´Â mysqlÀ» ¿µ±¸ÀûÀÎ Á¢¼Ó - -