3 ms·
> The irony is that had you used javascript to render the page taking advantage of everyone's CPU you may have lightened the load on your server. No, he just d
by vinceguidry 12y ago
> The irony is that had you used javascript to render the page taking advantage of everyone's CPU you may have lightened the load on your server.
No, he just didn't take his philosophy far enough.
The real way to do this is to make your pages static and serve them from a caching proxy. If you don't need dynamism then you shouldn't use it at all on production.
Without seeing his server and his backend code it's hard to make specific recommendations, but a single server with an nginx front-end can handle a lot of load. I've seen Wordpress handle a full-on Slashdotting without even breaking a sweat.
- SigmundA 12y agoWorks fine if it's relatively static content, which this site probably is. I come from an busniess app development background so maybe I see everything through that lens, but when you need dynamism why would you not want to take advantage of your visitors CPU? Is the web just supposed to be a bunch of static documents?
- vinceguidry 12y agoThe real issue is the number of connections. Sure, if you are doing something like an animation, it would be stupid to do it server-side, unless you can use an animated gif or another way to make it static. But if you are loading a page, then having that page go back and forth to the server to retrieve more data, then that will kill your site as soon as it hits HN. Because each client is making a ton of connections and it just compounds. You've essentially DOSed yourself.
- SigmundA 12y agoThe point is shortening the connection time and CPU resources on the server by only serializing the data needed. This means less concurrent connections allowing more visitors. If you visited the site before, maybe the javscript rendering engine is already cached, all you need is the latest data not the layout. Again maybe this isn't the best choice for a static site, but there is a continuum of sites from static to completely dynamic web apps. It's nice now that the developer has the choice to involve the clients resources at the point in that continuum of their choosing rather than it being off limits.
- falcolas 12y agoI think you overestimate the resources required to render a page. The act of filling a cached template on the server with variables doesn't take much longer than the act of serializing the same data into JSON.
- SigmundA 12y agoOf course I think you underestimate the resources and bandwidth required to render and send html. After all what is the purpose of http compression? Decreasing network resources and lower load time by increasing CPU load on server and client. Doing javascript rendering on the client is basically a form of application specific compression that can actually require less server CPU rather than more while increasing client CPU as a trade off. I agree JSON isn't always a big win compared to HTML, but it is lighter and typically contains only data rather than layout metadata, making it even lighter, along with doing partial update etc. Going back to the old 2-tier client server days the database protocols such as SQL server TDS where binary extremely compact and efficient to parse requiring as little overhead as possible on the server to render and as little network overhead as possible. You are starting to see a resurgence of these ideas with bson, msgpack, protobuff etc. If you pair client side rendering with say msgpack you get even bigger wins in network overhead and server CPU time for parse and serialize.
- vinceguidry 12y agoYou guys are arguing on a forum about something that's easy to go out and test. Make some test servers, run some benchmarks. Find out for yourself. Then make a post about it using what you learned and submit it to HN. I hope it doesn't crash under the load.
- SigmundA 12y agoThis is an odd response, your posts where arguing for a certain approach while not running test and benchmarks to post results for. As I said there are a continuum of web sites from static text to dynamic and graphical. Benchmarks could be made at any point in the continuum to validate a specific approach. My "argument" is simply that it is a good thing we can choose the approach rather than being limited to a server side model only. In many instances it can be more efficient allowing less server resources for a given load and lead to a better and richer user experience.
- falcolas 12y agoThe question boils down to how much dynamism does your site really need? If it's a web application, then by all means use Javascript all you need to. A blog, corporate landing page, forum... none of these are really that dynamic. Or where they are dynamic, they could be first served as static, letting Javascript take over once it's all been loaded. At the very least, the initial data required by JS should be loaded with the rest of the page, letting JS start rendering the page immediately, instead of after another network round trip.