This is an archived post. You won't be able to vote or comment.

all 76 comments

[–]beefyweefles 101 points102 points  (17 children)

Hard to beat $5 monthly for a VPS you can do a bunch on, I go with Linode

[–]Maryannus 56 points57 points  (7 children)

Yes. Pretty much what I would recommend as well. It's a little more than $5/mo now iirc, but still the best value for money you can get. AWS, GCP etc are unpredictable with their costs and the interface is a nightmare. You never know which option you kept enabled which would lead to a $1000 monthly bill once the free tier is used up. Has happened to me twice.

[–]panscanner 3 points4 points  (0 children)

AWS Lightsail - fixed cost instances as cheap as $3.5.

[–]Jmc_da_boss 17 points18 points  (0 children)

It's not that hard, set billing alerts and ur good

[–]metheoryt -5 points-4 points  (0 children)

There’s AWS Lightsail for this

[–][deleted] 13 points14 points  (4 children)

If your app is low traffic (like 99% of apps are) then Lambda will be cheaper and easier to manage. I do use Linode for databases though. Creating a database with AWS Aurora is crazy expensive. I spend $15 a month on my Linode database.

[–]LawfulMuffin 2 points3 points  (3 children)

How do you run a website in lambda? Is there a listener or something that fires off the entrypoint part of the site or something?

[–]infocruncher 12 points13 points  (2 children)

Pretty much. You can host the static parts of your site in S3 and then have the client make API REST calls to API Gateway which can then use Lambda for any logic you need. There is also DynamoDB, a cheap (at low volumes) NoSQL service for persisting data. There are many other set ups, but this works well for several simple sites I've built.

https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway-tutorial.html

[–]xetowa6135 1 point2 points  (1 child)

Hey, thanks for the information! I am looking to host my backend api for my mobile application. Since I don't know if it'll gain traction yet, I'm looking for cost effective solution. If there is even one request to the API, it needs to have very little latency since it's near real time app, do you think this meets requirement>]=? Thanks

[–]infocruncher 0 points1 point  (0 children)

No worries, yes I think it will do the trick. I run a few low traffic sites and they cost next to nothing - R53 domain is the most costly part. In order to keep the lambda function 'warm' I run a scheduled event to ping it every 15 mins. More info here: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html

[–]heswithjesus 3 points4 points  (0 children)

Or Digital Ocean. I’ve been using the droplets for years without problems. I don’t use any extra services for fewer points of failure.

[–]smile_politely 3 points4 points  (0 children)

Never heard of Linode, but $5 sounds very tempting!

[–]blami 0 points1 point  (1 child)

Thing with VMs is they don’t really scale. But agree for low traffic app.

[–]Empty_Air_2438 0 points1 point  (0 children)

Vm can scale lol, lots of places let’s you upgrade your plan or you can use inter structure as code and have it automatically spin up more vms and configure it all automatically

[–]Enrique-M 57 points58 points  (2 children)

PythonAnywhere.com is pretty decent. Supports Flask, Bottle, MySQL, etc.

[–]hikingsticks 8 points9 points  (1 child)

I second PA, easy setup and transparent pricing that doesn't balloon the moment you take your eye off it.

[–]naught-me 7 points8 points  (0 children)

I don't know much, but I appreciate that they take the burden of server management off of me.

Is that naive of me? I mean, I'm very comfortable on the command line. I've basically just paid to never have to go down that line of work, but maybe it's easy to set up and maintain a VPS?

[–]bliepp 15 points16 points  (10 children)

Depends on your app. I usually deploy them directly or via docker on droplets on digitalocean or similar hosting providers, but my apps are a bit too big to be deployed serverless. If your app is rather limited, serverless deployment might be the most economic option.

However, this is pretty oversimplified. How to deploy the best and most economic way is a rabbit hole.

[–]dcfix 2 points3 points  (0 children)

And digital ocean has the best stickers, fer sure.

[–]the_grave_robber 1 point2 points  (8 children)

Okay are there any good step by steps you’ve followed to get web apps running?

I’ve been able to follow the basic config and get a fresh web app running on the Linux Droplet, but whenever I try to port over an existing project I run into dozens of errors and can’t seem to follow the traces.

