Ask HN: Optimal cloud service to run tiny website with back end Python + SQLite?
Web ninjas:
What is your go-to cloud service for running a small website served with python + jinja2 + sqlite? The website does little besides searching an sqlite table, serving a form, and writing the form response to an sqlite table, all with minimal computation and bandwidth. Wants are:
Low price
Low maintenance time/cost
Simplicity
My strengths do not include web development/servers but I know the basics. I'm particularly interested in the gotchas like: difficulties setting up SSL, transfer limits, and "X is perfect except that ____".If I'm asking the wrong question or not providing enough info, please say so.
78 comments
[ 2.8 ms ] story [ 126 ms ] threadI second heroku for OPs requirements, extremely easy to set up and manage, and the free tier handles many small sites well.
Whatever you choose, use cloudflare for free SSL.
Once you a succeed each subsequent time becomes much easier. Plus you get to learn a ton about server management.
There are fantastic posts that will help you.
https://www.digitalocean.com/community/tutorials/how-to-set-...
There are different kinds of "simple". SQLite sure is simple in several dimensions, but then you need a writable file system for it, and file locking is not an issue for your usecase etc.
I consider my set it and forget it setup to be simple, and I haven't had to do any maintenance in 3 years, though Firebase is not exactly what you'd call "simple".
You'd have to be logged in to contact support :D
Installation is a breeze and there are plugins. If you're at all familiar with Heroku's deploy, you'll love this. It's the closest thing I've found to `git push` without any thinking.
I have noticed that deploys eat HDD for breakfast. Prune often. ("docker system df" helps show stats on space usage).
I have also read many optimisation guides talking about Alpine Linux images, but not sure whether that makes a difference.
Running a Go stack. Often wondering whether Caddy could be an alternative?
Sometimes I feel like this is still "too much". Like I still don't have enough control over the stack. Cloudflare introduces a lot of magic. I am not sure I fully grasp Dokku, but it works. Oh well!
Traefik is a reverse proxy for containers out of the box, apparently you would need some plugin to have that feature on Caddy : https://github.com/lucaslorentz/caddy-docker-proxy
As such, it seems like Traefik would be easier to setup for your use case.
Assuming you're a professional in the US / west europe, etc, the diff between $20 or $30/mo and $5 or $0 per month is negligible, while the time savings just from staying on a standard path can be huge.
My default suggestion would be:
Elastic Load Balancer, to talk to the internet and terminate SSL;
Elastic Beanstalk or something similar to host a box;
Certificate Manager for your SSL cert;
Route53 to serve your DNS.
All of the above should be cheap and, again, a very well trodden path with tons of help docs and people familiar with configuration.
Granted, Elastic Beanstalk/Load Balancer will allow you to scale should you end up with a massive influx of traffic - but I think you'd be far faster to spin up a VPS and use where-ever your bought your domain name from to point your domain name to it's IP.
In fact - this is exactly what I do and it took well under an hour including choosing and buying a domain name and costs $5 a month.
For example, I spent a pile of time getting letsencrypt to work with nginx. Admittedly, this was a couple years ago, but I had to go back in and fiddle with a config I barely remembered 6-ish months ago.
My ELB + AWS Certificate + EB have kept chugging along without a peep. I also ticked the EB setting to continually upgrade linux to take care of OS-level security issues.
You may be an expert on setting up linux/nginx/puma/bundler/ruby, but I've found that running my own (which I do!) requires a full couple days of maintenance a year. Again, from a person who does not do this regularly.
My AWS EB environment just does a new deploy and the magic keeps on magicking itself.
:shrug:
FWIW - Setting up Let's Encrypt doesn't seem much of a chore these days: https://www.digitalocean.com/community/tutorials/how-to-secu...
For my particular use-case (a personal blog) the software I wanted to run on a VPS had support for it so all I really had to do was install everything answer a few configuration questions and I was up and running.
In particular, all the web hosting side of things is preconfigured.
If you want to keep it simple..
A very small EC2 box. Maybe even micro instance. That'll run your python code + sqlite.
If you want, you can use an elastic load balancer or Route53. If you don't have DNS already. Route53 is AWS's DNS service which is easy to use.
This whole setup should not cost you much. If you do it right, you can probably spend less than $10/month taking advantage of the free tier.
Later on, as a side project, you can try to make the app serverless. You're probably close to it being serverless. Doing this allows you to run it on AWS Lambda. Which makes things even cheaper, if not free. And it's just pretty cool.
But most likely you'd have to switch to a real data store. No problem since AWS has DynamoDB.
If I were in your shoes I'd be looking at either:
- Firebase (free tier). Probably just using their RTDB for storage. You could conceivably do away with your backend entirely here.
- Cloudflare workers + KV storage (~$5 per month?) .. this would give you killer performance and let you write your storage logic in python. You're paying a minimum fee per month here, but in reality that could cover a large number of seperate sites.
Both suggestions raise vendor lock-in considerations, but given the use-case it doesn't seem like a major concern. Of course if you're looking forward to the joys of managing a box ...
You have a really great approach to simple software. Turns out your strengths do include setting up backends for web development!
Many self styled experts / People 2 digit years of experience who consider themselves solution architects could learn from you and your approach here.
Personally from there I would use a min-spec Postgres CloudSQL for the DB, but you can use whatever hosting you like if you want to DIY.
Python + SQLite AWS EC2 t2.micro
DNS + SSL Cloudflare free plan
Total cost = $0
https://prgmr.com/xen/ inexpensive. no overage charges. can pay by bitcoin. (and a FreeBSD friendly).
I wonder if you would also benefit from installing something like yunohost [2] on top of Debian. This will get you your personal cloud. And the use YounoHost's 'Custom web app' container [4]
This way, you get an automatically configured web server (nginx), with certificates (via Let's encrypt) that get auto updated.
You also get a pre-configured user/sftp access to your app's folders.
And those folders will be backed up when you hit the backup button...
Nginx will invoke your python app when the predefined URL is hit.
All you have to do is to point your domain registrar to the prmgr VPS host running yunohost.
[2] https://yunohost.org/#/whatsyunohost [3] https://yunohost.org/#/apps [4] https://github.com/YunoHost-Apps/my_webapp_ynh
lsc set up the Safeway divider advertisements. It was pretty cheap, like $150 a month. I don't think we would do it again, but it certainly caught a lot of people's attention.
I also know that they donate (or at least donated before now) hosting service to lobste.rs
I found them just by searching through like anybody else would.
I had never seen their ads.
are you affiliated with any of their competitors?
You can also get a free tier at Amazon AWS but you have to learn all the EC2 stuff and almost piece yourself a server one piece at a time (like the good old days where you build your own PC but clicking buttons) -- IMHO this takes much longer than just doing a $5 VPS and typing things. So if you want to learn Amazon AWS stuff, this may be a good path but it is going to take a lot longer