Using GCE’s new free-tier micro VPS for fun and profit

Google’s Cloud Engine product, GCE allows developers a couple hundred dollars worth of credits, but more importantly, they’ve setup an “always free” tier VPS, the f1-micro (1 vCPU, 0.6 GB memory). Now, there’s not a whole lot you can do with 600mb of RAM in today’s world, but I decided to give it a go.

Since we’re going to plug a couple of docker containers in to this machine, I went with my favorite, jwilder’s nginx reverse proxy. For example if you have three domains, livelylobster.us, treeoctop.us and plutovir.us and you would like to run three blogs from here. First, spin up your nginx reverse proxy:

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy

Now your VPS is listening on port 80 for all connections. Go to your registrar and make sure your A records are pointing at your VPS, this could take from minutes to a day depending on who is your DNS provider. From here, due to how well this containerized reverse proxy system works, we just spin up blogging containers with the correct environmental variables in the docker run command.

-e VIRTUAL_HOST=livelylobster.us

See it in action, spin up a blog at livelylobster.us:

docker run --name ghost --restart always --expose 2368 -v /var/livelylobster/ghost:/var/lib/ghost -e VIRTUAL_HOST=livelylobster.us -d ghost

Ok while that is spinning up, start a second blog, this time for plutovir.us using the same environmental variable method described above, volume mounting from a different location to keep them seperate:

docker run --name ghost-pv --restart always --expose 2368 -p 2369:236 8 -v /var/plutovirus/ghost:/var/lib/ghost -e VIRTUAL_HOST=plutovir.us -d ghost

After the whole Evernote wants to read your notes snafu I’ve been looking for a replacement. The open source alternatives leave a lot to be desired. Livelylobster has been put in private mode, I’ve been experimenting with using Ghost as a markdown specific notes system that also allows image uploads. One of my biggest beefs with Evernote, besides the privacy issue, is that it always preserves font styling etc which makes it painful to work with directly. It’s a work in progress, but with some minor changes may make a suitable alternative.

Anyways, at this point you should be able to browse to http://livelylobster.us and http://plutovir.us and view your handiwork.  To properly set them up for the first time, you will likely need to go to http://hostname/ghost/

The big takeaway here is that containers can be very small or actually quite large, depending on how they’re setup. The micro VPS has but only 600mb ram; obviously there’s some system overhead, the nginx proxy only uses 10MB ram which is about average from what I’ve seen from truly lightweight containers. Ghost on the other hand uses somewhere between 110MB and 175MB typically. That’s pretty heavy when you only have 300-350MB RAM to work with. Performance suffers considerably at the micro end of the VPS scale. At this point I’d consider a static website renderer to cut down on memory usage and improve overall performance, something like Jekyll or Hugo. It requires a little more pipeline to achieve this but you get the benefit of making it more modular, keeping your content in source control, and this is sort of the direction everything is headed anyways. Going to a static renderer should get you down below 30MB per container, giving you more bandwidth to standup additional services or accept many more connections.

The other thing not covered here, but supported, is enabling letsencrypt to allow full trusted SSL between clients and your web server(s). If you’re already on Kubernetes you can set it up that way. That’s a story for another time.

This entry was posted in computing, docker, kubernetes, linux and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>