Using PHP-MySQL Persistent Connections to Run WordPress Blog Menggunakan PHP-MySQL Koneksi Persistent untuk Jalankan Wordpress Blog
When connecting to MySQL database, WordPress weblog based on PHP scripting will use non-persistent connection by default. Ketika melakukan koneksi ke database MySQL, WordPress weblog didasarkan pada skrip PHP akan menggunakan non-persistent sambungan secara default. 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. Itu adalah, WordPress akan memicu PHP untuk membuat koneksi baru ke server MySQL untuk setiap permintaan halaman dinamis, dan kemudian menutup koneksi database setelah membangun halaman web selesai. Repetitive opening and closing of MySQL connections causes overheads and uses up precious CPU, memory and system resources on the web host. Berulang membuka dan menutup koneksi MySQL menyebabkan overhead dan berharga akan menggunakan CPU, memori dan sumber daya sistem di web host.
Using persistent connection to connect to MySQL database server is not always a good option. Menggunakan koneksi terus-menerus untuk melakukan koneksi ke database MySQL tidak selalu merupakan pilihan yang baik. 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. Setiap sambungan mengambil sumber daya, termasuk memori, buffer, tabel atau benang cache internal di MySQL dan soket, IO membuka file atau aktivitas pada tingkat OS. 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. Dengan demikian, ketika banyak koneksi persisten dibuka tetapi tidak ditutup setelah transaksi selesai, sumber daya sistem dapat mengalir ke atas dan menurunkan kinerja dari web server, atau dalam kasus terburuk, menyebabkan kegagalan 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. Lebih jauh lagi, jika koneksi yang gigih terhenti, tidak aktif atau menjadi tidak berfungsi atau tidak lagi digunakan, tidak diakhiri, dan server MySQL hanya akan menutupnya untuk melepaskan sumber daya yang diduduki oleh koneksi setelah kira-kira 28.800 detik (8 jam) secara default kecuali mengubah parameter timeout di file konfigurasi 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. Beberapa faktor ini dapat membawa masalah seperti MySQL menolak DB baru atau lambat koneksi server jika aplikasi tidak benar menangani koneksi persistent. Thus if you're not experience webmasters, please do not attempt to change Wordpress to use persistent connections. Jadi jika Anda tidak mengalami webmaster, tolong jangan berusaha untuk mengubah Wordpress untuk menggunakan koneksi persistent.
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. Namun, bagi blogger yang punya blog sibuk dan besar, dan menghadapi kendala dalam meng-upgrade sistem hosting spesifikasi, dan tidak ingin menggunakan plugin cache halaman statis seperti WP-Cache, koneksi persisten adalah pilihan tersedia untuk menyempurnakan dan mengoptimalkan web server untuk melihat apakah halaman web yang dapat melayani lebih cepat. Persistent connection allows connection to be open once and will not be closed when the execution of the script ends. Koneksi persistent memungkinkan sambungan untuk terbuka sekali dan tidak akan terputus jika eksekusi script berakhir. Instead, the link is kept in pool and will remain open for future use. Sebagai gantinya, link disimpan di kolam renang dan akan tetap terbuka untuk penggunaan masa depan. Thus, using persistent connections will eliminate the process of opening and closing the connection. Jadi, dengan menggunakan koneksi yang terus-menerus akan menghilangkan proses membuka dan menutup koneksi. 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. Hal ini secara tidak langsung akan mengurangi koneksi MySQL server terkait overhead seperti otentikasi untuk membuat sambungan mana yang diperlukan hanya sekali, tabungan ekstra lalu lintas jaringan, dan sumber daya yang digunakan untuk menangani koneksi ekstra. 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. Samping, mungkin ada beberapa tingkat koneksi cache, yang perlu diisi untuk kinerja yang tepat, dan berpotensi mengurangi jumlah koneksi ke database.
By default, WordPress is using mysql_connect() function that establishes a new database connection on every page. Secara default, Wordpress adalah menggunakan mysql_connect () fungsi yang menetapkan koneksi database baru pada setiap halaman. 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. Fitur koneksi yang terus-menerus akan membutuhkan mysql_pconnect () fungsi yang menggunakan API yang sama persis, tetapi memiliki koneksi built-in penggabungan untuk menjaga hubungan hidup antara permintaan. So to switch to use persistent connection to run WordPress, the mysql_connect() function has to be replaced with mysql_pconnect(). Jadi untuk beralih menggunakan koneksi yang terus-menerus untuk menjalankan Wordpress, para mysql_connect () fungsi harus diganti dengan 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. Untuk mengaktifkan dan menggunakan koneksi persistent dengan Wordpress, cukup login ke host web Anda dengan SSH (atau tidak aman Telnet), dan perubahan ke webroot direktori home di mana blog Wordpress diinstal. Then change directory into wp-includes directory. Kemudian mengubah direktori ke direktori wp-includes. Inside the wp-includes directory, there is wp-db.php file. Di dalam direktori wp-includes, ada file wp-db.php. Use any text editor such as vi to edit wp-db.php. Gunakan editor teks seperti vi untuk mengedit wp-db.php. Search or locate the function of mysql_connect (or @mysql_connect ). Cari atau menemukan fungsi mysql_connect (atau @ mysql_connect). There is only one instance of mysql_connect. Hanya ada satu contoh mysql_connect. Just change the mysql_connect to mysql_pconnect , then save and exit the wp-db.php. Hanya mengubah mysql_connect untuk mysql_pconnect, kemudian simpan dan keluarlah dari 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 dan PHP (selama anda tidak mematikan mysql.allow_persistent dalam php.ini) akan segera menggunakan koneksi gigih untuk koneksi ke database MySQL. It's worth to try out which setting is best for your environment. It's worth untuk mencoba pengaturan yang terbaik bagi lingkungan Anda.
IMPORTANT : The page is machine translated and provided "as is" without warranty. PENTING: Halaman ini adalah mesin diterjemahkan dan diberikan "sebagaimana adanya" tanpa jaminan. Machine translation may be difficult to understand. Terjemahan mesin mungkin sulit untuk mengerti. Please refer to Silakan merujuk ke original English article artikel asli bahasa Inggris whenever possible. bila memungkinkan.
Related Articles Artikel Terkait
- How to Move WordPress Blog to New Domain or Location Bagaimana Wordpress Blog Pindah ke New Domain atau Lokasi
- WordPress MySQL SQL Query Error in WPDB Class Wordpress MySQL Query SQL WPDB Kesalahan dalam Kelas
- Moderate WordPress Blog Comments Via Moderator with Desktop Client Moderat Wordpress Blog Komentar Via Moderator dengan Klien Desktop
- How to Customize, Modify or Change WordPress Database Connection Error Page Cara Customize, Memodifikasi atau Ubah Wordpress Koneksi Database Error Page
- Replace Google Blog Search with Technorati for Incoming Links in Dashboard of WordPress Ganti Google Blog Search dengan Technorati untuk Incoming Links di Dashboard dari Wordpress
- WLWManifest Disabler Plugin to Remove XLM Link in WordPress Blog Header Plugin untuk WLWManifest Disabler Hapus XLM Link di Wordpress Blog Header
- AdSense and Display Banner Ads Rotation in WordPress Blog or Websites AdSense dan Tampilan Iklan Banner Rotasi di Wordpress Blog atau Website
- Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template Mengintegrasikan dan Tampilan Google AdSense untuk Pencarian dan Co-Op Custom Search Engine Hasil di Wordpress Blog Page Template
- Change and Reset MySQL root Password Perubahan dan Reset MySQL root Password
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working Wordpress Paginating atau Split Post atau Page dengan Nextpage di Wordpress Not Working










































September 23rd, 2009 14:37 23 September 2009 14:37
Thanks a lot.I really do not know about the function mysql_pconnect().Will going to implement it practically soon. Thanks a lot.I benar-benar tidak tahu tentang fungsi mysql_pconnect (). Apakah akan mengimplementasikan praktis segera.
November 22nd, 2008 10:20 22 November 2008 10:20
THANK YOU SO MUCH! THANK YOU SO MUCH!
WordPress is running so much faster now! Wordpress adalah berlari begitu jauh lebih cepat sekarang!
I am running all on Windows Server 2008 with: Saya menjalankan semua pada Windows Server 2008 dengan:
- MySQL Server v5.0 x64 (on dedicated server) - MySQL Server v5.0 x64 (di server)
- IIS7 with FastCGI z32 (on dedicated server) - IIS7 dengan FastCGI z32 (di server)
Regards, Salam,
raja raja
September 27th, 2007 22:14 27 September 2007 22:14
This seemed to do the trick for. Ini sepertinya melakukan trik untuk. Thanks so much for the info! Thanks so much for the info!