Using PHP-MySQL Persistent Connections to Run WordPress Blog שימוש ב-MySQL PHP Persistent Connections כדי הפעלה בלוג WordPress
When connecting to MySQL database, WordPress weblog based on PHP scripting will use non-persistent connection by default. בעת חיבור אל מסד הנתונים MySQL, WordPress weblog מבוסס על PHP scripting ישתמש ללא חיבור מתמיד כברירת מחדל. 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. כלומר, וורדפרס יפעילו 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 גורם תקורה ומשתמש את המעבד היקר, הזיכרון ואת משאבי המערכת במחשב המארח של האינטרנט.
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 ו ארובות, או לפתוח קבצים IO פעילות ברמת מערכת ההפעלה. 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 רק לסגור אותה כדי לשחרר את המשאב שנכבשו על ידי החיבור לאחר כ 28800 שניות (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 DB מסרב קשרים חדשים או שרת איטי אם היישומים לא טיפלו כראוי קשרים מתמיד. Thus if you're not experience webmasters, please do not attempt to change Wordpress to use persistent connections. לכן, אם אתה לא Webmasters ניסיון, בבקשה אל תנסו לשנות 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. עם זאת, עבור בלוגרים שיש להם בלוג עסוק גדול, מול האילוצים שדרוג מערכת האינטרנט המארח מפרטים, ואת לא רוצה להשתמש דף סטטי במטמון תוסף כגון WP-cache, חיבור מתמיד הוא אפשרות כניסה כדי לכוון ולבצע אופטימיזציה של שרת אינטרנט כדי לראות אם ניתן שירות אינטרנט מהיר. 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. כברירת מחדל, וורדפרס היא בעזרת mysql_connect () function כי חיבור מסד נתונים חדש בכל עמוד. 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 () פונקציית ה-API שבו משתמש בדיוק, אבל יש חיבור מובנה איחוד לשמור על קשרים חי בין בקשות. So to switch to use persistent connection to run WordPress, the mysql_connect() function has to be replaced with mysql_pconnect(). אז כדי לעבור להשתמש חיבור מתמיד לרוץ וורדפרס, את mysql_connect () function יש להחליף עם 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 (או Telnet ביטחון), ולשנות לספרייה הביתה Webroot שם בלוג WordPress מותקן. Then change directory into wp-includes directory. ואז לשנות את wp-המדריך כולל המדריך. Inside the wp-includes directory, there is wp-db.php file. בתוך wp-כולל ספרייה, יש קובץ wp-db.php. Use any text editor such as vi to edit wp-db.php. השתמש בעורך טקסט כלשהו כגון השישי כדי לערוך 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_connect mysql_pconnect, ואז לשמור ולצאת wp-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 : The page is machine translated and provided "as is" without warranty. חשוב: הדף מכונת תירגם מתפרסם "כמות שהוא" ללא אחריות. Machine translation may be difficult to understand. תרגום מכונה יכול להיות קשה להבין. Please refer to נא עיין original English article המאמר המקורי באנגלית whenever possible. בכל הזדמנות אפשרית.
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 Class
- Moderate WordPress Blog Comments Via Moderator with Desktop Client מתונה בלוג WordPress תגובות באמצעות מנחה שולחני עם הלקוחות
- How to Customize, Modify or Change WordPress Database Connection Error Page כיצד להתאים אישית, שינוי או שינוי וורדפרס חיבור מסד דף שגיאה
- Replace Google Blog Search with Technorati for Incoming Links in Dashboard of WordPress החלף עם Google Blog Search Technorati עבור Incoming Links שבלוח המחוונים של וורדפרס
- WLWManifest Disabler Plugin to Remove XLM Link in WordPress Blog Header WLWManifest Disabler תוסף להסיר קישור xlm ב בלוג WordPress כותרת
- AdSense and Display Banner Ads Rotation in WordPress Blog or Websites AdSense ו-הצגת מודעות באנר סיבוב ב אתרי אינטרנט או בלוג WordPress
- Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template שלב הצגת Google AdSense לחיפוש ו Co-op תוצאות מנוע החיפוש המותאם אישית של בלוג WordPress תבנית
- Change and Reset MySQL root Password שינוי סיסמה איפוס שורש MySQL
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working Paginating או פיצול וורדפרס פוסט או עמוד עם NextPage ב-WordPress לא תקין










































September 23rd, 2009 14:37 23 ספטמבר 2009 14:37
Thanks a lot.I really do not know about the function mysql_pconnect().Will going to implement it practically soon. תודה lot.I באמת לא יודע על הפונקציה mysql_pconnect (). האם הולך ליישם אותו ממש בקרוב.
November 22nd, 2008 10:20 22 נובמבר 2008 10:20
THANK YOU SO MUCH! תודה רבה!
WordPress is running so much faster now! וורדפרס הוא רץ כל כך הרבה יותר מהר עכשיו!
I am running all on Windows Server 2008 with: אני מפעיל את כל Windows Server 2008 עם:
- MySQL Server v5.0 x64 (on dedicated server) - MySQL Server V5.0 x64 (בשרת ייעודי)
- IIS7 with FastCGI z32 (on dedicated server) - IIS7 עם FastCGI z32 (בשרת ייעודי)
Regards, דרישת שלום,
raja ראג 'ה
September 27th, 2007 22:14 27 ספטמבר 2007 22:14
This seemed to do the trick for. זה נראה בשביל לעשות את הטריק. Thanks so much for the info! תודה רבה על מידע!