Friends, I am *wheezing*. People on this plane are giving me looks. Holy shit...like...hahahahahahaha....omg...doubled over laughing:

https://martijnhols.nl/blog/how-much-traffic-can-a-pre-rendered-nextjs-site-handle

How much traffic can a pre-rendered Next.js site really handle? by Martijn Hols

How much traffic can a self-hosted Next.js site handle? I ran load tests, uncovered surprising limits, and compared pre-rendering with SSR.

Martijn Hols

@slightlyoff Martin’s testing method is a little bit peculiar — was the issue really next.js? Or lack of load balancing and infrastructure right sized for the workload?

The article closes saying SSR isn’t appropriate for lots of traffic, but… doesn’t discuss caching, or if a page truly needs to be 100% dynamic.

There’s a lot of high traffic fully/semi dynamic pages out there, SSR is just fine for so many applications.

TLDR: next isn’t likely the problem here at all

@benschwarz @slightlyoff

To show that next is not a problem it’d be informative to benchmark a fully static site on the same server.

I mean, you can collect your own data to back your claim.

@pointlessone @slightlyoff My 'claim' isn't something even slightly unbelievable! Dynamic workloads have numerous levers to pull to eek out request performance.

Off the top of my head: Load balancing reverse proxies, employing a CDN, use well-suited cache headers, use server-side caching, use partial response caching, ensure the server has enough CPU/memory for the workload, ensure there's autoscaling, eliminating slow DB queries.

All of which will improve RPS for dynamic workloads.

@benschwarz

Yeah, it had little to do with Next and mostly just a shit server

VPS isnt inherently slow - there's plenty of fast and cheap ones on lowendtalk.com - many (eg Ryzen) are much faster than his bare metal. netcup.com root servers are a good EU option

Nginx, caddy, etc would surely serve the static assets faster and with less compute

Avoiding US-based CDNs is probably prudent. More on SSR vs SSG wouldve been good. k6 also has playwright built-in now, for testing a full page render

@benschwarz My take is that the "prerendered" perf is trash tier, but I'd need to repeat the tests on the same host config. Just shocking to see below 200qps on 2 cores and 8gb of RAM, likely backed by 10K+ IOPS storage.

@slightlyoff @benschwarz yeah but that has nothing to do with next.js? saying that as somebody who hates next.js.

https://hachyderm.io/@mb21/114132277376540490

mb21 (@[email protected])

@[email protected] @[email protected] This. If it’s really a completely prerendered static site, this is testing the web server (like nginx). Or actually for a static site that needs to scale, you should use a CDN instead of (not in front of) the web server. sure, all CDN providers charge for bandwidth, but at that point it’s a pricing question, not a “does it scale” question (same for S3).

Hachyderm.io

@slightlyoff @benschwarz

I see you haven't met my friend WordPress...

On "static" sites where you can cache each page's html, nginx/litespeed can serve a huge amount of requests.

But if it's slightly "dynamic" (users log in, have custom views etc), it's all SSR and you'd be lucky to get 20 RPS on that sort of hardware because php is synchronous & single threaded, and WP has to do a billion calculations with 200 db queries to just return "You have 0 friends"

Fortunately most are the former

@slightlyoff @benschwarz
Though, again, the real stories here are

1. trash tier performance of almost all web hosts - especially any "shared hosting", but also most VPS and even many dedicated servers. They advertise blazing perf but run on overloaded 8yr old hardware. The "perf inequality gap" might be worse than on phones...

Surely SPA popularity is partly due to most devs knowing nothing about servers, so they are forced to move compute to the client when their server can't handle anything

@slightlyoff @benschwarz

2. The gap between SSG and SSR

Moving to a decent server had vastly better RPS. But there was still a chasm between SSG and SSR. Given its title, this is where the article should have focused

It's the same story as with WP (though, even there, plenty can also be done to partly mitigate the mess I described)

I'm curious how Ruby on Rails, Django, etc fare on a similar SSG vs SSR test. I suspect similar, or worse, numbers. Youd have to move to eg Golang for decent perf

@slightlyoff I'm confused by what's being tested here. Shouldn't the static assets be served by nginx or apache or something, if not a dedicated CDN? It doesn't seem like you can just take the RPS for the homepage HTML and then divide by the number of total requests the page makes to get the max number of visitors.

@slightlyoff it made me laugh as well. I can understand being shocked if you found these results hosting on Vercel, but this just points to author doing a poor job of hosting themselves. As others mention, what alternative are you comparing to on the same host?

Free advice, add a #varnish container to front anything static and 1000x your throughput

@slightlyoff I think my similar VPS does 3-5K rps, limited by logging. Perhaps also limited by https://loader.io/
Application Load Testing Tools for API Endpoints with loader.io

Free tool for web application load testing that allows for the simulation of concurrent connections to your web application's APIs

@slightlyoff That's AMAZING. Epicycles upon epicycles to make a blog page scale.
@ceejbot IT FITS IN MEMORY. I guarantee you the whole damn thing fits in memory!
martijnhols.nl/articles/nextjs-traffic-benchmarks at main · MartijnHols/martijnhols.nl

Martijn Hols is a Freelance React Developer. This website gives more info about me. It's made in React, with Next.js as framework and Prismic as CMS. - MartijnHols/martijnhols.nl

GitHub
@wimleers @slightlyoff I now feel bad for the guy, who probably just wants to show off his skills using his blog as a portfolio item, and has been sold a bill of goods like everybody else about how React is The Only Way to build web sites.
@ceejbot @wimleers I feel for him too. React ecosystem fairy tales steal so much joy.
@wimleers @slightlyoff @ceejbot why serve a bunch of static files with nodejs rather than nginx?
@ceejbot @slightlyoff Had my eyes on a "similar" static setup last week. It managed to serve a whopping 2req/s pr instance :|

@slightlyoff I think about this quote from https://tailscale.com/blog/new-internet a lot:

> I read a post recently where someone bragged about using kubernetes to scale all the way up to 500,000 page views per month. But that’s 0.2 requests per second. I could serve that from my phone, on battery power, and it would spend most of its time asleep.

The New Internet: Tailscale's Vision for the Future of Connectivity

Tailscale's CEO, Avery Pennarun, explores the future of the internet, discussing the evolution of networking, the issues with today's complex systems, and how Tailscale is simplifying connectivity for developers with a new, more efficient approach. Discover the vision for a New Internet.

@kp @slightlyoff Wait, this blog post was meant to be taken seriously?

@slightlyoff 😂
I just had to try this. Same K6 script, a ratty old webpage written in ASP.net Web Forms (yeah) running on IIS on a Windows VM (4 cores, 4 GB), no caching whatsoever, all server side rendered (so to speak).

2760 requests/s, iteration_duration avg=69.63ms, max=223.39ms

@slightlyoff Oddly he stopped at Cloudflare on CDN options. If he searched more he'd find bunny net as an option as a european provider.