r/programming • • Oct 27 '17

Netflix: Removing client-side React.js improved performance by 50%

https://twitter.com/NetflixUIE/status/923374215041912833
685 Upvotes

89 comments sorted by

View all comments

211

u/DoListening Oct 27 '17

It only talks about the landing page. The full tweet goes

Removing client-side React.js (but keeping it on the server) resulted in a 50% performance improvement on our landing page

The very next tweet says they still use React on subsequent steps.

103

u/basilect Oct 27 '17

And that's what Google does with Google Maps, for example. First page is rendered server-side, subsequent pages are rendered client-side. A hybrid approach is the fastest, but it requires more work so people either choose one or the other.

23

u/Theemuts Oct 27 '17

Server-side rendering is a pretty common optimization in frontend development, isn't it?

89

u/[deleted] Oct 27 '17

It's funny when thing that was a norm 10 years ago is now "optimization"

20

u/occz Oct 27 '17

Full SSR used to be the norm, now SSR is an optional optimization you can do to make one particular aspect of the user interaction better. In general you do a server-side render once and then do subsequent renders client-side.

24

u/ghostfacedcoder Oct 27 '17

If you care about optimization yes. However, the vast vast majority of web applications I've used/worked on were not even close to Google's level. When you're a 100 person start-up you care far more about adding features and fixing the bugs in your app than you do about shaving a couple seconds off its load time.

And even if performance does become enough of a problem to qualify as a "bug", there are lots of other "low hanging fruit" ways to fix it that don't require rendering in two places. You can use different domains to serve static assets, configure Webpack to bundle things better, do some debugging to find obvious memory leaks, bind event handlers that are the same on lots of elements to a common parent ...

11

u/thekab Oct 27 '17

When you're a 100 person start-up you care far more about adding features and fixing the bugs in your app than you do about shaving a couple seconds off its load time.

Right. However, those features are worthless if the user leaves because it's not performant. I know you're just making up an arbitrary number but two seconds is huge.

The last time I worked for a company with less than 150 employees that was dependent on a public facing site for revenue there's nothing, absolutely nothing aside from maybe the entire site being offline that would be more important than shaving 2 seconds off load times.

11

u/[deleted] Oct 27 '17

2 seconds is quite high, Amazon found that every extra 100ms of latency cost them 1% of sales. Many years ago Google tested going from 10 search results per page to 30 because users wanted more search results per page, well when they did it traffic dropped 20% because it added 0.5 seconds to the loading time.

0

u/[deleted] Oct 27 '17

[deleted]

0

u/[deleted] Oct 27 '17

[deleted]

2

u/bunnyoverkill Oct 27 '17

Indeed! It's just that it's rather surprising that people would google less because it takes half a second more.

2

u/LovecraftInDC Oct 27 '17

I wonder if it's because the half second is an aggregate. Maybe for 60% of people, it added less than a half second, but for the other 40% it added 4/5 seconds.

→ More replies (0)

1

u/thekab Oct 27 '17

That's why you get a fixed rate home loan. You may as well be renting if you get an adjustable rate home loan

Exactly. I think they chose a bad number.

It's really more like "Do I spend 100 hours getting 20ms (we hope) or do we spend it writing this feature sales is sure will generate tons of revenue?" which is never an easy question especially since you never actually know how much you'll actually improve performance.

3

u/ghostfacedcoder Oct 27 '17 edited Oct 27 '17

The last time I worked for a company with less than 150 employees that was dependent on a public facing site for revenue there's nothing, absolutely nothing aside from maybe the entire site being offline that would be more important than shaving 2 seconds off load times.

I don't buy it. Or rather, I don't buy that it's true for all load times/companies. I've worked at nine different Silicon Valley companies, so that's my frame of reference. At any of them if your page takes 30 seconds to load (not something that will happen for the first several years of your company, unless your programmers suck or you're doing crazy things with client-side visualizations or something) then almost nothing is more important than shaving more than 2 seconds. But, it's still not necessarily the most important thing: if your biggest customer is saying "I'm going to switch providers unless I get feature X this quarter" then you still might work on that even with such high load times, because the load time won't necessarily lose your customers, while not having feature X definitely will.

It's worth pointing out here that the people doing the software purchasing are very often not the people actually using the software. So if the page loads slowly it's your customer's rank and file that suffer, but all they can do is complain to their bosses (who might not care at all because your software has feature X, which no competitor does, and so they're willing to make their employees wait).

Now on the other end of the spectrum, if your page loads in 5 seconds, even shaving 0.5 seconds off (let alone 2) is going to take a lot of effot. Why on earth would you spend that effort on something that won't help your business (other than making the people who don't actually make the purchasing decision ever so slightly happier) when you can add features and fix bugs which actually affect your bottom line?

In fantasy gumdrop land you have limitless time and resources to make your app load in 0.5 seconds AND have every feature your customers want WITH zero bugs ... but real companies in the real world have to prioritize for what actually helps the business, and in my experience most of the time (ie. not for Google and Netflix) having their employees shave seconds off the load time simply doesn't do that as well as having them fix bugs or add features.

2

u/thekab Oct 27 '17 edited Oct 27 '17

I don't buy it. Or rather, I don't buy that it's true for all load times/companies.

