6 ms·
Any tips on how to run a site on a 5 dollar vps? I built an MVP on a 5 dollar VPS. But I had to recently upgrade to a 12 dollar VPS as some of my analytics pro
by anyfactor 4y ago
Any tips on how to run a site on a 5 dollar vps?
I built an MVP on a 5 dollar VPS. But I had to recently upgrade to a 12 dollar VPS as some of my analytics process were being stopped because of low memory. Aside from writing better code, I found out that using linux utils/app via system calls is the most effective solution as nothing I can write can ever be even remotely as performant as something like grep.
I am following a similiar path to yours but my stack is a bit complicated.
Python + SQLite on VPS
Vue/Nuxt + Auth on Firebase
The process is extremely hacky and experimental, so it might change. I am not planning to use a proper backend as the Python scripts communicates to the Firebase via its SDK. That is working for me at this moment and eliminates writing boilerplate API code.
- winrid 4y agoSqlite is cool but you'll find Postgres will perform a lot better on average and not use much more resources (it only needs like 16mb of ram by default...).
- solumunus 4y agoNonsense. For read heavy content sites Sqlite will obviously perform better.
- winrid 4y agoThat depends on the read patterns. Sqlite doesn't even support some features that will make very simple aggregations much faster on postgres, even with the same indexes. For purely sequential reads of data from disk, sure.
- anyfactor 4y ago> it only needs like 16mb of ram by default TIL. Thank you very much. I always wanted to invest more time in postgres, but I just find the Windows environment to be clunky when working with it. Like psql isn't supported in a windows environment (last time I check few months ago), and setting up the postgres environment on WSL was quite annoying as you have to figure out port forwarding. I know setting up a postgres on a local machine directly or even without docker may not be a mature decision, but that is the hacky reason, why I keep going back to sqlite, as it is the easiest solution to get started with a database.
- winrid 4y agoIf you're using an IDE, many have DB browsers built right in (all jetbrains IDEs for ex). But hey, nothing wrong with easy, usually. :)
- anyfactor 4y agoI honestly started with CSV files and google sheets as my database! People think I am joking but Google Sheet is a zero setup always on database and the API is friendly for basic operation. Also you have built-in version control. Once I started to feel limited by google sheets, I upgraded to SQLite. I will invest in postgres once I hit the ceilling with SQLite.
- lightning19 4y agoI run a SaaS that makes between $1000-$2000/yr on a $5 VM. My operations are as follows: On the VM: - Nodejs + React SSR - Nginx - Certbot to manage my SSL cert - Integrated with Grafana's cloud service (free tier) Outside of the VM: - Managed MongoDB cluster - API health check's every 3 min with email alerts (I use multiple uptime services to check from different regions) - DB backup cron jobs, backups are stored in 2 cloud providers - Service desk for customer's to send queries/raise issues - Alerts if CPU/RAM usage is too high (never got an alert for the past 2 years) I also nuke the VM once a year and re-provision otherwise you have to maintain the OS, do cleanup etc. Future work: - Find way to backup my DNS records - Probably need to monitor the SSL cert expiration in case certbot breaks - CI/CD
- anyfactor 4y agoThat is really awesome. > nuke the VM once a year and re-provision otherwise you have to maintain the OS, do cleanup etc That is really interesting. What are you using to re-setup your entire infrastructure after purging a VM? How do you manage the down time between one vm purge to setting up the next one. I would love to know, going beyond the VPS what is your total infrastructure + maintenance cost.
- lightning19 4y agoThanks :) I set things up again on the new VM manually. I have a runbook for it, usually takes me 30 mins or less. To not have any downtime I keep the old VM up and attach a new public IP to the new VM. I then update the DNS records and after a while when the new IP is mapped to my domain I then stop the old VM. Costs: Managed Mongodb cluster: $9 but I share it between multiple side projects so let's say $3 API health checks - free! I use digital ocean and fresh ping Service Desk - free! I use Jira DNS: Usually $0.3 DB backups: within the free tier on both cloud providers. I have it set to only keep the last x backups so this should always be free Cron job to run the backup: I have a serverless function for this, still within the free tier SSL cert - free because I use let's encrypt Docker image storage costs: <$1 Total ~$9.5
- 4y ago
- zhte415 4y agoMeasure how long a response takes, shave that. Count how many responses you're providing for a single request. Reduce them. See what can be done in parallel or out of order, do that. Check requests through time of day. Eliminate overload.
- jesterson 4y agoIt's very simple - avoid unnecessary and overcomplicated "cool" frameworks/technologies which modern development is infested as old house. I run heavy traffic EC sites on $20-30 VPS and can't imagine why you would need more, unless you do data analysis on same node. Fancy things like Vue/Nuxt are cool, but do you actually need it?
- jarebear6expepj 4y ago> Any tips on how to run a site on a 5 dollar vps? I don't know... from what I've used of Python it is pretty memory heavy and doesn't do well left alone unsupervised. I could be wrong but that was my experience trying various Py web frameworks. My app servers were all $5 VPS with only nginx, PHP/php-fpm, and Memcached. PHP was cached, nginx assets were cached, and data was cached in RAM with Memcached which was updated from remote DB server on cache expire. I would then stack as many of those behind a load balancer as needed (nginx as reverse proxy basically) and scaled up to serving 100's of terabytes of data monthly and billions of page views. So while it was "$5 VPS" it was really a small cloud of them behind another $5 vps as a load balancer with a $25 database server supporting the data. Still cheaper than Amazon for equivalent loads.
- anyfactor 4y agoThank you very much. The only thing I can think of while reading your comment was, "wow this is elegant." Have you consideres productize/templatize this stack and selling some kind license/supporting deal? Although a more marketable solution will be a redis + node based stack.
- jarebear6expepj 4y ago> "wow this is elegant." > Have you consideres productize/templatize this stack and selling some kind > license/supporting deal uhhh it's really just a basic install of freebsd and a bunch of shell scripts! As far as I'm concerned anyone with a bit of time could google fu themselves in to production. I am always happy to, and have, contracted to build similar setups for other people for CDN delivery, etc, but that was just another day in the life of a sysadmin basically. Email in profile if you have any other questions.
- anyfactor 4y agoThank you very much for the inspiration. I appreciate your insights.
- batmaniam 4y ago
- wcedmisten 4y agoNot OP, but I started up a project running Postgres, a Python backend (with FastAPI), and a NextJS frontend on the cheapest DigitalOcean droplet. Hosting+domain came to $7.68/mo I can't say it's had very much production load testing, but using the site myself it seems to work fine. https://wcedmisten.fyi/post/stateful-webapp-on-7-68-budget/ https://wcedmisten.fyi/post/stateful-webapp-on-7-68-budget/ https://github.com/wcedmisten/python-nextjs-template https://github.com/wcedmisten/python-nextjs-template
- anyfactor 4y agoThank you for sharing. I use mainly flask and restful flask. However restful flask has been deprecated, so I was really interested in FastAPI. Then someone pointed out the number of open issues on the FastAPI project, so I got spooked. Flask maybe has quite a few frameworks for implementing rest API. Not sure what the future holds for Flask. As you pointed out > A backend comes with all sorts of baggage: databases, managing user data, authentication, backups, and increased server load. With Flask being a microframework and barebones, going through this list becomes a chore unless you have built dozens of webapp and have some kind of template. So I kinda gave up on web-backend entirely and moved towards firebase. Most of the complicated stuff will happen on the VPS side of things and will be communicated to firebase via the SDK.
- wcedmisten 4y agoYeah that sounds like a good choice for managing complexity. Probably a trade-off with cost I'm guessing. For my project I was trying to get the cost as low as possible, since it's just a side project for me. Interesting point about the open issues, I didn't notice that, but does seem like it could be an issue for the longevity of the project.
- foolswisdom 4y agoI always liked fastapi and didn't have any problems, so your comment on issues made me check. Currently there are 16 open issues. However, I believe (based on vague memories) that there used to be a ton of issues on the fastapi repo that were basically support requests. Going throw some closed issues, it seems that these were closed and/or converted to discussions.