Hacker News new | past | comments | ask | show | jobs | submit login

Doesn't server rendering increase load on the server? I like to off-load as much processing to the user's browser as possible. We have ~1 million users and I like to think that when we off-load a lot of processing to the browser, we basically have 1 million servers for free.



Consider this: you're doing server side rendering whether it's JSON or HTML fragments you're sending across. They're just different serialisations of the same data. The problem that SPAs were meant to fix was that each update of the page meant a full rerender under the classic model rather than just rerendering those bits that had actually changed.

You're still going to be able to take advantage of those client machines to do rendering, but the difference is that with HTMX, you skip serialising JSON, so your clients aren't stuck doing unnecessary rendering. The load on the server is barely different, but the client has less to do.

Now, if you're doing an awful lot of data manipulation on the client, that's a different story.


Rendering html doesn't consume a lot more than rendering json, specially that with htmx you'll render small fragments... Anyway the bottleneck is most of the time on the database.


Hi! Sorry for the delay. I'm the one who gave this talk.

Yes, rendering HTML on server-side increases server load, for the simple reason that the server-side templates contain some display logic. But:

- Most SPAs I've seen generate useless server load: either by fetching too much information, or by fetching information too often. And that's not because SPAs are a bad idea per se, it's because many small companies have very small teams, and very small teams just don't have time to build a custom-tailored API ("backend-for-frontend"). We chose jsonapi with Django-Rest-Framework, which was crazy-easy to implement from the back-end perspective (as we had many other challenges), but which made the front-end developer implement twisted stuff on client-side, like prefetch-on-hover, or plugging react-query with crazy refresh settings generating hundreds of API calls when only 2 or 3 would have been enough. At the end of the day our servers load is not higher now. Each request costs a little bit more, but there are a lot less of them.

- Another thing is: the idea of delegating template processing to the client may seem good from a wallet perspective. But if you also think of the environmental impact of what we do as developers, you might notice that many people get a new laptop on a regular basis just because some applications are more and more CPU and memory greedy. And when you think that about 80% of environmental impact of the digital industry is generated by building and shipping new terminals, it might make you realize that being part of the solution implied reducing the amount of client load you ask your users. And yes, this implies that your company accepts to reduce gross margin to take a very small action in the battle for a cleaner industry.


It is quite nice to create on the browser, but as the number and variety of clients increase, the application may become slow for some. And the main problems start there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: