Website Performance Tuning and Optimization

German   Spanish   French   Dutch   Italian   Russian
  How can I make my application (website) run faster as a whole ? Although your hosting provider may offer you to upgrade hosting package or replace server parts, the latest hardware is often not the solution to website performance problems. We can help you to find answer(s) to this question.

  As a quick proof of our skills you can download demo version of Esvon Classifieds with many modules. Have a quick look and let us know if you will find anything worth a critical remark.
We carefully designed Esvon Classifieds and used the best known to us programming methodologies to make it solid and very fast application.

  It was noticed that after medium or extensive functionality customization probably by junior developer web application can run slower bringing server to knees and eating up to 100% of CPU time or RAM. In most cases the conclusion is simple: always hire experienced professionals for custom programming services if you have real plans for your website. Such developers will take into account many different coding aspects including general website performance and database architecture.

  If you have similar issues, you'll have to address them sooner or later. First question before doing anything, is this server dedicated to your website or other websites are hosted as well and they could cause server performance problems ? If you are sure that your website causes this, PHP code audit and MySQL database structure / SQL queries optimization can help. As it was mentioned, certain custom programming changes could affect overall performance and slow down website when traffic increases occur.

  How can we help ? We can perform performance audit to find possible bottlenecks (tune the slowest SQL queries, eliminate unnecessary SQL queries, create missing or remove redundant table indexes, optimize CPU intensive PHP code, etc) and make the necessary database structure / PHP code changes to ensure the software works as fast as possible. We should be able to find out the changes required to speed up the website as a whole and give you a quote on these changes before doing them. If you are interested in our services, please submit your request using Online HelpDesk here.

  If you have made efforts to boost the performance by optimizing your queries and your application code, we'd like to share some thoughts regarding PHP-based website performance optimization with you and really hope you will find something useful to think about and to make further research before making actual changes in your server environment.
  There are number of server-level and language-level tunings for high-traffic websites (OS, MySQL, hardware related) that you (or your host admin) can try to ensure that an application performs at its best, i.e. :

  1/ Use the latest stable PHP version.
As a major step ahead, PHP 5.3 version offered a significant performance gain over previous PHP versions. With each new version it becomes even better. Now you should have very specific reasons for running anything below PHP 5.4.

  2/ Use the latest possible MySQL / MariaDB.
There are enough things that run faster on recent MySQL versions (improved SQL query optimizer behaviour, query cache if enabled, full-text indexing, more efficient SQL syntax in some cases, etc), our software automatically uses some of them if they are available.

  3/ Client side - caching
All static content (HTML pages, images, etc) can be cached in the browser by Expires header and Cache-Control header for 30-45 days (look at "mod_expires" Apache module). Client-side cache can significantly improve the second visit, you'll get happy returning visitors and reduced bandwidth usage.

  4/ Use Content Compression.
It provides 30-50% bandwidth usage reduction and even small overall performance increase. You can consider using Apache module mod_deflate (for Apache 1.3.x) or mod_gzip.

  5/ MySQL tweaks.

  5a/ Query cache and buffer sizes.
Make sure MySQL query cache is enabled and has proper size (you can start with 4MB or 64MB depending on the RAM available, use "query_cache_size" parameter in my.cnf).
Pay attention to "key_buffer" and "table_cache" parameters, they are important and shouldn't be too small.
If RAM allows, make sure MyISAM key buffer size in MySQL ("key_buffer_size" option) is large enough to hold the indexes of your most actively used tables (calculate the total size of your .MYI files for the tables).

  5b/ InnoDB (selective).
This option is not for low end VPS, where InnoDB should be disabled to save memory.
In MySQL it is wise to change type of certain tables from MyISAM to InnoDB. MyISAM uses table-level blocking, InnoDB uses row-level blocking. Conversion to InnoDB is useful for tables which experience many SQL updates (i.e. more than 20% write to 80% reads, e.g., session, hits, accesslog tables). Don't forget to balance the amount of RAM between MyISAM and InnoDB because the buffers for each are configured separately.

  5c/ Disable MySQL DNS Hostname Lookup.
Add line "skip-name-resolve" in my.cnf, but you can only use IP numbers in the MySQL Grant table if you activate this option.

  6/ If you have database server and web server running on the same host, consider configuration from 2 independent servers for MySQL and Apache.

  7/ Use Nginx or Varnish for font-end.
Nginx (lightweight web server) or Varnish usage for front-end and Apache for back-end is very beneficial for heavily loaded servers. Static content is served very efficiently, reverse proxy for dynamic content allows to reduce memory consumption (RAM requirements) and overall server load. You can start thinking about this model if your server load exceeds 10 http-requests per second.
Serving static content with Apache and mod_php results in the expensive portions of the process being squandered for high-traffic environments.
Reverse proxy (Proxy Cache, HTTP accelerator) is an additional server that sits in between the end user and the PHP application to reduce PHP processes time. The proxy instance can simply run as a 2nd server instance on the same machine (or be on a dedicated machine).

  8/ TMPFS.
Consider TMPFS usage, virtual memory is much faster than a persistent storage device.

  9/ Web cluster usage.
It provides much better redundancy, capacity and load balancing compared to a single Web server. But web applications which run on a single Web server perfectly may need certain tuning to work as expected at a web cluster.

Sincere wishes
to outstanding website performance
------
The Esvon Team