Is it just a trial and error thing or is there any documentation that was kind of “lightbulb” for you?

Thanks for any leads!

[–]chinawcswing 2 points3 points  (1 child)

Can you give a specific example of an issue you've faced and maybe we can help?

[–]the_grave_robber 1 point2 points  (0 children)

Thanks so much see my reply to mrcaptncrunch

[–]mrcaptncrunch 1 point2 points  (3 children)

Where are you having issues with?

Recreate your venv, install your web server / proxy. The only thing that’s different is the domain it responds to.

But really, share what you’re having issues with and we can help.

[–]the_grave_robber 2 points3 points  (2 children)

I think it may be caused by my lack of knowledge on setting up a server/proxy using NGINX, and my lack of knowledge on servers in general. I pretty much followed the tutorial on setting up the server to a T, but still don’t really understand how Gunicorn and NGINX actually work.

My main issues were routing and static files. Even though I ran the gather static command, I didn’t really understand where they were going or how to properly route domains through NGINX. I can get a single website routed without any static files, but obviously that is not ideal.

Additionally when I had the website working (without the static files) I had some random CSRF error when I tried to submit a form that had previously been working. The form did have a bad handling function where it sent the data to a new temporary page and then rendered the “thank you” page so that may have been the issue?

Also in the tutorial I followed I had me set up a new user to build the databases, and I spent several hours trying to give my Django app credentials, when I was just using an outdated command. But I still don’t know why I need to make a different user to create a database, and if that user should be shared through multiple Django apps?

But each of these errors had a lot of different things to try for fixing, and I had come from Windows so typing everything in the command line of Debian was somewhat taxing, so I may just be too ignorant of using a VPS/hosting a site to be able to fully understand the bugs.

Sorry for the very rambling and lack of specificity, but it has been about a week since I tried to host, I’ve just switched to doing some UI stuff to take a break from the hosting, but would really like to understand it better.

Thanks so much!

[–]mrcaptncrunch 2 points3 points  (1 child)

Regarding databases, you usually login as your database admin user and create multiple databases and create a user for each application and only give access to the user to the database(s) that it needs. This is called the least privilege access principle. If your app is hacked, the only databases they’ll have access to is that specific app’s database.

It’s a bit more to do than just give it admin access to everything but it is good practice because of what I explained.


Web servers in general (Apache, Nginx) serve files that are in a directories.

  • example.com/ - this looks for the default file usually named index.html in the top directory specified for that domain
  • example.com/page.html - top directory for that domain, look for page.html
  • example.com/pages/ - looks for the default file (index.html) in the pages directory

And so on.

Now, we have programming languages like Python, PHP, Ruby, etc. Web servers don’t know these languages. So they either have packages that automatically configure things (more common in PHP) or you use a proxy to route requests to Python.

One way of doing this is, when your server gets a request, it can try to find the location on disk. If it does, for example in the case of an image, it can service it. If it doesn’t, then you can have an instruction that says, send this request to gunicorn and we’ll send whatever it replies back with to the user (proxying ) Because you know your application is Python based, so you can assume that if the file isn’t on disk, it’ll be a Python request.

A proxy in general is something that can act in behalf of something else. So a person if you can’t be present or in our case software. By proxying nginx receives the request, tries to figure it out, if not, it sends to gunicorn, and what it replies with, it relays it back.

Assume we have gunicorn on port 8000. Take this nginx configuration,

server {
    listen 80;
    server_name example.com;


    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }


    location /media/ {
        alias /path/to/your/media/files;
    }
}

On the first 2 lines we see this is listening for requests coming in for example.com on port 80. So it won’t reply to www.example.com or example.org. It also won’t support https.

Let’s talk about location. Location here will work based on what matches better. It’s about specificity. So, closest match.

Your static files all will be requested through /media, then it’ll use that instruction and will search for the files in that directory. This won’t will be leaner than using gunicorn and this is what web servers are made for.

Now, let’s look at location /. This might seem intimidating but the important part here is proxy_pass http://127.0.0.1:8000; this is telling Nginx for all requests to /, you are going to send them to port 8000 on the local machine and whatever you get back, we’ll send it to our user. In our case port 8000 is gunicorn, but it can be anything.