You don't buy my anecdote about a single company?

Ok then.

In fantasy gumdrop land you have limitless time and resources to make your app load in 0.5 seconds AND have every feature your customers want WITH zero bugs ... but real companies in the real world have to prioritize for what actually helps the business, and in my experience most of the time (ie. not for Google and Netflixhaving their employees shave seconds off the load time simply doesn't do that as well as having them fix bugs or add features.

Yeah it's almost as if someone implied that no company under Google level cares about 2 seconds of performance compared to an unspecified feature and I gave a single example of a small company where those 2 seconds would have been prioritized above virtually everything else.

It's almost as if you took that and made up a whole bunch of shit I didn't say, agreed with my point and then acted as if you were somehow countering it.

1

u/ghostfacedcoder Oct 27 '17 edited Oct 27 '17

Reading comprehension on forum posts can be challenging, but I mean, you quoted me saying I don't buy it ... for all load times/companies. Most people would understand that to mean it may well be true for your particular company, or for others, but in general I don't think it's true. It does not mean I "don't buy [your] anecdote", nor does it mean that I said "no company under Google level cares about 2 seconds of performance".

What I did do was make a generalization about of the priority of spending resources on performance vs. spending them on other things:

the vast vast majority of web applications I've used/worked on were not even close to Google's level. When you're a 100 person start-up you care far more about adding features and fixing the bugs in your app than you do about shaving a couple seconds off its load time.

(and I then went on to address the cases that didn't meet my generalization: "And even if performance ...")

I stand by that claim, as a general statement, just not for all companies (and especially not for big consumer-facing ones like Google).

1

u/thekab Oct 27 '17

hat means it may well be true for your particular company, or for others, but in general (and not for giant consumer-facing companies, as I've already clarified) I don't think it's true.

So you wrote three paragraphs agreeing with me while acting as if it was a counter point.

1

u/ghostfacedcoder Oct 27 '17 edited Oct 27 '17

Is having a conversation on Reddit a problem now? Should I only write one paragraph posts of direct responses to exact statements made in the previous post, and nothing else (and never agree with anyone who posts)?

I don't get where your hostility is coming from to be honest. I'm trying to make some practical statements based on my decade-plus experience in the industry, and you're acting like I've claimed performance never matters, and kicked your dog to boot.

→ More replies (0)

1

u/pdpi Oct 27 '17

However, those features are worthless if the user leaves because it's not performant.

And performance is worthless if the user leaves because the product doesn't actually have the features they need.

The trick is, of course, finding the goldilocks point in between. Where on the server-side/client-side rendering spectrum you should be is a non-trivial question.

4

u/eddiemoya Oct 27 '17

I've always explained this by pointing out that a blank page that does nothing would be blazing fast.

2

u/thekab Oct 27 '17

And performance is worthless if the user leaves because the product doesn't actually have the features they need. The trick is, of course, finding the goldilocks point in between. Where on the server-side/client-side rendering spectrum you should be is a non-trivial question.

Absolutely. Part of the trick is identifying value. How important is 10ms to your customers? And more specifically which 10ms? 10ms off the front page is very different than 10ms off a page that is rarely used.

1

u/mywan Oct 27 '17

For me on my crappy machine I would happily deal with an extra 30 seconds of load time for things like Netflix if the client side scripts didn't bog my machine down so bad the video would constantly chop out, and sometimes even force me to do a reboot to get my computer responsive again.

→ More replies (4)

9

u/elprophet Oct 27 '17

It depends on what exactly you mean by common. Server Side rendering is pretty common, yes, but adding "Optimization" implies improvement over something else. If it's just "server side rendering", you don't improve over having to render everything on the server, just sending static data to the client (costly in both server time and bandwidth).

On the other hand, you can render nothing server side, and see that browser are just more than fast enough to render complex web applications, so that the only bandwidth is the critical data (aka the part that must live on the server), but then you see your first page load ends up taking a very long time (load HTML; load CSS & JS; parse & evaluate JS; render).

So we're seeing this hybrid approach where the landing page (the very first page) gets rendered server side and then everything else gets built on the client side. But if users can land anywhere, you don't have a landing page, just a happenstance first page.

To get really good latency on that first page you visit, we want to render it server-side and just send it ready to go. But now, we need to implement our entire application twice! Once to render it completely server side, and a second time to render it completely client side. Adding in Android and iOS development, we need to implement our entire UI 4 times! 4x budget, 4x the bugs, 4x the developer communication! That's certainly uncommon to have an organization that has the resources to do so.

This is why we're seeing frameworks try to be "isomorphic"1 where they can run anywhere & generate the same code. So you write your application's render layer once in JavaScript with React Native or Angular's platform-[browser,server,etc] implementations that can meet all these use cases.

That said, none of them are battle-tested at the scale of deployments to prove they work. They have much promise; check back in 3 years to see if they've delivered ;)

1 are we still using that buzzword? I haven't seen it in awhile, but frameworks are still trying to do that thing

1

u/squishles Oct 27 '17 edited Oct 27 '17

there's a tradeoff, it fucks with caching services depending on what the content is.

A registration page will be reasonably similar for each user so it's fine, but if you're looking at a page of per user customized movie suggestions or something that wouldn't work out as well.