how does one identify why a website is slow? [closed]
Asked Answered
R

9

22

I was asked this question once at an interview:

"Suppose you own a website where the server is at some remote location. One day, some user calls/emails you saying the site is abominably slow. How would you identify why the site is slow? Also, when you check the website yourself as any user would (using your browser), the site behaves just fine."

I could think of only one thing (which was shot down):

  • Check the server logs to analyse incoming traffic. Maybe a DoS attack or exceptionally high traffic. Interviewer told me to assume the server has normal traffic and no DoS.

I was kind of lost because I had never thought of this problem. I have almost no idea how running a server/website works. So if someone could highlight a few approaches, it would be nice.

While googling around, I could find only this relevant, wonderful article. That article is kind of too technical for me now, but I'm slowly breaking it down and understanding it.

Realty answered 27/3, 2013 at 5:36 Comment(7)
If you have access to server logs you can analyze that, if not, then it is not your problem ;p I would have asked the interviewer to clarify the situation and exactly how much access you have to server, say to run ssh and then top.Maniacal
@leppie, How would top help? I'm sorry, my original question omitted a crucial detail. Please look at the edited interview question.Realty
You can use it to see if there are cpu, memory, load, etc issues.Maniacal
@leppie, But an assumption was that the CPU from which I tested my site loaded the site just fine. So in this case, how would top help me?Realty
In that case, probably not much. Can you impersonate the user and the exact page request? If it is fast for you, the issue is likely client side (browser and/or network).Maniacal
@leppie, I did not ask the interviewer that. Didn't occur to me for some reason haha. Anyway, if it is fast for me and not the client, it is 100% not a server problem?Realty
Might not be directly related to interview question but this site is quite useful to analyze the causes: tools.pingdom.comClarkin
L
17

Since you already said when you check the site yourself the speed is fine, this means that (at least for the pages you checked) there is nothing wrong with the server and it can serve those pages at a good speed. What you should be figuring out at this point is what the difference is between you and the user that reports your site is slow. It might be a lot of different things:

  • Is the user using a slow network connection (mobile for example)?
  • Does the user experience the same problems with other websites hosted at the same webhoster? If so, this could indicate a network problem. Normally this could also indicate a resource problem at the webserver, but in that case the site would also be slow for you.
  • If neither of the above leads to an answer, you could assume that the connection to the server and the server itself are fine. This means the problem must be in the users device. Find out which browser/OS he uses and try to replicate the problem. If that fails find out if he uses any antivirus or similar software that might cause problems.
Legatee answered 27/3, 2013 at 18:1 Comment(0)
D
8

This is a great tool to find the speed of web pages and tells you what makes it slow: https://developers.google.com/speed/pagespeed/insights

Decemvir answered 27/3, 2013 at 5:49 Comment(3)
Thanks for your answer! Nice tool. What would be nicer is if someone can explain how that tool works. In an interview, I don't think I can just say, "Oh. I can use PageSpeed Insights!"!Realty
It's as easy as you can imagine. Type in the URL of your site and click analysis. In Suggestion Summary, it tells you what need to be improved by priority. Click the summary to see detailed explanation on how to improve.Decemvir
@Decemvir - I have tried the tool which you suggested. Its was pretty good. I need some clarification from you. I tested my web application directly by passing the URL. BY passing the URL, I have passed the Create form - Ex: User creation form but after the results I have noticed the results is coming for the home page but not for the page which i was given. Can you please me thisPretorius
T
4

I think one of the important thing that is missing from above answers is the server location, which can play a vital in web performance.

When someone is saying that it is taking a longer time to open a web page that means high latency. High latency can be caused due to server location. Let's assume as you are the owner of the web page then the server and client are co-located, so it will have a low latency.

But, now if client is across the border, then latency time will increase drastically. And hence a slow perfomance.

Another factor is caching which drastically affects the latency time.

Taking the example of facebook, they have server all over the world to reduce the latency time (and also to provide several other advantages) and they use huge caching system to cache their hot data (trending topics) whereas cold data (old data) are stored in hard disk so it takes a longer time to load an older photo or post. So, a user might would have complained about this as they were trying load up some cold data.

Tatter answered 13/4, 2016 at 5:29 Comment(1)
Thanks for your answer! Yeah, the caching bit can be a tricky cause of slowness.Realty
H
2

I can think of these few reasons (first two are already mentioned above):

  1. High Latency due to location of client
  2. Server memory might need to be increased
  3. Number of service calls from the page.
  4. If a service could be down at the time of complaint, it could prevent page from loading.
  5. The server load might be too high at the time of the poor experience. The server might need to increase the resources (e.g. adding another server/web server to the cluster).
  6. Check if there was any background job running on the server at that time.

It is important to check the logs and schedules of the batch jobs to determine what all was running at that time.

Hope this help.

Henkel answered 2/2, 2017 at 20:20 Comment(0)
P
1

Normally the user takes the page loading time as a measure to find out that the site is slow. But if you really want to know that what is taking the maximum time the you can open the browser debugger by pressing f12. if your browser is chrome the click on network and see what calls your application is making and which are taking maximum time. If you are using Firefox the you need to install firebug. If you have that, then again press f12 and click on Net.

Possing answered 27/3, 2013 at 5:50 Comment(2)
You seem to have misunderstood the question, (maybe I worded it ambiguously). In this case, I am the owner of the website where some other user reports my site to be slow.Realty
Your answer actually reminded me of another detail in what the interviewer asked. Please look at the edited question now.Realty
G
1

One reason could be the role of the user is different of your role. You might be having suppose an administrator privilege (some thing like super user role) and the code might be just allowing everything for such role that means it does not really do much of conditional checking to see what is allowed or not. Some times, it's a considerable over ahead to get all the privileges of the user and have the conditions checking, how course depends how how the authorization is implemented. That means, the page might be really slow for specific roles. Hence, you should find out the roles of the user and see if that is a reason.

Gribble answered 27/4, 2014 at 17:26 Comment(0)
B
1

Obviously an issue with the connection of the person connecting to your site OR it's possible it was a temporary issue and by the time you checked your site, everything was dandy. You could check your logs or ask your host if there was an issue at the time the slow down occured.

Brainstorm answered 14/4, 2015 at 16:38 Comment(0)
W
0

This is usually a memory issue and it can be resolved by increasing the Heap Size of the Web Server hosting the application. In case the application is running on Weblogic Server. Heap size can be increased in "setEnv" file located in Application Home. Goodluck! Michael Orebe

Writhen answered 20/11, 2015 at 2:9 Comment(0)
C
0

Though your question is quite clear, web site optimisation is a very extensive subject.

The majority of the popular web developing frameworks are for some reason, extremely processor inefficient.

The old fashioned way of developing n-tier web applications is still very relevant and is still considered to be best practice according the W3C. If you take a little time to read the source code structure of the most popular web developing frameworks you will see that they run much more code at the server than is necessary.

This may seem a bit of a simple answer but, the less code you run at the server and the more code you run at the client the faster your servers will work. Sometimes contrasting framework code against the old fashioned way is the best way to get an understanding of this. Here is a link to a fully working mini web application which represents W3C best practices and runs the minimum amount of code at the server and the maximum amount of code at the client: http://developersfound.com/W3C_MVC_EX.zip this codebases is also MVC compliant.

This codebase comes with a MySQL database dump, php and client side code. To see this code in action you will need to restore the SQL dump to a MySQL instance (sql dump came from MySQL 8 Community) and add the user and schema permissions that are found in the php file (conn_include.php); setting the user to have execute permissions on the schema.

If you contrast this code base against all of the most popular web frameworks, it will really open your eyes to just how inefficient these frameworks are. The popular PHP frameworks that claim to be MVC frameworks aren’t actually MVC compliant at all. This is because they rely on embedding PHP tags inside HTML tags or visa-versa (considered very bad practice according the W3C). Also most popular node frameworks run way more code at the server than is necessary. Embedded tags also stop asynchronous calls from working properly unless the framework supports AJAX dumps such as Yii 2.

Two of the most important rules to follow with MVC compliance is: never embed server side tags (such as PHP tags) in HTML tags or visa-versa (unless there is a very good excuse such as SEO) and religiously never write code to run at the server if it can be run at the client. Also true MVC is based on tier separation, where as the MVC frameworks are based on code separation. True MVC compliance is very processor efficient. Don’t get me wrong MVC frameworks are very useful for a lot of things, but if you’re developing a site that is going to get millions of hits, they are quite useless, or at least they will drive your cloud bills so high that it will really eat into your company’s profits.

In summary frameworks don’t give much control over what code runs at the client or server and are very inefficient but you can get prototypes up and running quicker with less code.

In contrast the old fashioned way takes a bit more elbow grease but you have complete control over what runs at the server and what runs at the client.

As an additional bit of advice for optimisation avoid using pass-through queries and triggers and instead opt for stored procedures. Historically stored procedures weren’t invented at the time MVC was present as a paradigm but it definitely increases separation of concerns between the tiers and is much more processor efficient.

Hope this advice helps.

Colettecoleus answered 2/6, 2019 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.