I’m glad to notice that we’ve jut finished the tunning project to improve performance. So I want to share with you about our experiences in practice.
step 1. PROFILING
* detect standard time consumming for a basic requests.the simpest tool to realize this is firebugs, other good tool is xdebug + WinCacheGrind; with SQL queries you can set configuration at my.cnf to logs all slow log queries.
Other simple way is set judged point of time and echo consumming time like this
$t = time();
echo (time() - $t). "s functionX <br/>";
$t = time();
step 2. DETECT FOR BOTTLE NECK FUNCTIONS
follow the 80/20 rule, you dont need to focus all components, functions. find out the most important functions/features effect to performance of your system. After profiling system at step 1, maybe you got them.
* set a goalan acceptable response time for each actions.
step 3.IMPROVE SKILLS & KNOWLEDGES– business of systems: you should never start to tun until you undertand how your system is working .
– learn best practices for Speeding Up Your Web Site http://developer.yahoo.com/performance/rules.html
– study how to use these tools ( for client side optimization)
– data modelling : OLAP/OLTP, datawarehouse, best practices
– query optimization
– cache & noSQL system: is it need? which is the best choice for your system?
step 4. TUNING
* bottle neck functions– you should consider the algorithm to resolve it. So offcouse, you need smart man with good background to solve it effectively.
* client sidelet consider about these technicals:
– css sprite
– client cache (set header)
* data transfering:reduce time for data transfer from host to client, with host locating outside of country, it’s so important, let image: network dowload speed can be 15kb/s; and you have 1.5mb to display the page. after gzip, you need to download only about 300k! you save many times!
this can set by mod_deflate of apache setting.
* SQL optimizationthe most important factor for performance, almost time spent at server side is SQL queries. SQL optimization maybe is the most important skills to improve performance of web response.
– run explain query to understand why it’s slow.
– minimize fields selected in select query
– minimize number of table joined.
– check for indexes of tables
– change the way to query, devide it into some case for different condition, thinking about UNION, UNION ALL, LEFT OUTER JOIN, LEFT JOIN, INNER JOIN. You must understand the diffencies.
– material view ( depend on SQL engine, but mySQL ‘s not supported now)
– redesign db structure: reduce size of a field if we can
– db partitioning
– build sumary table
* Cache– pre-build data and set to cache layer.
– cache layer is the key factor for OLTP system, but not in an OLAP system. But I want to build it for realtime statistic in nearly future.
* Optimize server setting– MySQL setting
– Apache/web server setting
– PHP setting, enable opcode cache.
– OS tuning
I reserved these works for the system administrator =))
Improve performance of a system is not a easy mission for dreammers.
There’re many technical solutions to apply, we can learn them . But the key factor to tun it successfully is human resource. I’ve got good members, so we overcame! Thank you for your contribution in this project : Bùi Hữu Diệp, Lê Quốc Đạt, Ngô Tuấn Long, Phạm Lê Lợi, Nguyễn Đình Thức. And we – development team also want to say thank you to SQA team, nice girls!
This is reporting by Viet from Septeni.
Thank you and good bye!