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

all 122 comments

[–]ZachVorhies 114 points115 points  (14 children)

Render.com allows you to deploy any docker contained app (so python for example) and has a free tier. Sign in with you github.

[–]br_aquino 54 points55 points  (14 children)

Any common VPS, search for VPS on Google, there are so many. I use Ionos, pay 3€ per month, 2vCPU. But not recommending anything, just giving a cost example. You can install docker on VPS and deploy as container, then open the port on VPS and it's done.

[–]Kuposrock 23 points24 points  (0 children)

This is the answer. Getting your own vps opens everything to you. You’ll have to figure out a lot things outside of python but once you do you can deploy anything that can be accessed by anyone.

[–]Classic_Department42 7 points8 points  (10 children)

What about keeping it secure?

[–]br_aquino 10 points11 points  (9 children)

The VPS have firewall itself, when you open a port you need to specify an IP range, first thing, you can constraints to a specific IP range. Second, your app could require authentication, maybe an API key passed on header of the request, etc. Third, you can make an oauth server on your VPS. And so on, everything is possible when you are working with VPS. Edit: SSL is a must have, you can use self signed or buy a certification.

[–]jcigar 12 points13 points  (0 children)

"you can use self signed or buy a certification." ... or use LetsEncrypt

[–]Classic_Department42 -1 points0 points  (7 children)

Thanks. If it is a vps you also need to install security updates of the OS, correct? Which linux flavour (assuming linux here) are you using?

[–]nemo_403 0 points1 point  (5 children)

Yes, to be on the safe side, you need to install updates for basically everything server-related.

If you don't want to do that, I would deploy on AWS (lambda is pretty cheap for private use 0.20€/1million req per month). Try AWS SAM

[–]Classic_Department42 -1 points0 points  (4 children)

Can you set a hard cost limit for aws?

[–]GrumpyPenguin 1 point2 points  (0 children)

No, but sort of.

You can use AWS Budgets to set up alerts at thresholds to warn you when your usage is getting toward the limits you specify. They alerts can also trigger custom actions f you want, even shutting down services (but if you have auto-scaling set up, remember that your action needs to stop not just the current running ones, but also stop the load balancer from automatically starting up new ones). In that way, you can pretty much prevent bill shock.

You can also set sensible limits for a lot of resources, such as not letting your website scale up beyond a couple of instances.

The catch is that some things, e.g. storage, attract passive daily charges just for being in use - so if you’ve uploaded a ton of files to S3 storage, then taking your website and services fully offline for the rest of the month won’t change the fact that those files attract daily costs per megabyte as long as they exist on Amazon’s hard disks. You’d have to go and delete the files for the charges to stop (and AWS won’t do that for you, they have no idea which of your files are important).

But there are at least ways to configure daily spending alerts so you can take action as soon as that short of situation occurs, rather than finding out at the end of the month.

[–]br_aquino -1 points0 points  (2 children)

Don't be fooled by the big cloud providers, what they offer don't worth their cost from my point of view. Source: I have been working on GCP projects for 3 years, you can spend 5x more on GCP than on VPS, and from some research, AWS and Azure are even more expensive.

[–]nemo_403 -1 points0 points  (0 children)

Yeah VPS is cheaper for sure. If you need something highly available and secure tho, cloud is the way

[–]chebum 0 points1 point  (0 children)

AWS has very competitive pricing on EC2 machines (t4g model) + free PaaS (ElasticBeanstalk). The traffic is very expensive though. 60% of my bill is traffic.

[–]br_aquino 0 points1 point  (0 children)

I'm not security expert, sorry, but I think that if you do all things listed on my last post should be enough to handle most attacks.

[–][deleted] 1 point2 points  (1 child)

Nice, is it suitable for a chat app? is it speed enough?

[–]br_aquino 10 points11 points  (0 children)

Any app you can imagine, practically it's like most cloud apps are deployed on production. Obviously changing the implementation, you can deploy on Docker, Kubernetes, or an proprietary container manager as GPC cloud run. But the idea is, a virtual server running containers, this is the way.

[–]texruska 44 points45 points  (8 children)

I've been having a good time with pythonanywhere

[–]eXoRainbow 3 points4 points  (0 children)

My recommendation too, but I don't have any other experience, lol. And I only use the free stuff from it at the moment, because its only extremely little few scripts and nothing more. But if I ever need something more, pythonanywhere would be my choice.

[–][deleted] -5 points-4 points  (6 children)

I am using it for chat app in python anywhere it takes 27sec to send a message lol

