stretchr
stretchr

Reputation: 615

When I key in a URL, why does the webpage take a long time to load on my mobile phone's browser?

I would like to construct an answer that is very detailed in preparation for software engineering interviews and also to really understand what happens 'under the hood'.

What I have right now is:

When you key in the url, there is a TCP handshake that occurs between one's browser and the server. Once connection is established, the request for the webpage is routed to a server via a loadbalancer in the data centre. That particular server will return the webpage to the browser, which renders it for display based on DOM rules specified in the webpage. Hence, the speed of connection is affected by: 1) Location of data centre 2) Routing algorithm used by the load balancer 3) Time taken for the server that contains the webpage to clear the requests sent its way

This is an answer I gave in an interview, which was deemed insufficient. I understand it's probably rudimentary and am on a determined path to understanding as much as possible about this process. Please can someone shed good light on this question?

Upvotes: 1

Views: 140

Answers (1)

karns
karns

Reputation: 5887

I think you might be overanalyzing it. A webpage that takes long to load on a browser will take long to load on mobile and most of the time vice versa.

Resource sizes (images, html, CSS, JS, etc...) take much much more time to load than the TCP handshakes, DNS, data center location, etc..

Also, you might want to specify more details - is it any old webpage? Is it a webpage that is hosted by a server with lack of resources such as CPU power? Is the database being hit too strongly, this impacting performance?

To expand upon that notion:

http://www.pcworld.com/article/2038500/why-some-web-sites-are-much-slower-than-others.html

In my opinion, from most likely candidates to least:

  • Internet speed
  • Page size (use Chromes Dev tools to inspect what resources take what time to load) and whether or not developer knew what he/she was doing (selector efficiency in CSS, JS, etc..)
  • Server Power/database power
  • Various Networking Intricacies (DNS, server location, TCP handshakes, etc..)

I'm sure I'm missing some , but I will add to this list as I go.

Upvotes: 1

Related Questions