Two MySQL tuner scripts
MySQLTuner (Perl) and MySQL Performance Tuning Primer (Shell) are two scripts that can help diagnose MySQL database performance issues, and provide recommendations on how to solve them. While both scripts output similar information, the diagnosis can be slightly different with each script, so I like to use both. Below are directions on how to use them, as well as a few screenshots.
# Download MySQLTuner and MySQL Performance Tuning Primer to ~/scripts. # To avoid having to invoke Perl/SH each time, make both files executable. chmod +x ~/scripts/mysqltuner.pl chmod +x ~/scripts/tuning-primer.sh # After that, give them a go! ~/scripts/mysqltuner.pl ~/scripts/tuning-primer.sh
Configure Apache, PHP, and MySQL for performance
Make sure that your configuration files are setup correctly for your server, application, and load. Enough said?
- A HOWTO on Optimizing PHP with tips and methodologies
- HOWTO: Basic Apache performance tuning (httpd)
- HOWTO: Basic MySQL performance tuning (MySQLd)
- Tuning LAMP systems, Part 2: Optimizing Apache and PHP
- Optimize your Apache VPS for WordPress
Best Practices
Did you know that incrementing a class variable is three times slower than incrementing a local variable? Did you know adding LIMIT 1 to SQL queries for a single row can speed up queries? Simply changing the way you write code can speed things up considerably.
- 63+ best practice to optimize PHP code performance
- Let’s make the web faster – Google Code
- Top 20+ MySQL Best Practices | Nettuts
- Best Practices for Speeding Up Your Web Site
Get a PHP opcode cache
PHP is an interpreted language, and as such it must be “compiled” into a readable format called opcode. An opcode cache basically preserves the compiled data, and allows us to essentially skip a step. This can save much needed resources (CPU, memory, etc.), and lower load time considerably.
Just a quick correction – Zend Optimizer is a loader for Zend Guard encoded scripts. It also does some runtime optimizations, but is not an opcode cache.
Zend Optimizer+ (note the “+”) is an opcode cache and is available as part of Zend Server and Zend Server CE (both of which contain other technologies for optimizing performance).
Thanks David! I made that correction within the article.
APC, a very good opcode cacher, will come standard with PHP 6 onwards. So, I highly recommend using APC from the get go.