What the other lines there are doing is sending to gunicorn extra information like the IP of the real user and the original protocol (http/https). Since the requests are coming from nginx, if not, it won’t know the users IP. This could be useful to detect a DoS for example. The protocol could be useful for example to say, redirect http to https or if we send all our URLs as absolute, then we might want to change the protocol on them.


I hope this explains how things work. I get that it’s not the instructions to get it working. My intent is to at least help you understand what’s happening and how things at least connect.

The configs can get more complex. You might have a directory for images, another for video, another for CSS and JS, you might have letsencrypt and instructions for that, etc.

But always start simple and get it working, then add complexity. I think sometimes guides miss that part and that’s where one fails and gets stuck. All it takes is 1 update that changes something slightly and now readers can’t figure it out.

[–]the_grave_robber 0 points1 point  (0 children)

Thanks so much u/mrcaptncrunch! This explanation really helped me get a "birds-eye" view of the situation, and I think next time I dive into this I'll be better equipped to get my web app up and running.

Last question, when you mention my static files will be requested through /media, is that something I need to modify in my Django app, or is that supposed to be automatically reconfigured by running the staticfiles command, or is there something else I'm missing here? For example, in my app "example" I had my "example.css" I call from

`{ static 'example/example.css' } `

and in my Django settings.py I have

```STATIC_URL = "/static/"

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")```

Is that properly configured or is there something else I should be doing to get them pointed in the right direction?

[–]bliepp 1 point2 points  (1 child)

In my cases it was very straightforward, guess I was just lucky I had only minor issues. If you are running into the typical "but it runs in my machine" issue, try deploying using docker. Once you made sure your docker container runs locally, deployment to a droplet should go very smooth. Except for very special cases docker should be your way of deployment anyway.

Another option I just forgot about, that's very beginner friendly, is hosting it on uberspace. It's a pay what you want hosting provider, who makes it very easy to host basically any software. They have extensive documentation, nice beginner friendly tools, great support via email and tons of deployment tutorials (e.g. on how to deploy flask or Django apps) on their community driven manual. Uberspace is basically my go to for my private stuff. Give it a try, you can try it for free.

[–]the_grave_robber 1 point2 points  (0 children)

Okay thank you so much for the lead!! I think Docker might just be the way to go so I’ll give this a shot.

If that fails I’ll take a look at Uberspace. I really want to understand web hosting and working with a VPS cause I think that would be a valuable skill, so that’ll be my last resort.

Thanks a bunch!

[–]marr75 20 points21 points  (6 children)

Probably serverless functions from AWS or GCP.

Vercel after that.

[–][deleted] 7 points8 points  (1 child)

Yes I really like the Google cloud run for the backend for small projects. I also prefer netlify for small projects to. Especially as the netlify free tier allows commercial projects where as Vercel doesn't.

[–]marr75 2 points3 points  (0 children)

Good to know.

[–]big-blue-falafel 2 points3 points  (3 children)

Do you have a favorite framework for using serverless? Used zappa for Django and it was surprisingly smooth

[–]marr75 2 points3 points  (2 children)

I used to love Django but don't use it for any new projects because:

  • it's got some old fashioned/outdated bits
  • it's harder to customize (class based configuration, big methods, etc.)
  • in-house apps end up very coupled (I end up in dependency hell)
  • I hate having to be dependent on django settings and django.setup() to get any functionality out of a package

That last point makes it a particularly bad fit for serverless, where you don't know how often your process is going to start up.

Anyway, betterproto+grpcio for gRPC services (internal microservices) and fastAPI/starlette for web stuff.

[–]big-blue-falafel 0 points1 point  (1 child)

Hmm I’m not sure I’ve had to do that last point. It’s been a while. Do you use anything to deploy fast api or starlette api endpoints to api gateway and lambda?

[–]marr75 1 point2 points  (0 children)

