Optimizing PHP Code
View Single Post
11-15-2007, 01:11 AM
Join Date: Nov 2007
One of the first steps is to optimize your database. Check the schema, add index's when needed, check your queries, etc. Also choosing the correct table type can help a lot. Watch out for locked tables / rows. Or COUNT(*) on IonnoDB tables... They can kill apps.
Another one is to make sure you're caching data you need to cache. Example would be, besides HTML pages, if you generate thumbnails or other graphics with PHP, to cache and save those (honestly, when does a thumbnail change all by itself?)
Also, look at how your system/core php files are designed.
Are you using multiple require / include statements that aren't needed? Are your include files excessively large? Could they be split into smaller more specific tools / packages ?
I mention this because everytime you need to require a file, it server must then read disk. Which doesnt seem so bad... but increase traffic and average hit per page... I've seen some sites/pages have up to 15 - 25 includes get bombed.
Just little tid bits to look out for...
Oh, and also, the point about the file size of PHP scripts... PHP is an interpreted language, which means if you can get it done in less code, get it done. So having excessive unneeded code for PHP to compile and process slows down the page.
Last edited by dschreck : 11-15-2007 at
. Reason: Added additional explaination
View Public Profile
Send a private message to dschreck
Visit dschreck's homepage!
Find More Posts by dschreck