Terms: 1 dedicated server /VPS/VDS + PHP + MYSQL
Target: Fasten server’s speed in 10-50 times minimum
Here is the list below, what should be paid attention at while server optimization.
There is no sense to start everything at once, it depends on concrete situation and its bottleneck.
- Diagnosis, monitoring and profiling
- munin
- disks: df -h, iotop, mpstat, iostat, sar, lsof, smartctl
- processes/data store: ps aux, top, htop, vmstat, pstree, strace, watch, free -m, lsmod
- network: tcpdump, netstat, iptraf
- OS optimization and general tips.
- if logs aren’t necessary, it’s better turn it off.
- FS: XFS for fast reding and big files, ext3/4 – universal
- FS formation : relatime(or noatime), async
- checking stability and operability dns resolve, jump to 8.8.8.8 and 8.8.4.4
- Web-server frontend Nginx
- check worker_processes, worker_connections, %events_module% (kqueue – freebsd, epoll – linux), worker_priority
- unix sockets instead of IP sockets
- 304 http headers at all statistics, for a month: expires 30d
- gzip on
- gzip_static on (ngx_http_gzip_static_module); «for i in `find ./* -type f -name ‘*.js’`; do echo $i; gzip -c -9 $i > $i.gz; done;»
- turn off statistics logs: access_log off
- try_files instead of «if (… !-f)»
- fastcgi_cache
- aio on – suport of acynchronous IO in nginx, in details
- sendfile on – if without aio
- open_file_cache
- timer_resolution 100ms – reduces the frequency of the call timer function
- Web-server backend PHP-FPMÂ (forget about apach (httpd) forever)
- php-accelarators (opcode randomizing): apc or xcache
- communication with front-end through the unix-socket
- MySQL database server at config level and log analysis:
- analysis of the variables of the serverstatistics (tuning-primer.sh, mysqltuner, sometimes phpMyAdmin)
- profiling slow queries (one can with mysqlsla)
- caching of SQL-queries on the database level
- raising the limits on file handlers into the OS, it is necessary to optimize the temporary tables in virtual memory
- raising the limits on connection to the database server
- expansion / Fit buffer memory for running software / data
application-level:
- addition of conventional, multi-columned index, and FORCE INDEX in problem table
- waiver / review request with wildcard-characters and the reduction of full scans
- the use of DELAYED queries, multi (batch) insert / updates, statements
- possible instead to use php-mysql php-mysqli in a compartment with mysqlnd
basic tips for working with mysql
- Applications’ optimization
- use  APC var-caching, or (worse) memcached / redis / nosql …
- analysis and refinement of queries to the database
- replacement of full-time service outside the application. For example, replacing the standard search function on SphinxSearch
- reduce http requests to the web server, http union loanedresources, sometimes CSS sprites




