Resolve slow loading website

Home > Search
  by

If your website is taking a long time to load, use a web browsers web Inspector to determine how long it is taking for your website to load. In this example, it took 10 seconds to get www.freekb.net. This is slow.


Web server

When attempting to determine the cause of latency, if the web server is on-site, it is best to create a new website with no custom code, using the default web server website. If possible, use a web browser on the same machine as the web server to spot latency.

In this example, a Linux HTTPD web server was able to load all resources in about 30 ms. This is very fast. It's important to recognize that the total size of the files is about 35 KB. Obviously, if there are more files, and the file sizes are larger, it will take longer to load the site. For this reason, it's important monitor the number of files and the size of the files as code changes are made to your site.

This shows that the web server can load the page very quickly, and the cause of the latency is not the web server.

If the web server is taking more than 1 second to load the site default web server website, there is some issue with the web server.

If the web server takes less than 1 second to load the default web server website, but your production web site takes more than 1 second to load, refer to the following common issues. If using MVC, refer to resolve MVC loading slow.

 


images / audio / video

Media files can cause the website to take a while to load, because media files can be large.

 


Database queries

The website may only be slow whem making database queries. In this example, when loading a page that makes a database query, it took just under 8 seconds for the page to load.


LAN

Once the total duration for the website to load is less than 1 second when using a web browser on the same machine as the web server, next use a web browser on a different machine in the same subnet as the web server (in the LAN). If the total duration is greater than 1 second, you may have a congested network or your network switch may not be optimized.

Be careful to not be fooled by false positives. In this example, it may appear that interface GE8 on the switch has some issue, since this interface is 100 Mbps. However, if the server is connected to GE1 and the client is connected to GE2, GE8 would have nothing to do with the latency. 

 


WAN

Use a PC that is not in the same subnet as the web server. For example, use a PC in the same city as the web server, but not in the same network as the web server. Recall that it took about 30 ms to load the site in the LAN. In this example, when using the WAN, the site took about 1 second to load. It will take longer for the site to load over the WAN. However, 1 second is totally acceptable.

 

Use the tracert command to determine the number of hops between the client computer and web server. In this example, there are 8 hops from the client to the web server.

PS > tracert www.freekb.net
1    2ms   2ms   1ms  192.168.0.1
2   11ms  10ms  13ms  x.x.x.x
3  867ms  29ms  29ms  x.x.x.x
4   18ms  15ms  16ms  x.x.x.x
5   25ms  26ms  23ms  x.x.x.x
6   37ms  34ms  42ms  x.x.x.x
7   22ms  20ms  20ms  x.x.x.x
8   35ms  34ms  34ms  x.x.x.x

 

One solution would be to run the application on a web server that has less hops between the client and the web server. This is a reasonable solution if we know all of the clients are isolated to a certain geographic region. For example, if the clients are in Wisconsin, we could point local.freekb.net to a web server in Wisconsin, and then use the Web Inspector to see if the latency is reduced. In this example, it is only taking 89 milliseconds to get local.freekb.net.

If you are not able to predict where the clients are located geographically, determine the geographic location of the web server. The last IP address in the tracert command should be the IP address of the web server. Use http://whatismyipaddress.com/ip-lookup to determine the geographic location of the web server. Let's say the client computer is in Wisconsin USA and the web server is in Arizona USA. In the example, the data packets must travel just under 2,000 miles from the web server to the client PC. This distance would produce some latency.


Shared server vs. Dedicated server

If it is taking a long time to get index.html, the web server being used may be a shared server hosting many different web applications. You will need to contact your hosting provider to know if you are using a shared server. If you are using a shared server, moving to a dedicated server should reduce latency. However, a dedicated server is much more expensive than a shared server. For example, a Go Daddy shared server starts at $3.99 per month, and a Go Daddy dedicated server starts at $79.99 per month (https://www.godaddy.com/pro/dedicated-server). A dedicated server would cost you nearly $1,000 per year. At that price, it would probably be more cost effective to rent a very fast ISP connection and run your own server out of your house or business.

 


ISP download speed

Determine the download speed between the client and server. Go to www.speedtest.net to determine the download speed. Let's say the download speed is 6 Mbps (Mega bits per second).



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments