r/AskComputerScience • u/_4lexander_ • Oct 14 '19
Why are there still issues with web page loading speed if internet bandwidth got over 1000 times faster in the last 20 years?
I remember loading pages in dialup internet when I was a kid. Sure it was pretty slow but it was at 56kbps. Now we get hundreds of MB/s bandwidth which is several 1000 times faster but I still get pages which load slow.
I also know a small amount about JavaScript and there's min-js which makes JS into a more compact non-human-readable format to improve load speed. Or sometimes I get advised to put css in a different place because that will make the page load faster. Seriously though??? It's just text!
I know that web pages and web apps are much more complicated than they used to be, but I can't imagine that they literally got 1000 times more complicated.
Bonus: Same question for memory and CPU speed. I feel like the improvement in specs has been disproportionate compared to what I can actually do with a computer. It still takes a while to load up excel, just like it did 20 years ago.
4
u/kristopolous Oct 14 '19 edited Oct 14 '19
latency isn't bandwidth and latency hasn't changed much. The number of dependencies, which have a time to first byte (which hasn't improved much) has gone up ... They have to do things such as resolve their dns (which again, hasn't gotten orders of magnitude faster) before establishing the connection and transiting things.
To understand the difference, imagine a motorcycle and a train, both traveling at 60 miles per hour. Once at the destination (say an hour away), the train deboards 400 people and the motorcycle 1.
We aren't getting to servers dramatically faster ... our carrying capacity has gone up. This means more connections can be serviced and there isn't really any "queuing" going on, as if all lanes at the supermarket was open. But the time to buy your groceries once it's your turn, that's the thing that hasn't changed here.
There's ways a savvy web designer could speed those things up but in practice few have the time or priority to concern themselves with it.
1
u/_4lexander_ Oct 15 '19 edited Oct 15 '19
Thanks! The answer makes sense to me although I'm not sure why it's the first mention of it I've seen among all the comments. Do you think it's an often overlooked aspect?
Edit: actually, after reading more I noticed that your answer appears in other comments just stated differently.
3
u/sloec Oct 15 '19
There is one key piece missing from the answers given so far. The underlying protocols used for web browsing were not designed for today's bandwidth/latency and are thus causing some bottlenecks. To load a web page that today might have 50-100 resources you need to do an HTTP request for each resource individually. This in turn requires a TCP connection for each resource. So first you have to do a 3 way TCP handshake to establish the connection, then send your HTTP request and wait for the answer. Rinse and repeat until you have all the resources. Originally, you could only have 2 of these outstanding at a time, though that is higher today. Some optimizations have happened to piggy back multiple resources on a single request or compress a bunch of stuff together, but the fundamental limitations are still there in TCP/HTTP1.1. Newer protocols such as HTTP/2 have come along to address these issues and greatly improve the experience.
1
u/_4lexander_ Oct 15 '19
Awesome response. Do you think HTTP/2 properly addressed the root cause, or was it kind of a half hearted attempt which did a great job but didn't go all the way?
1
u/sloec Oct 15 '19
Regarding your original question it will undoubtedly help. You will still have TCP under it. I’m not sure about other concerns it was trying to address. I’m working on my first protocol on top of it now, so I will know a lot more later on.
2
u/msiekkinen Oct 15 '19
It depends a lot on the specific site on why it's being shitty. Common issues are lots of resource HTTP requests (external css, javascript, image files). Aside from any processing rendering it first has to fetch the raw "just text" source code you mentioned.
Browsers will only allow a limited number of concurrent requests. If a site is setup poorly it might make 10 different requests fro the java script it needs instead of minifying it all into a single file where the byte size coudl be the same (or less) but is only a single request.
Ads.... all the fucking ads... that's only going to further add to the number of HTTP requests on top of the actual content your after.
Aside from many HTTP requests when it's all said and done just the HTML/CSS/JS can measure in the megabytes. That's compared to kilobytes or less in days of 56k modems.
People go to boot camps to sling code and get jobs looking for the lowest bidder. They aren't concerned with such things on how to be performant other than maybe some half truths they have remembered from a medium blog post that read that one time.
Now lets turn the looking glass around and look in the mirror. Are you running 5 chrome windows with an average of 72 tabs each on a system with 4GB of RAM? That's not going to help anything client side.
Things like Chromes developer tools and other kits can help you visualize waterfall network requests as well as which parts of javascript are taking the longest for a particular site.
1
4
u/khedoros Oct 14 '19
Not every web server is going to give you a connection at your max speed; maybe you've got a gigabit connection, but their upload is limited to 10 megabit (or it isn't explicitly limited, but the site's just busy).
You also are only rarely connecting to a single server, anymore, and some of that has to go in sequence, rather than parallel. Load the main target page, then start contacting the hosts for the media to be displayed, the ad servers, etc. And then maybe each of those have their own chain of prerequisites to load too...and it all needs back-and-forth to establish the https connections.
20 years ago, it would've been pretty standard to build a page like a table, optimized for something like a 1024x768 screen. Now, you've got things like flexbox and other properties that influence layout in ways that can take a lot of work to do, if the page is at all complicated. That's a case where we make it much easier for developers, but need to make heavier use of the computer's resources to make up for it.
Think about that the browser is parsing HTML, CSS, and Javascript, often compiling the JS into native code, and using those technologies together to come up with the actual tree that it's going to use to render the page. A lot of these things are in combination...so doubling the size of the problem-space might quadruple the work it takes to solve it.
Just in general, when we've increased the speed or capacity of a piece of computing technology, we usually have chosen to do more, rather than to do the same thing faster. Add an encryption or compression layer, transfer full-on video instead of Flash vector animations, etc. Windows 10's got file indexing, checks for updates, seamlessly doing web searches when you type something into the start menu, accesses zip files as if they were directories, keeps in-memory caches of previously-opened files, and a thousand other pieces of background magic.
4
u/irbilldozer Oct 14 '19
The modern web is largely driven off of web APIs rather than the static documents you used to load on Geocities back in the day.
Depending on the complexity of the web application I wouldn't be surprised if something like Facebook/Reddit is making literally 100s of API calls at times. Each one of those API calls means a web server somewhere is going out and communcating with another web server over the internet and exchanging millions of bits of data.
Yes over time the less dynamic things can be cached and they do help speed things up, but imagine the new content coming in on reddit or social media every time you hit F5.
As a software developer who has worked in a few different code bases in my life, it is absolutely baffling to me that most webpages run as fast as they do if you actually get a chance to peek behind the curtain and see slowly smouldering dumpster fire.
4
u/deong Oct 14 '19
In the old days, you went to a web page and your browser sent an HTTP GET request to that server and pulled back some HTML. It parsed that HTML and used issued a few more GETs for the embedded resources, assembled it all for layout, and you were done.
Today, pages may have dozens of JavaScript frameworks making hundreds of requests for every load. Even with caching and CDNs, lazy companies with a bottomless need for tracking data can make anything slow if they try hard enough.
2
u/Mukhasim Oct 14 '19
The brief answer is that there's a long chain of things that need to happen between the time when you click a link and the time that you can see the page. If any one of those things is slow, then the whole process will be slow.
1
u/Hans_of_Death Oct 15 '19
web pages are 50x more massive and complicated and shit then they used to be. think when you load a page and the page loads like 50 ads and fancy css and effects and stuff
1
u/not-just-yeti Oct 15 '19
Part of it is that loading pages these days entails lots of further secondary loads. E.g., for every image on the page, that's a separate request (w/ the associated overhead).
For this exact reddit page/thread, my browser made 91 file-requests: screenshot And that's with an ad-blocker and some modest anti-tracker plugins.
If you're on a desktop, look at the developer-tools, re-load the page, and it may show a timeline of all its requests. (For Chrome on desktop, the timeline is the default thing you see when opening [menu dots] > More Tools > Developer Tools.)
1
u/qxnt Oct 15 '19
Because of Jevons paradox: improvements in infrastructure and technology that should have brought us a transcendent web experience have been countered by massive bloat that actually slowed us down more.
0
Oct 14 '19
[deleted]
3
u/WikiTextBot Oct 14 '19
Wirth's law
Wirth's law is an adage on computer performance which states that software is getting slower more rapidly than hardware is becoming faster.
The adage is named after Niklaus Wirth, who discussed it in his 1995 article "A Plea for Lean Software".
[ ^PM | Exclude ^me | Exclude from ^subreddit | FAQ / ^Information | ^Source ] Downvote to remove | v0.28
0
u/HelperBot_ Oct 14 '19
Desktop link: https://en.wikipedia.org/wiki/Wirth%27s_law.
/r/HelperBot_ Downvote to remove. Counter: 284251. Found a ^^bug?
21
u/TenableTarsier Oct 14 '19
On the surface you might think these are simple questions, but the answers to them are varied and complicated.
Load Times
Page load times are generally affected by several factors:
Your connection speed
Your connection's local saturation (are a bunch of people in your area all on the same trunk and doing things that take a lot of bandwidth?)
The server's connection speed
The server's saturation (more people asking for things from a server means you wait longer for your request to be completed)
Subpoint: is the server undergoing maintenance or some other internal process that consumes most of its resources? (At my work, we sometimes run reports to give to sales or marketing and these can have a brief impact on site performance depending on when we run them)
The route your request has to take to reach the server and if that route suffers from node outages (e.g. take two rights to get home vs. two rights, three lefts, right, straight, then left, then right again, two more lefts, then go right)
Where you are located geographically (or where your current VPN server is located geographically)
Where the server you are requesting information from is located geographically
The "robustness" of your computer (hardware)
The amount of data you are requesting and the format it is in
Large database queries can cause servers to slow down
How much processing your client (web browser) must do before displaying the data (javascript)
The efficiency of the code the site uses to display that data (back end/server side, not your browser)
Whether or not you have cached data - if you have never been to a site before, then it must request new copies of all assets needed to use and display the site
That is not an exhaustive list by any means, and there are many more details that go along with most of these.
Bonus
Many programs are not entirely optimized or optimized the way they should be to make their loading times faster. In many cases it could be because the application is pre-fetching data and/or in other cases it is because it is connecting to (or contacting) a server to verify that application is valid/licensed.
For MS Excel, it would not surprise me in the least if the reason it loads slowly is because it is contacting a server somewhere to verify that it is a "genuine Windows product (tm)" - that said, it's purely conjecture on my part.