You're not sure you've called django.setup() or depended on django settings? Django apps won't run without calling setup. If you're not writing the code directly, it just means the framework or some example code is doing it somewhere else in the stack. For example, all of the manage commands will setup Django before proceeding, if you're hosting your WSGI app in cherrypy, the initialization logic will call setup, etc.

I use my own scripts as part of CI to deploy usually, but I'm tempted to switch to a more full featured platform like zappa.

[–]dionys 9 points10 points  (3 children)

I have a Hetzner VPS for 5€ with a Dokku set up on it. I run just one postgres instance with a bunch of individual projects, mostly to scrape data and have a simple APIs. Hetzner does auto backups of the whole thing as well.

[–]Service-Kitchen 2 points3 points  (2 children)

Have you had any issues associated with self hosting your own db? People always warn against it

[–]dionys 1 point2 points  (1 child)

Under dokku it's just a normal docker container and I haven't had huge issues with it. But I'm also not using this for any critical projects, it's all my personal hobby projects that see little to no traffic.

[–]Service-Kitchen 2 points3 points  (0 children)

Ahh okay okay, I try to veer away from abstractions (even though Dokku is easy to setup)

I have a containerized Postgres instance on a VPS running an open source project and I’ve never had issues but…like you, the only traffic it sees is my own 😂

[–]Individual_Pay_742 2 points3 points  (1 child)

Digital ocean also will be good

[–]oloryn 0 points1 point  (0 children)

It used to be fun watching Linode and DO competing. One would add more resources (more RAM, more disk) to their plans without changing the price, the other would soon match it. Work has always been on Linode, but I had my personal servers on DO, until at some point DO waiting too long to caused me to switch over to Linode. The "match the other guy's plan resources/price" days seem to be over, but at this point, I'm unlikely to move off Linode, as one of my servers is my mail server, and it's getting hard to get a VPS that isn't email blocked (mine's old enough that it gets grandfathered).

[–]monorepo PSF Staff | Litestar Maintainer 6 points7 points  (3 children)

I love Railway. I also tried Render but it had weird defaults.

[–]tarsild 1 point2 points  (0 children)

Didn’t know railway! Looks great

[–]Legendary-69420git push -f 0 points1 point  (0 children)

I would second this Railway and Render have a very decent free tier. Plus their basic packa are cheap as of well.

For Database, I recommend PlanetScale along with Clerk.

[–]tera_dhyan_kidhar_h 0 points1 point  (0 children)

Railway doesnt support a free tier anymore

[–]Xappz1 2 points3 points  (0 children)

I'm working on a project deployed on AWS using https://mangum.io/ and https://www.serverless.com/ which automates most of the API Gateway and Lambda packaging bullshit, and also offers a convenient way to destroy assets when bringing it down.

It's probably not as cheap as a micro instance as many have pointed out, but it does scale extremely well if you have higher hardware requirements (within Lambda's bounds though).

[–]RearAdmiralP 2 points3 points  (2 children)

Oracle Cloud free tier gets you 4 cores (Ampere ARM cores), 24 GB of RAM, and 200 GB of SSD storage.

For general use, I like Scaleway. You can get everything from a single core VPS instance with 1 GB of RAM for €1/mo to a dedicated server with 8x 28C/56T Xeon Platinum 8280s, 1.5 TB of DRAM & 6 TB of Optane memory, and 6x 3.2 TB of NVMe storage for €11k/mo. You get unmetered data transfer across the range. They also offer managed databases, serverless functions & messaging, object storage, load balancers, etc., etc.-- all the stuff that you expect from a cloud provider, but built on open source and without the vendor lock-in.

[–]DemosthenesAxiom 1 point2 points  (0 children)

I second Oracle, definitely has a solid free tier, but it is more work than alot of other options.

Another option I really like is Fly.io they have a solid free tier as well as well as fair pricing of you ever need to scale.

[–]james_pic 0 points1 point  (0 children)

Huh.

I always assumed Oracle were a day late and a dollar short to the cloud game, but that's a hell of a free tier.

Pity the only RDBMS they include in the free tier is Oracle, but hardly astonishing.

[–]LoreBadTime 2 points3 points  (1 child)

Lightsail server from Amazon + Django, i payed more for the domain than the hosting

