Optimaliseren highLoad server

network-server-overloadPerformance issues is een probleem voor elke systeembeheerder. Hieronder staan wat handige tips om een web cluster te optimaliseren in Linux. Hier wordt een cluster met websites en mysql bedoeld.

Elke website is uniek en heeft zijn eigen bottlenecks. Hieronder staan tips, echter er is geen garantie dat je website sneller wordt.

  • 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 optimaliseren en algemene tips.
    • Als je bepaalde logs niet echt nodig hebt, zet ze dan uit. Bij drukke servers kan een logfile snel vol raken en het kost processor en hardisk kracht om logfiles te genereren en op te slaan.
    • FS: XFS for fast reding and big files, ext3/4 – universal
    • FS formation : relatime(or noatime), async
    • Zorg voor snelle DNS servers en dat de DNS server goed werken. Ook het hosts bestand moet kloppen met de eigen hostname bij het eigen ip-adres.
  • 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

     

  • Applicaties optimaliseren
    • 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

Laat een reactie achter

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *