The following are the points that I picked up from an on-line course. Writing them here for reference to keep in mind while optimizing PHP websites:
- Choose the right version of PHP either use PHP7 or use HHVM.
- XHProf is a PHP profiling tool, similar to what you do with Xdebug.
- Query optimizing using Redis.
Cache Aside pattern.
Syncs data to disk so when system goes down, your data can be recovered
Has advanced data structures
Has a master slave configuration.
PHP has a redis extension : you can download it and then make install it.
- Nginx is better than Apache:Because of ease of configuration, optimized for static content, flexibility, knowledge applies across many stacks.If you use apache make sure you are using the modern setup of Apache which uses PHP-FPM and mpm_event.Configuring Nginx :
tcp_nopush : send only complete packets
sendfile if you want to server the file directly
tcp_nodelay: there is a algorithm, which waits for 200ms before a packet is sent to the network, this removes that.
access_log : write only when traffic is low, but using a flush setting
nginx -t will test if the file is ok and contains no errors.
1. max_children = (MAX_MEMORY – 500mb) / 20mb
2. max_process = 10% of children
5. Database Optimizations:
max_connections = max_children in nginx * processes
buffer pool size = 90% of the server(dedicated)
io_capacity : check how much can be handled easily and then set it.
remove query cache limit if you are one a single server that is doing the read and write, keep it if the server is only doing read
Enable slow query log.
Denormalization: you can bring in frequently joined data into the table itself and to maintain the same values on both the tables make use of referential integrity. Eg. If there is a product table and categories table, add the category name to the product table itself and use references to keep data in product table relevant.
6. Load testing:
You can use a command line tool called siege to make concurrent user requests.
Application Performance Monitoring : statsD and graphite , whisper, influx and cynite6
Please comment with your real name using good manners.