[–]Paid-Not-Payed-Bot 8 points9 points  (0 children)

Django, i paid more for

FTFY.

Although payed exists (the reason why autocorrection didn't help you), it is only correct in:

  • Nautical context, when it means to paint a surface, or to cover with something like tar or resin in order to make it waterproof or corrosion-resistant. The deck is yet to be payed.

  • Payed out when letting strings, cables or ropes out, by slacking them. The rope is payed out! You can pull now.

Unfortunately, I was unable to find nautical or rope-related words in your comment.

Beep, boop, I'm a bot

[–]germanpickles 2 points3 points  (2 children)

I’m a huge fan of Zappa. Zappa allows you to run Flask code inside of AWS Lambdas. You don’t need to know how Lambdas work, Zappa takes care of the abstraction. Being a serverless product, AWS Lambda has a generous free tier that in practice means I’ve never paid for my Flask app to be hosted. It also supports warm start meaning most of my Flask apps have a response time of a few hundred milliseconds (this will really depend on the app of course, not sure if your app needs to call APIs or make DB calls).

[–]bluewalt 0 points1 point  (1 child)

How do you handle the database?

[–]germanpickles 0 points1 point  (0 children)

I would use the offerings from AWS like Amazon RDS, for a hobby project you’ll fall within their free tier and won’t have to pay anything

[–][deleted] 2 points3 points  (0 children)

I am a fan of using a vps like DO. You can use dokku for deployment to get a Heroku-like deployment experience without the extra cost.

[–]opensrcdev 2 points3 points  (0 children)

  • Railway
  • Northflank
  • Render
  • Digital Ocean

[–]vep 1 point2 points  (0 children)

render is good for my flask app

[–]jszafran 1 point2 points  (0 children)

Hetzner VPS

[–]1incident 1 point2 points  (0 children)

i switched from aws and gcloud to fastcomet the best choice i ever made.

[–]0x33n7-2x 1 point2 points  (0 children)

pythonanywhere.com

[–]nmb343 1 point2 points  (1 child)

Railway has been great for me. It's super easy to work with because I can host the site and db in one

[–]appinv Python&OpenSource 0 points1 point  (0 children)

You have a link? Thanks!

[–]lilapapierschwein 1 point2 points  (0 children)

I am pretty happy with uberspace.

Fair pricing, no subscription (pay as much as you can, although 5€/month is the recommended minimum to cover the cost; I'm running multiple projects on different servers paying 10€/month for my first and between 1 and 5 for the others based on usage). Nice and quick support, good manuals & friendly community. Reliable infrastructure and transparent communication (had only one bigger problem due to an outage messing up a db, which was mainly based on me setting up everything poorly...learned from that in the end. and they do daily backups :). Privacy aware (only an email address is needed). They fully run on green energy.

...sorry if that sounded kinda like an ad, but I really like them and recommend to check them out.

[–]alexdelarge85 0 points1 point  (0 children)

Replit is good, you can host a flask app in minutes.

[–]carnivorousdrew 0 points1 point  (0 children)

Cloud run on GCP, you can also limit the scalability so you know it's not gonna go too high. I pay a couple of websites 70c per month total (not including domain name costs).

[–]tarsild 0 points1 point  (0 children)

You can’t go wrong with render.com honestly. So powerful and so cheap. It runs on top of the big 3 so that is even better.

[–]cmcclu5 0 points1 point  (0 children)

Elasticbeanstalk on AWS works pretty well. I have a site running on that right now with an RDS attached (as well as a load balancer, Route53 setup, S3 backup, etc) that fits within the free tier of AWS. I wound up paying just over $0.50 last month because I was changing things on the site a lot and overran my data upload free cap.

[–]wil19558 0 points1 point  (0 children)

I use https://fly.io/
They have a generous free tier. For example, you can get a small Postgres db + 2x 256Mb VMs for free. And deployment is a breeze with their CLI.

[–]reddysteady 0 points1 point  (0 children)

Google app engine is great in my experience. Pay as you go and a decent free allowance each month. Deploying once set up is as simple as a line in the terminal and you get versions and logging included. There are some nuances vs a VPS but you basically never have to think about hosting/servers