How this site works
This site is statically built by a python script. It gets rsync
'd up to a server running nginx and certbot.
The static site builder is cobbled together from a few examples. It definitely needs a from-scratch rewrite because some of the design choices are just awful. The code is a mess. It also has two major deficiencies:
- If I'm writing a post, it gets compiled: I don't have a way to tell it "No, this is just a work in progress, don't generate this."
- I have to redundantly make a tag in the markdown and the filename line up to have the page be properly linkable.
The posts are written in markdown and put into HTML templates. The markdown files are first split to extract some tags at the top, like which template to use, the post date, or the page title (which is in a field actually called subtitle; like I said, bad early assumptions). Then that HTML is used to replace placeholders in HTML templates.
The markdown is parsed using a python package called Commonmark. It's latest version is 0.9.1 and from 2019. The from-scratch rewrite will probably use pandoc. I'll probably publish it to github after I do that.
The server is hosted on Oracle's Always Free tier. It's actually pretty good! You can have two x86 servers with one core and a gig of RAM each and you can split an ARM server with 4 cores and 24 gigabytes of RAM up to four ways. There's also like 200gb of free block devices, 10tb/mo of egress, a load balancer, and a database.
I highly recommend using the Always Free tier because it's Always Correct to cost Oracle money. There's just one caveat...
If your server is idle they kill it.
What makes a server idle? According to Oracle...
- CPU utilization for the 95th percentile is less than 20%
- Network utilization is less than 20%
- Memory utilization is less than 20% (applies to A1 shapes only)
So what can we do?
- It'd be kinda hard to use that much network constantly and I'm unsure what the check interval is.
- A1 shapes are the ARM Ampere servers (which this is not hosted on) and, regardless, using this doesn't cost Oracle any extra money because RAM isn't really sparsely allocable. Programs can cope with waiting on CPU time, but oversubscribing RAM will result in lots of paging and inefficient usage of everything else.
- So that leaves me with using enough CPU which is also the easiest.
What's a good way to waste CPU time? If you said mine crypto, lmao no.
There's a program called PractRand which is designed to perform statistical analysis on a series of random numbers to see just how correlated they are. It's very useful for assessing the quality of an RNG. It also can run a CPU flat out, no problem.
So we make a cute lil' script called larry.sh
#!/bin/bash
while :
do
echo "Press [CTRL+C] to stop.."
sleep 1
nice ./RNG_test xoroshiro128plus
done
and run it in a screen
so it keeps running even when we exit.
The important considerations here are nice
and xoroshiro128plus
. nice
tells the OS that this program can play nice with others and that it can be pre-empted for CPU time. We don't want to waste time on generating random numbers if we can waste time serving the site! And xoroshiro128plus
is the name of an RNG. Originally I made the mistake of running pcg64
, a much higher quality RNG which survived statistical analysis long enough that PractRand allocated so much memory that the server died. woops. xoroshiro128plus
is a somewhat older RNG that has a few severe statistical flaws which makes the test abort early and free the used memory.
Why is it called larry.sh
?
Because Oracle is actually an acronym! One Raging Asshole Called Larry Ellison.
Who is Larry Ellison?
To quote a former Sun engineer, Bryan Cantrill, who left after being acquired by Oracle, "Do not fall into the trap of anthropomorphising Larry Ellison. You need to think of Larry Ellison the way you think of a lawnmower. You don't anthropomorphize your lawnmower, the lawnmower just mows the lawn, you stick your hand in there and it'll chop it off, the end. You don't think 'oh, the lawnmower hates me'- lawnmower doesn't give a shit about you, lawnmower can't hate you. Don't anthropomorphize the lawnmower. Don't fall into that trap about Oracle."
Oracle is offering free servers and their only condition on having them stay up is that you run up their bill. Oblige them.