Best Cloud Platform for Clojure Hobby Projects

What’s the best cloud platform to use for hobby Clojure projects? I’m looking for something that can:

  • Serve up a web app on the intertubes.
  • Give me access to a database. Bonus points if I can choose between a nosql and relational db, but really I’m not that picky. I just want to be able to save and retrieve stuff.
  • Provide an easy way to deploy a Clojure app.

I’m looking for something that is free or very inexpensive for apps with extremely low traffic. I don’t care if I need to use Java Clojure, babashka, or babashka/nbb. I just want easy.

Thanks!

3 Likes

Both AWS and Google Cloud have what you have asked for. I’m not sure about Azure, but would assume it has similar things.

As far as deploying a web app, build your backend as an uberjar and start it up at server start. For your front-end, build your project as an SPA, point your web page to your translated Clojurescript file and serve both from any simple web-server (which you can find on the web). Bonus points for putting all this stuff in Docker and shoving it into a Kubernetes environment. But in general, any of the major cloud providers (as well any of the minor ones) will give you what you need.

The cheapest path might be some cheap shared hosting with cPanel that lets you use cgi scripts and have a MySQL DB where you’d use babashka kind of like how its described here: Clojure like it's PHP: Use Clojure on Shared Web Hosts | Eccentric J

Something that might be easy and cheap is to use pcp.

You could also just go with a cheap VPC and use http-kit along with an embedded database like H2 for SQL or a datalog one such as Datahike, Asami, or Datalevin. And there’s also some simpler ones that are basically like persistent hash-maps such as codax or spicerack.

I think you can also use Heroku or Render.com probably, though they might be more expansive.

You might be able to do something with the free tier of AWS Lambda and DynamoDB as well, not sure, that might be close to free for small usage. Also PlanetScale has a free SQL DB tier worth checking out. You could setup some JAMStack with some free static site hosting like on render.com or cloudflare and connect to a DynamoDB/PlanetScale free tier DB and even throw in some AWS Lambdas or some CloudFlare functions or some similar free serverless offering.

This guide talks about other options: Deployment | Luminus - a Clojure web framework

I recently came across:

https://fly.io/

Didn’t tried it yet. The instructions looks pretty straight-forward. You also can use Postgres on the free plan.

3 Likes

I use Heroku to deploy Clojure projects, direct from the source code using Git push (no local packaging or container configs)

There is a simple guide and example Clojure project to help get you started

Heroku supports Leiningen by default and Clojure CLI (deps.edn) projects work with with a couple of simple tweaks:
https://practical.li/clojure-web-services/projects/status-monitor-deps/deployment-via-ci.html#create-a-custom-build-behaviour

A free Heroku account give enough minutes to run an application continuously without incurring costs (apps sleep after an hour of no use, but wake up automatically on request (or multiple apps and scaled resources if you remember to scale them down when not using them). If you want a user facing constant 24/7 uptime though, then choose the relatively low cost hobby plan.

Postgres, Redis and Kafka are the main databases, although there are many more in the Elements Marketplace

Databases (relational or otherwise) can be instantly provision with a single command or mouse click in the Heroku dashboard for an app. Each product makes its connection details available as environment variables (which can also be used locally from your dev environment - so no need for docker containers - although you can also deploy those too if you prefer)

I believe all databases have a free plan, although some products will require details of a credit card in case you decide to use more than the free plan. I haven’t been charged anything in the last decade.

Disclaimer: I worked for Heroku/Salesforce between 2012-2017, although have no current commercial relationship.

Resources

2 Likes

I’m personally a big fan of using plain VPSes on DigitalOcean. I have a bash script for provisioning that I copy into all my projects. The script sets up git-push-to-deploy as well. Spinning up new projects is fast, and I’ve found the “boringness”/not having more layers of abstraction than necessary to be a productivity boost. It’s not free, but it is pretty cheap–$6/month for a 1GB instance.

Re: databases–for hobby projects you could use something like sqlite that uses the filesystem for persistence. You can set up the VPS to take weekly system backups. For something more serious, DigitalOcean has a few managed database offerings (Postgres, MySQL, MongoDB) that start at $15/month. They also have an S3 clone that starts at $5/month.

Here’s the provisioning script; you can tweak that to your needs if you decide to go this route. It’s part of Biff, a web framework I made, but you don’t have to use Biff to use the script. I’ve written some documentation that covers the entire process step-by-step (you can ignore steps 2-4, and to deploy you’d do git push prod master).

3 Likes

I use Jelastic via MirHosting. It’s free for small apps that don’t use too much RAM and it’s dead-easy to set up because they have pre-built Java images that you just upload your uberjar to, and a simple GUI for adding Mongo / Postgres / whatever DB. I wrote a blog post with instructions a couple of years back and I still do things pretty much the same way now:

1 Like