3 ms·
It's really not a good idea to use dynamically generated pages to run a blog. There's a reason static site generators exist. This should be made clear that th
by sneak 3y ago
It's really not a good idea to use dynamically generated pages to run a blog.
There's a reason static site generators exist. This should be made clear that this is just a toy/example app to demonstrate Django, not something someone should actually use.
Generating the pages on each request is madness, and is why Wordpress in the default configuration (without WP Total Cache, which allows the httpd to bypass Wordpress entirely for most requests) falls over as soon as it's linked from any media site. Let's stop repeating these engineering mistakes in language after language.
Compile your blog to static pages and deploy those. Hugo, Jekyll, and a million others await you, as well as CF Pages, S3, GitHub Pages, Netlify, and others.
- simonw 3y agoIf you're worried about traffic spikes, stick your site behind a caching proxy like Varnish or Cloudflare. My main blog https://simonwillison.net/ https://simonwillison.net/ runs as a Django+PostgreSQL app on Heroku behind Cloudflare, with a 15m cache TTL for every page. This works perfectly. I survived a surprise Elon Musk tweet a few months ago which the server didn't even notice, because Cloudflare absorbed all the traffic: https://simonwillison.net/2023/Feb/17/analytics/ https://simonwillison.net/2023/Feb/17/analytics/
- frankwiles 3y agoSame, a bit of caching and the REVSYS blog survived being on the front page of Slashdot (back when that was a thing), Reddit and HN all at the same time. No Elon tweet for sure, but caching like Varnish, Cloudflare, Fastly etc go a LONG way.
- lyjia 3y agoThere are other ways one can cache dynamic blog pages, like with CLoudflare. Some frameworks will automatically cache database calls as well, like with Rails.
- AdamCraven 3y agoAs someone who uses a mixture (django, Hugo), I say it’s fine use dynamic sites to run a blog - there’s millions of them out there. They are usually easier to administer for less professional users, as well as being able to quickly modify from standard web interfaces. If it’s backed by a cache like redis it’ll easily handle Hackernews level traffic, even at very short cache times.
- evantbyrne 3y agoWhat a strange comment. Yes, caching is intelligent and will help you scale, but there's nothing inherently wrong with dynamically generated pages. > Generating the pages on each request is madness, and is why Wordpress in the default configuration (without WP Total Cache, which allows the httpd to bypass Wordpress entirely for most requests) falls over as soon as it's linked from any media site. No, it is not. WordPress is slow because it has an exceptionally poorly designed database schema, which requires SELECT DISTINCT and joining on the same table multiple times per query in order to do anything meaningful. > Compile your blog to static pages and deploy those. Hugo, Jekyll, and a million others await you, as well as CF Pages, S3, GitHub Pages, Netlify, and others. One downside of this is that you have wait for a compilation process every time you make content changes. Another is that any forms you might have still need a backend of some kind. Static sites are really only appropriate for sites that rarely ever change. A blog may or may not change frequently enough to warrant a backend.
- sneak 3y ago> Static sites are really only appropriate for sites that rarely ever change. A blog may or may not change frequently enough to warrant a backend. Any modern SSG can build and deploy in under a minute, usually in single digit seconds. This isn't really an issue in practice at all. Static sites work fine even if you are updating many times an hour. This is a far cry from "rarely ever change".
- evantbyrne 3y agoYou're conflating build times and deploy times. A low friction deployment might take a couple minutes end-to-end for something that "builds" in a few seconds once the CI is booted up. Sure, that's fine for hobbyist stuff that is always being edited by the web developer and nobody else. The point is a proper backend editing experience brings so much to the table. Once upon a time, my promotion was delayed because the team lead I answered to decided to use a SSG instead of a proper CMS, and non-technical stakeholders were not happy about the limitations.
- thraxil 3y agoHere's a post I put up just a few weeks ago showing how a completely dynamically generated blog with zero caching or performance tuning handles the traffic from ending up on the front page of HN, being served off the free tier of Fly.io: https://thraxil.org/users/anders/posts/2023/08/19/hn-traffic https://thraxil.org/users/anders/posts/2023/08/19/hn-traffic It's Phoenix in my case, but I've had a dynamic blog with Django for a long time and it's not massively different in terms of performance. I also do like static site generators, but more for being able to dump stuff into S3 and avoid some deployment complexity (but they introduce other complexity). The main point is really that Wordpress, with the default configuration is just off the charts terrible. Like, it had to have taken massive amounts of engineering to make something that performs so poorly. If you don't pile a million features into a product and overengineer the living daylights out of it, it's really not very hard to handle quite a bit of web traffic.