264 points · by scastiel · 2y ago · 148 comments
Thought about maybe running a Postgres VPS, but I've enjoyed using neon.tech more than I expected (esp. the GUI and branching). I guess the thing that has crept in: speed/ease is really beating out my ingrained cheapness as I've gotten older and have less time. A SaaS DB has sped things up. Still don't like the monthly bills & variability though.
Have you used SQLite with Litestream? That's the beauty of it. You can blow away the app and deploy it somewhere else, and Litestream will just pull down your data and continue along as if nothing happened.
At the top of this post, I show a demo of attaching Litestream to my app, and then blowing away my Heroku instance and redeploying a clean instance on Fly.io, and Litestream ports all the data along with the new deployment:
If anything, I'd probably end up looking at a dedicated PG VPS. I've started to get used to a few Postgres conveniences over SQLite, especially around datetimes, various extensions, and more sophisticated table alterations (without that infamous SQLite 12-step process), etc. So that's been an evolution, too, compared to my always-SQLite days.
> It’s a simple, open-source tool that replicates a SQLite database to Amazon’s S3 cloud storage.
That was a very long walk to get to that second quote. And it makes the first quote feel deceptive.
Can you share a bit more about why you feel it's deceptive?
The point I was trying to make is that database servers are relatively complex and expensive. S3 is still a server, but it's static storage, which is about as simple and cheap as it gets for a remote service.
Was it that I could have been clearer about the distinction? Or was the distinction clear but feels like not a big difference?
I'm not sure what you are hitting that would go past the capacity of a small vps.
Independent VPs for DB make sense, but if the requests are reasonably cached, you can get away with it (and beef up the backups) especially if it's something non-critical.
I'll be honest it's not documented as well as it could, some concepts like the archive process and the replication setup took me a while to understand. I also had trouble understanding what roles the various tools played. Initially I thought I could roll my own backup but then later deployed pgBackrest. I deployed and destroyed VMs countless times (my ansible playbook does everything from VM creation on proxmox / hetzner API to installing postgres, setting up replication).
What is critical is testing your backup and recovery. Start writing some data. Blow up your database infra. See if you can recover. You need a high degree of automation in your deployment in order to gain confidence that you won't lose data.
My deployment looks like this: * two Postgres 16 instances, one primary, one replica (realtime replication) * both on Debian 12 (most stable platform for Postgres according to my research) * ansible playbooks for initial deployment as well as failover * archive file backups to rsync.net storage space (with zfs snapshots) every minute * full backups using pgBackrest every 24hrs, stored to rsync.net, wasabi, and hetzner storage box.
As you can guess, it was kind of a massive investment and forced me to become a sysadmin / DBA for a while (though I went the devops route with full ansible automation and automated testing). I gained quite a bit of knowledge which is great. But I'll probably have to re-design and seriously test at the next postgres major release. Sometimes I wonder whether I should have just accepted the cost of cloud postgres deployments.
I'm heavily inspired by it and working on an app for book clubs to host "elections" to choose their next book to read using a variety of voting systems (ranked choice, approval, scored, first past the post, etc).
One thing I find interesting is the growth chart: It's linear. But given that the app clearly has some traction, and is viral in nature, how come it isn't exponential?
I suspect that the architecture can be improved to get the cost down.
- Don't host anything media-heavy (e.g. video streaming)
- Make sure you have reasonable upload speeds (probably 10+ Mbps min)
- Even behind Cloudflare, make sure you're comfortable with the security profile of what you're putting on the public internet
The min upload speed is mostly about making sure random internet users (or bots) don't saturate your home internet link.
One thing I’ve been interested in is the idea of decentralized handling for this. That is, the project is funded in and every month if its bills don’t get paid it dies. If it receives enough to go over it buys T-bonds for the appropriate duration and then burns them down over time.
Perhaps in the past it would have to be automated but I wonder if in the near future a limited AI agent could be the server and you leave him alone to do his thing.
One thing that drives me crazy is it works really poorly on slow mobile connections. I'd really love to try to add local first or offline first support but I know it would be a significant change. However, even just caching pages like the add expense page would be a nice improvement.
The web hosting costs basically nothing. Most of the cost comes from the database.
Modern computers are mind-bogglingly powerful. An old laptop off eBay can probably handle the load for business needs for all but the very largest corporations.
As someone who is literally using old laptops to host things from my basement on my consumer line (personal, non-commercial) and a business line (commercial)...
I can host this for under 50 bucks a year, including the domain and power costs, and accounting for offsite backup of the data.
I wish people understood just how much the "cloud" is making in pure profit. If you're already a software dev... you can absolutely manage the complexity of hosting things yourself for FAR cheaper. You won't get five 9s of reliability (not that you're getting that from any major cloud vendor anyways without paying through the nose and a real SLA) but a small UPS will easily get you to 99% uptime - which is absolutely fine for something like this.
* Usage won't be uniformly distributed and you may need to deal with burst traffic for example when a new version is released and all your users are pulling new config data.
* Your application data may be very important to your users and keeping it on a single server is a significant risk.
* You're users may be geographically distributed such that a user on the other side of the world may have a severely degraded experience.
* Not all traffic is created equal and, especially paired with burst traffic, could have one expensive operation like heavy analytical query from one user cause timeouts for another user.
Vercel does not solve all of these problems, but they are problems that may be exasperated by a $4 droplet.
All said I still highly encourage developers to not sell their soul to a SaaS product that could care less about them and their use case and consider minimal infrastructure and complexity in order to have more success with their projects.
That said, I completely agree-a $4/month DO VPS can run MySQL, and should easily handle this load; in fact I’ve handled far bigger loads in practice.
On a tangent: any recommendations for good US-based bare metal providers (with a convenience factor comparable to OVH, etc)?
I was surprised by the cost of Vercel in that blog post too, which is why I dislike all kinds of serverless/lambda/managed services. For me, having a dozen people subscribing to $1-$2/month sponsorship on GitHub Sponsors is enough to cover all the costs. Even if no one donates, I’d still have no trouble keeping the project running on my own.
How many times per second is the DB actually accessed? As far as I can tell my the metrics, they're doing ~1.7 requests/minute, you'll have a hard time finding a DB that couldn't handle that.
In fact, I'd bet you'd be able to host that website (the database) in a text file on disk without any performance issues whatsoever.
You can read a little bit more about my analytics setup here:
https://joeldare.com/private-analtyics-and-my-raspberry-pi-4...
Very possible.
OTOH If you want managed Postgres it seems like you always have to pay a fairy high minimum.
It does feel like the tech community as a whole has forgotten how simple and low resource usage hosting most things is, maybe due to the proliferation of stuff like AWS trying to convince us that we need all this crazy stuff to do it?
If banks would get their head out of their ass, this would be a native feature with ach/zelle/fednow as the backbone. Organizer creates group in bank app and can invite other users which may have different bank accounts. Payment requests satisfied through 1-click. No more manually checking if Cashapp/bank accounts/venmo have received payment then checking off the expense in third party app
I'm 99% sure I'm reading something wrong, as that's incredible expensive unless this is hosting LLM models or something similar, but it seems like it's a website for sharing expenses?
A more charitable reading is that they pick the technologies that the jobs they want are hiring for, even if they don’t make sense for this simple application.
I'm not sure, I'm also "new generation of devs" I suppose, cloud had just entered the beginning of the hype cycle when I started out professionally. Most companies/individuals at that point were pushing for "everything cloud" but after experiencing how expensive it really is, you start to look around for alternatives.
I feel like that's just trying to have a "engineering mindset" rather than what generation you belong to.
One would think that to be the common sense case...but, in corporate America - at least the last handful of companies that i worked at - some companies are *only now just getting work loads up to the cloud now*...so they have not yet felt the cost pain....Or, in other cases, other firms are living in the cloud, have seen the exorbitant costs, but move waaaaay toooo sloooow to migrate workloads off cloud (or hybridize them in smart ways for their business)....Or, in even other cases that i have seen, instead of properly analyzing function and costs of cloud usage - and truly applying an engineering mindset to matters - some of these so called IT leaders (who are too busy with powerpoint slides) will simply layoff people and "achieve savings" that way.
Welcome to being a technologist employed at one of several/many American corporations in 2024!
It's certainly possible to spin up your own db backup scripts, monitor that, make sure it gets offsite to an s3 bucket or something, set yourself a calendar reminder to test that all once a month, etc... but if I had to write out a list of things that I enjoy doing and a list of things that I don't, that work would feature heavily on the "yeah, but no" list.
DHH (Rails founder) thinks you should dare to connect a server to the internet: https://world.hey.com/dhh/dare-to-connect-a-server-to-the-in...
(I already submitted this once, but given the discussion here, I think it's worth posting again, if my rate limit allows it)
I unfortunately sorta put myself in this category where my PaaS of choice is Firebase. For this cost-splitting app however, what would you personally recommend if not Vercel? Would you recommend something like a Digital Ocean Droplet or something else? What are the best alternatives in your opinion?
You'd have a Linux machine (the VPS) that would have at least 3 programs running (or it is running Docker, with these programs running inside containers):
- Node.js
- the database (likely MySQL or PostgreSQL)
- Nginx or Apache
You'd set up a DNS record pointing your domain at the VPS's IP address. When someone visits your website, their HTTP requests will be routed to port 80 or 443 on the VPS. Nginx will be listening on those ports, and forward (aka proxy) the requests to Node, which will respond back to Nginx, which will then send the response back to the user.
There are of course security and availability concerns that are now your responsibility to handle and configure correctly in order to reach the same level of security and availability provided by a good PaaS. That's what you're paying the PaaS for. However, it is not too difficult to reach a level of security and availability that is more than sufficient for a small, free web app such as this one.
I was surprised how extremely easy it is to get set up with Coolify on a Hetzner VPS, which has preset install options for NextJS + Supabase + Posthog + many others. And I get the standard autodeploy on commit functionality. The open-source versions are missing some features, and I don't get the slick Vercel admin interface, but for a pet project it works great. I'm also by no means a sysadmin expert, but with ChatGPT it's pretty easy to figure things out now.
Even less when I pay for a dedicated machine running all of my hobby projects. Gratuitous Kamal 2 plug. Run your personal projects all on one machine.
First thing I thought while reading was Firebase - it's interesting how much it would cost there.
... Should be more than enough to handle 2 requests per minute, could probably handle 100x of that.
So it should be able to handle somewhere in the ballpark of 2,000,000x the required load, or maybe 100,000x without the application level optimization.
(TLS reduces this by a factor of ~10 if you're doing handshakes each time. Despite what blogs claim, as far as I can tell, if your CPU doesn't have QAT, TLS is very expensive)
Of course doing SSL on the server itself is more secure, but if that's a performance bottleneck the load balancer can be a cost effective compromise
Then you get to determine gains you may get from caching and other potential optimizations from one of the best eyeball connected providers in the world. Oh plus the ability to fend off the largest DDoS attacks ever seen.
Cloudflare tunnels enable you to do all of this through an encrypted tunnel without exposing the machine/services to the internet at all. Cloudflare will still MITM all traffic but so does Hetzner (obviously). At least with the tunnel the connection is persistent so you don’t incur TLS handshaking, etc CPU overhead with each client connection.
Bonus points - you can move hosting providers without any hassle, configure hosting provider redundancy (Hetzner + whoever), all of that stuff.
> A short disclaimer: I don’t need donations to make Spliit work. I am lucky enough to have a full-time job that pays me enough to live comfortably and I am happy to give some of the money I earn to the community.
And this is why open source will finally die, because being comfortably employed while still having surplus time and energy to work for free is an increasingly rare thing among the younger generations.
A better way to "give back to the community", instead of making open source software, would be to purchase software from other indie developers.
We already have a profit-oriented market. And we have empirical evidence that profit-oriented markets do not like open source (for their primary products).
> being comfortably employed while still having surplus time and energy to work for free is an increasingly rare thing among the younger generations.
edit: remved anecdote
The cost of living will never rise so much that the upper 50% can't easily make enough money. (Otherwise what? The other 150 million people go homeless?)
And unless our industry sees a major shift, which I don't see happening, software engineers will continue being comfortably in the upper 50%.
That's a given. If you open source your code, other developers will steal it and sell your software. Just like billion dollar tech companies are the main benefiters of open source today, that some guy made for free. Excuse me, I meant for $42 in donations.
I haven't published any software at all recently. But if I did (anything non-trivial), it would be AGPL. Or even SSPL.
Permissive licensing (MIT, BSD, Unlicense, public domain, etc) is a scam to make you work for companies for free - if your software is worth anything to them, that is. They told developers they should use MIT licenses so more people would use their software. That's true. They didn't ask whether that was a good thing.
Even if my libraries were used only by mega corporations (which they aren't) there would still be a benefit to the public: If companies have lower cost, they will charge lower prices, benefitting customers / the general public. (And yes, they will lower prices. Most markets are not monopolies.)
Work for free for huge companies so they can make billion dollar profits while at the same time demanding unionization. Refusing to sell your work to consumers who are willing to pay, yet happy to provide free tech support to free loaders who wouldn't give you a cent. What's the logic?
Some of us like making things, and are happy to share our excess production with the world.
Like any other good work, it does not require acknowledgement or reciprocation, and the benefits are not part of a zero-sum economy where the giver is harmed by any action of the receiver.
You're on record as being vehemently anti-OSS. Why does it offend you so much that other people prioritize forms of compensation differently than you do?
To clarify some confusion in this thread, it might be helpful to distinguish "open source" (the application) from "free" (this hosted instance of the application). Munging the two together might lead to some incorrect conclusions. Running a "free" application for others is going to have certain costs. The cost of running an "open source" application is going to depend entirely on the resources that application consumes, which, if run privately, might be a lot less.