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 ³» µðÁöÅÐ »ýȰ Æ÷·³ .
Related Articles °ü·Ã ±â»ç
- How to Move WordPress Blog to New Domain or Location »õ µµ¸ÞÀÎ ¶Ç´Â À§Ä¡¸¦ WordPressÀÇ ºí·Î±×¸¦ ¾î¶»°Ô À̵¿ÇÕ´Ï´Ù
- WordPress MySQL SQL Query Error in WPDB Class WordPressÀÇ MySQLÀº SQL Äõ¸® ¿À·ù WPDB¿¡¼ ¼ö¾÷
- AdSense and Display Banner Ads Rotation in WordPress Blog or Websites ¾Öµå ¼¾½º¿Í WordPressÀÇ ºí·Î±× ¶Ç´Â À¥»çÀÌÆ®¿¡ Ç¥½ÃµÇ´Â ¹è³Ê ±¤°í ·ÎÅ×À̼Ç
- Moderate WordPress Blog Comments Via Moderator with Desktop Client WordPressÀÇ ºí·Î±×¿¡ µ¡±ÛÀ» ÅëÇØ ¿Â°Ç ¿î¿µÀÚ µ¥½ºÅ©Åé Ŭ¶óÀÌ¾ðÆ®¿Í
- WLWManifest Disabler Plugin to Remove XLM Link in WordPress Blog Header WordPressÀÇ ºí·Î±× Çì´õ¿¡ WLWManifest Disabler Ç÷¯±×ÀÎÀ»Çϸé XLM ¸µÅ© Á¦°Å
- Replace Google Blog Search with Technorati for Incoming Links in Dashboard of WordPress ¹Ù²Ù±â Google ºí·Î±× °Ë»ö Technorati´Â ÇÔ²² µé¾î¿À´Â ¸µÅ©¿¡ ´ëÇÑ '´ë½Ãº¸µå'¿öµåÀÇ
- Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template WordPressÀÇ ºí·Î±× ÆäÀÌÁö¿¡ ÅëÇÕ °Ë»ö ¹× Çù·ÂÀ»À§ÇÑ µð½ºÇ÷¹ÀÌ Google ¾Öµå ¼¾½º - opÀÇ »ç¿ëÀÚ Á¤ÀÇ °Ë»ö ¿£Áø °á°ú ÅÛÇø´
- Publish Blog with Windows Live Writer Offline Blog Editor Tool ºí·Î±× °Ô½Ã ¿ÀÇÁ¶óÀÎ ºí·Î±× ÆíÁý±â µµ±¸¿Í ÇÔ²² À©µµ¿ì ¶óÀÌºê ¶óÀÌÅÍ
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working WordPressÀÇ Paginating ¶Ç´Â ½ºÇø´ Æ÷½ºÆ® ¶Ç´Â ÆäÀÌÁö Nextpage ÇÔ²² ¿öµå¿¡ ¾È µÊ
- Limit Maximum TCP Connections to Web Servers Çѵµ´Â ÃÖ´ë TCP ¿¬°áÀ» À¥ ¼¹ö¿¡

































September 27th, 2007 22:14 9 ¿ù 27 ÀÏ 2007 22:14
This seemed to do the trick for. ÀÌ Æ®¸¯À» ÇÒ °ÍÀ¸·Î º¸ÀδÙ. Thanks so much for the info! Á¤º¸°¡ ³Ê¹« ¸¹ÀÌ Áּż °¨»çÇÕ´Ï´Ù!