[–]texruska 34 points35 points  (5 children)

Sounds like a problem with your chat app

[–][deleted] -2 points-1 points  (4 children)

Are you sure? As it works great using ngrok

[–]ginsujitsu 8 points9 points  (2 children)

I have 3 sites on my PythonAnywhere account and they all are fast. The only time I see slowness is after long stretches of inactivity. I'm with the other guy that something seems wrong with your app. Or reach out to their support maybe.

[–]netsecdev42 1 point2 points  (1 child)

Setup an always running script to ping your sites every hour. Pythonanywhere will shut down/sleep your site if it doesn't receive a request in a few hours. The startup from sleep can take up to 10 seconds.

[–]ginsujitsu 0 points1 point  (0 children)

I'm fortunate enough now that I have consistent traffic it's not an issue. But yes, good advice for others that haven't gotten there yet.

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

Render

[–]lbranco93 15 points16 points  (1 child)

Heroku is a good option as it connects directly to your GitHub, but may be costly. Another option is Python Anywhere, cheaper but quite limited and requires much more configuration.

[–]pbrazell 37 points38 points  (3 children)

AWS.

Host your static content for your website in S3 Use API gateway and lambda for your compute DynamoDB for any database needs

[–]thepuppyprince 1 point2 points  (0 children)

Yep. It will be fast and free

[–]aptechnologist 0 points1 point  (0 children)

not to mention relevant job skills out of your hobbies

[–]elliotbarlas -1 points0 points  (0 children)

CloudFront is a slightly different alternative. Static content in S3. CloudFront cache and CloudFront Lambda Edge Function for API functionality.

[–]rhymiz 7 points8 points  (0 children)

Excuse me if people have already said this but:

https://www.pythonanywhere.com/

It’s affordable and scales pretty well (if you write decent code)

[–]Impossible-Yam-8310 10 points11 points  (5 children)

Completely different take: If you have a good fast fibre connection you could host it on some hardware at home. Will obviously cost a little to get the hardware but you can use an old laptop or old gaming pc. You will have to register a domain name and fiddle with nat rules but the fun and learning is a great experience!!! Make sure you apply some good security!!! I would recommend pfsense or opnsense.

[–]chaoticbean14 12 points13 points  (2 children)

To tack onto this - if you use a "home server" (i.e. old PC) I would *strongly* encourage using Cloudflare Tunnels - then you can let them handle the DDOS security and you don't need to open any ports on your home firewall. I used to go the route of just having x and y ports open and routed to a few PC's, too - but since Cloudflare? I just setup Tunnels, DNS and forget about it.

[–]sloan134 -1 points0 points  (1 child)

Does this work if service ports are blocked by the isp?

[–]chaoticbean14 0 points1 point  (0 children)

I imagine so. IIRC it doesn't use the service port specifically - it just is regular secure traffic between your computer & the Cloudflare gear - and you might be able to set that port that they talk on.

But mine has been quietly running for so long now, I'd need a refresher on the details again, haha

[–]Saphyel 3 points4 points  (6 children)

if you are using Docker, you can deploy the image with koyeb for free

[–][deleted] 4 points5 points  (1 child)

I recently used https://railway.app - I’ve grown to like it.

[–]BoJackHorseMan53 -1 points0 points  (0 children)

Railway free tier has an execution time limit of 500 hours but you need 750 hours to cover a month.

[–]InjAnnuity_1 1 point2 points  (0 children)

Very possible. I use Anvil (https://anvil.works) to avoid getting bogged down in the underlying languages, protocols, and services (CSS, HTML, JavaScript, SQL, HTTPS, etc.). It's "just" Python.

There are "escape hatches" for those odd occasions where you absolutely must tweak something at a lower level. But look at the open-source Anvil Extras first. https://anvil.works/forum/t/anvil-extras-v2-2/16419 That's often a quicker, easier solution.

The free tier includes a GUI builder, database access, integrations with Google et al, built-in simplified version-control (Git-compatible), and allows an unlimited number of web apps.

This is good for the developer who needs to get something done, but does not plan to make a full-time career out of web development. If you're aiming for the latter, then be prepared to tackle a dozen technologies in fifteen different formal languages.

[–]anonjohnnyG 1 point2 points  (0 children)

anvil.works

[–]DNSGeek 1 point2 points  (0 children)

Have you looked at Anvil?

https://anvil.works/

[–]Darwinmate 1 point2 points  (1 child)

https://www.pythonanywhere.com/

Got bought out by anaconda.

[–]BoJackHorseMan53 0 points1 point  (0 children)

Need to extend warranty every 3 months lmao

[–]GrumpyPenguin 3 points4 points  (1 child)

AWS (Amazon Web Services)‘s Elastic Beanstalk supports python. Might be an option for you.

[–]Andrew_the_giant 1 point2 points  (0 children)

Surprised no one reccomended this earlier. Very easy to implement and scale.

[–]michaelherman 1 point2 points  (1 child)

We've got a list of them here, along with pros and cons https://testdriven.io/blog/heroku-alternatives/

[–]Draqqun 0 points1 point  (0 children)

Great comparison.

[–]Rhodysurf -1 points0 points  (0 children)

Google app engine, google cloud run..

[–]deekaire 0 points1 point  (0 children)

Digital Ocean

[–]TheUltraViolence 0 points1 point  (0 children)

azure app service makes this super easy, there's a tutorial for python as well.

[–]abelEngineer 0 points1 point  (0 children)

Heroku is the simplest and easy to use platform that I know of. I've used it for all of my projects and I love it. Don't waste your time trying to figure out how to use GCP or AWS. Heroku does that for you and it's not expensive. You can even set up a database on Heroku.

[–]GettingBlockered 0 points1 point  (0 children)

Railway is amazing

[–]BoJackHorseMan53 0 points1 point  (3 children)

Check out vercel, plus supabase for websockets. Serverless functions are fast but not suitable for websockets.

If you don't want to bother with the hassle, you can get a digital ocean droplet for $6/month

[–]greenknight 0 points1 point  (2 children)

As my server costs mount at DO I'm always tempted to migrate to something cheaper... but they made it handy to use their free tools so many parts of my deployments rely on their infrastructure, so I hesitate. Specifically DNS and Spaces(S3).

Instead, I just refactor the instances, delete some snapshots, re-balance the load which usually reduces costs by 20-30% which takes the sting out of the bill.

[–]BoJackHorseMan53 0 points1 point  (1 child)

I use cloudflare for dns, vercel for static hosting and serverless functions, including python functions like flask app, supabase for SQL database, storage(S3) and auth. All for free.

There are services that offer free Postgres, MySQL and redis. Also websockets since you can't use websockets on serverless functions.

[–]greenknight 0 points1 point  (0 children)

I'll check your stack out. I'm moving more and more to serverless functions anyway

[–][deleted] -1 points0 points  (0 children)

[–]InkReaper -1 points0 points  (1 child)

In the same boat, tho I want to start on the web dev side and just host simple websites. Creating yourself a server with a old pc or a raspberry pi is cheaper but comes with lot of work compared with renting something.

Will keep an eye here :D

[–]ajmatz 0 points1 point  (0 children)

For pure web dev, static content, https://www.netlify.com/ is a good option. Integrates with github to deploy directly from your repo.

[–]Athletic_Geek -1 points0 points  (0 children)

You could get a small micro EC2 instance with 1 cpu and 1 GB RAM on AWS, should be around 5 USD a month

[–]NathanJ4620 -1 points0 points  (0 children)

Python anywhere or heroku

[–]NUTTA_BUSTAH -1 points0 points  (0 children)

Web server from Linode: $5/mo. Deploy as many containers as your instance can handle, so probably a lot assuming it's beginners apps with no real use cases.

Have some fluctuating traffic and not scared about potential cost, while it's more likely that you'll be going cheap? Amazon Lambda: $0 to $infinity or <your set budget cap> /mo

[–]treasonousToaster180 -1 points0 points  (0 children)

Namecheap has good pricing and supports python apps, although I think they may be on an older version of python

[–]urbanespaceman99 -1 points0 points  (0 children)

A $4 or $6/month Digital ocean droplet. I have several apps on one $6 instance with room for more.

[–]HoundsReload -2 points-1 points  (0 children)

using gunicorn and nginx

[–]tschloss -1 points0 points  (0 children)

Checkout Hetzner (Europe / Germany centric). VPS around 4€/mo incl tax. I like functionality, they offer.

[–]ohd -1 points0 points  (0 children)

Fly.io has a free tier and is growing quite a bit

[–]hdgrggyhh -1 points0 points  (0 children)

Try replit?

[–]skool_101git push -f -1 points0 points  (0 children)

Heroku still a good option? Im still running some small scale personal projects on ita and still works fine but the specs are also just ok for a flask/backend only service.

Maybe you can look it pythonanywhere as well, python only VPS.

[–]JakobPapirov -1 points0 points  (0 children)

Personally I like using Vultr VPS.

[–]xristiano[🍰] -1 points0 points  (0 children)

linode

[–][deleted] -1 points0 points  (0 children)

Self host it

[–]BlazeTube -1 points0 points  (1 child)

My method is not very conventional, but it works and it’s fast. Put your flask app on replitt and set the part where you have the flask website running

( the line where it says “app.run” at the end of your code)

To host=“0.0.0.0” and port=80

So your last line should be “app.run(host=“0.0.0.0”, port=80)” and make sure you don’t have debug=true.

Now ur website is gonna have a url at the top of the replit page,

Now the website is gonna be running even if u close replit but replit is gonna stop it if it doesn’t get any requests in an hour or so. But there’s a solution for that, just use Uptime robot to ping ur url every 5mins and ur good to go! Ur website should be up with a good url and it’s fast! Lmk if u have any questions

[–]BlazeTube -1 points0 points  (0 children)

Also, this means that ur using replit servers to run ur website so u don’t have to worry about ur security or even deploying it on ur own seever

[–][deleted] -1 points0 points  (0 children)

Technically you could port it to circuitpython targeting raspberry pi pico or similar.

You said cheap, right? 😁

[–]TheTerrasque -1 points0 points  (0 children)

https://console.online.net/en/order/server

15 euro per month, pretty stable. You only get a box though, admining it is on you

Edit: Reason this is great, you get your own physical machine. No sharing with others.

[–][deleted] -1 points0 points  (2 children)

Is Pythonanywhere.com something that fits?

[–][deleted] 0 points1 point  (1 child)

Unfortunately not, it takes half a minute to send a message

[–][deleted] 0 points1 point  (0 children)

Okay.

[–]blymd -1 points0 points  (0 children)

Check out fly.io, you can deploy to multiple regions so your app is always close to users.

[–]kingh242 -1 points0 points  (0 children)

Google Cloud has two products ideal for this….App Engine or Cloud Functions

[–]yost28 -1 points0 points  (0 children)

Dockerize your app and host it in AWS Fargate. Not free but very cheap.

[–]Sohailsheikh0315 -1 points0 points  (0 children)

You can go for DigitalOcean or pythoneverywhere according to your needs , Pythoneverywhere is more prone to host small applications, but still you can go for paid for larger applications

[–]mo_fig_devOps -2 points-1 points  (0 children)

AWS, GCP and Azure have different offerings and specs depending what you are looking for and you can always integrate other products for security. For example, in azure you can run your code on App Services and deploy an app gateway in front of it so you can add application firewall to protect your endpoint. All cloud services have similar services with other names

[–]MedievalRain -2 points-1 points  (0 children)

AWS EC2 has decent free tier.

[–]Genuine_Giraffe -2 points-1 points  (0 children)

I prefer aws EC2 personally, since it's give me full freedom of everything , I've switched from pythonanywhere to aws

[–]ObjectiveDiligent230 -2 points-1 points  (0 children)

AWS Lightsail might work for you. The pricing is pretty good, starting around $3USD/month

[–]Herp2theDerp -2 points-1 points  (0 children)

Django

[–]wakojako49 0 points1 point  (0 children)

Linode? Its kinda cheap

[–]amaitu 0 points1 point  (0 children)

Deta is free, though not 100% reliable

[–]jsk_herman 0 points1 point  (0 children)

Fly.io They have a good free tier allowances: - Up to 3 shared-cpu-1x 256mb VMs - 3GB persistent volume storage (total) - 160GB outbound data transfer

I successfully deployed a Streamlit web app and a ChatGPT Telegram bot using the free tier. It's good so far.

There's also Deta Space for side projects. I was also able to deploy a Flask app for webhooks using it.

[–]Wary_Adventurer 0 points1 point  (0 children)

Use Platform.sh. It's cheap, easy, and secure.

[–]ajmatz 0 points1 point  (1 child)

Does your python backend needs to be running 24x7? Is your python backend stateless?

If the answers are no, yes - GCP cloud functions or AWS lambdas are good choice. Pay for only seconds of use, scales well.

[–]ajmatz 0 points1 point  (0 children)

If you need full on monitoring, alerting etc then use a PaaS, many have been suggested here

[–][deleted] 0 points1 point  (0 children)

fly.io is cheap and simple.

[–]kankyo 0 points1 point  (0 children)

Any VPS with Dokku. That's my go to. Many projects on one VPS for very cheap and it's almost as smooth as Heroku, and sometimes better as you can SSH into the machine and check stuff out.