Since around February of 2012, I've been publishing this blog as a static HTML site using Pelican. The experience was pretty good, but over time I ran into a few problems with the fact that I never upgraded the site to match current versions of Pelican. Which meant the following:
So I started looking at other options. My requirements:
With those requirements in mind, I got started reviewing other tools. I tried a bunch of options (Hugo, Lektor, Pelican again, etc) but none of them met my requirements to the degree I wanted.
Eventually, I decided the best course of action was to write my own blog engine with Flask and host it on AWS Lambda via Zappa with a JSON and Markdown backend. Using Flask and Zappa seemed like a good fit for me.
The reason is that while our core engine at work is always Django, we use Flask on AWS Lambda to power many microservices. For persistence we have DynamoDB/Redis or Django-powered APIs.
So one day this month I wrote up a blog engine that suited my requirements. I flung a theme on it and deployed it to AWS Lambda.
Hooray! Mission accomplished!
With pleasure, I asked friends to take a look at my new blog system. Immediately these friends started to tell me it was running slow.
You see, it turns out if you load a huge JSON file for each page load AND render markdown on the server side, your site is going to be slow. Even after numerous optimizations the pages still loaded in seconds.
I thought about writing something to convert the JSON to native python objects. Or using an S3-located SQLite3 backend. But that felt like a lot of work to me and I wanted to get to writing.
Inspired by her idea, I installed Frozen-Flask and a few minutes later I had a static version of my blog. I removed the pagination and was done.
My new blog is built and deployed with the following backend components:
The markdown files that make up the content have metadata stored as JSON. That makes it easy to read and parse, but I have considered switching to TOML.
Looking out the window a few days ago I came up with a name for my blog engine: "Mountain".
Because Flask is better at doing work that doesn't involve SQL. And I don't want a SQL-powered blog. I want something that lets me write in markdown using my text editor. Mountain lets me do precisely that.
Here are some things I plan to do:
The end result of this is you'll probably see me writing more blog entries in the days to come. Mountain works exactly how I want it. It has removed some of the hindrances that slowed me down.
In fact, this is my first blog post written in Markdown on the new blog. How cool is that?
Published: 2018-03-29 16:00
Content Copyright © 2012-2018 Daniel Greenfeld. Proudly harnessed by Mountain, powered by Flask, and rendered by Frozen Flask, all of which take great advantage of Python.