This article describes the various stages involved in a web request, as well as optimization steps you can take to improve performance.
A DNS lookup is the process of converting a domain name (such as example.com) to an IP address (such as 188.8.131.52). For a web request, this means obtaining the IP address of the server that hosts the website for a given domain name.
Your browser starts a web request by querying its resolver where a domain name is. If the IP address is cached, the resolver returns the IP address immediately. If the IP address is not cached, or if the cache has expired (as determined by the TTL value in the domain's DNS zone), the resolver asks the root DNS servers for the IP address.
Using a reliable DNS server is essential for obtaining the quickest IP address resolution of a domain name. We recommmend you use A2 Hosting's name servers for your domain.
Additionally, setting the correct Time to Live (TTL) values for domain records in your DNS zone is a good way to ensure that DNS root servers do not constantly look up where your server is. The TTL value should be set to less than a day, but more than an hour.
A browser and a server must establish a connection before they can communicate with each other. This connection is known as a TCP handshake, which consists of a three-step process: SYN (synchronized), SYN-ACK (synchronized-acknowledgement), and ACK (acknowledgement). The browser sends a SYN, the server responds with a SYN-ACK, and the browser responds with an ACK. When this three-step process is finished, an Apache web server thread is assigned to the browser.
The best way to ensure a quicker connection time is to make sure that your server is located relatively close to your customer base. There are many packets traveling back and forth between the server and the browser, so if the physical distance between the browser and server is too great, the latency of each packet increases the connection time.
For example, if your customers are located in Europe, try to use a server located in Europe.
During an SSL handshake, the browser and server establish encrypted communication between each other using a multi-step process:
As with connection times, the best way to improve SSL performance is to strategically position the server close to your customer base. For example, if your customers are located in Europe, try to use a server located in Europe.
The browser generates a request to the server, which includes the URL, cookies, sessions, and headers that describe what forms of responses the browser will accept from the server. The browser also sends any form data, including file uploads. If SSL is used for the connection, the request is encrypted.
The server then sends confirmation that it has received the request.
To improve request time performance, you can:
Wait time is the time between the moment the server acknowledges the request, and the time that the browser receives the first byte which contains the start of the response headers from the server. This step includes script processing and database calls.
Some scripts return the response header before any processing or database calls; this is generally indicated by an extremely short wait time of less than 10 milliseconds. When headers are sent before content, the time that would normally be in the wait time is added to the receiving or download time.
You can make most improvements in wait time at the application level. How the page is rendered in the code and how the site runs database queries are the largest factors in improving performance.
If your site uses a popular CMS (content management system) like WordPress, Drupal, or Magento, make sure that you do not have any unnecessary plugins or extensions active on your site. On WordPress, for example, you can use the P3 Plugin Performance Profiler or GTMetrix tools to determine which plugins or theme extensions are slowing down your site. New Relic is another tool that you can use on any site to help Identify slow functions and database queries.
Regardless of your application's speed, the largest performance gain can be made by using a caching engine. Caching engines store a copy of the rendered HTML for each page on your site. They serve fresh content after a specified amount of time, or purge a cached copy of a page when the page has been modified. Remember that the first person to visit a page after a cache has expired may have a longer wait time while it serves the fresh content and saves a new copy for the cache.
Many CMS’s have plugins that can automatically cache a site's content:
This is the amount of time it takes a browser to download the content generated by the server. Remember that this value can be larger than expected if the server sends information immediately as it is generated, instead of generating all of the content and then sending it.
To improve performance, enable minification in your source files and use Gzip compression.
To use Gzip commpression, make sure that you are using the mod_deflate module.