289 points · by caspii · 6y ago · 257 comments
For comparison at the other end of the scale:
Facebook said that in the first quarter it spent $3.7 billion on data centers, servers, office buildings and network infrastructure.
https://www.datacenterdynamics.com/en/news/facebook-signific...
That's something like $8 per user per year. If you had that level of expenditure for your 55k-user app, it would cost $400,000 per year, 200x the cost given by this blog post. It isn't that Facebook is wasting the vast majority of their infrastructure, though, it's that the application does a lot more for each user.
I suspect that one particular aspect of Facebook's operations - the nation-state level of spying on its users and the people they mention - accounts for a significant part of the difference.
I don't even understand why they need a VPS at all. It seems simple to run off of firebase and cloudflare for the UI.
-> Facebook is making far more than 10$ per user? Jesus Christ.
Source: https://www.statista.com/statistics/234056/facebooks-average...
I don't think we can be sure Facebook isn't wasting money on their infrastructure. They've shown themselves to be pretty wasteful in the past.[0][1] They're just rich enough to get away with it.
Facebook's application may be doing a lot more to their users than a simpler app, but I doubt it's doing that much for users.
[0] https://www.cio.com/article/3197554/why-is-facebooks-ios-app...
[1] https://jaxenter.com/facebooks-completely-insane-dalvik-hack...
Just running Facebook, Instagram & Co as a platform would probably be much cheaper than $8 per user.
I have web applications running that reliably serve 50k users per day and cost me $10/month, running on a single, cheap VPS.
It's great that your web app only costs $10/month but others may have web apps that are more computationally intensive e.g. video processing or ML inference etc or simply can't join everything they need at runtime.
And it's great that you're willing to deny those 50k users a day access to your service when that cheap VPS inevitably falls over. But others may be monetising that traffic and will want a HA solution so their revenue isn't impacted.
All of those add complexity and cost to an architecture.
The fact that this person is spending nearly as much to support 50k users a day as I do to support more than 4 million cannot be hand-waived away by "people are so free to judge other's[sic] situations". The matter is worsened by the fact that the application is so simple that it doesn't even support user accounts. There is room for discussion here about efficiency in application architecture. More importantly, an article billing itself as "Costs of running a Python webapp for 55k monthly users" is silly because there is no way this is representative of anything. I'm afraid new hackers will be scared by the high costs listed here and be discouraged in their own efforts.
Another consultant that came in and try to do this, made our costs go up by 10x per month… so i'm not surprised when I see stuff like this here…
The knowledge of ones tools available at ones finger tips and the relative costs of such seem to make the difference for these things.
There’s statistically a 95-99%+ chance you’ll never get to 55k monthly users with your app so don’t worry!
And it explains there's currently zero revenue.
So it seems fair to judge the situation there based off those pieces of information we've been given.
As I posted elsewhere, the OP's choice to run dual redundant green/blue capable instances and cloud hosted metabase might have good reasons, but right now those reasons are not "wanting a HA solution so revenue isn't impacted"...
Green/Blue is all about saving resources and costs, not keeping them around. You misread the cause here. It has nothing to do with deployment strategies.
EDIT: not sure why I'm downvoted, I'm just presenting my use case. They are multigigabyte images encoded with custom wavelet compression that are cut into tiles (think google earth), each user needs 5-10 tiles every second
If you're just serving them (eg no image manipulation), that sounds like there's a problem somewhere.
In my mind, choosing a dual redundant prod platform so you can do blue/green deployments is _totally_ unnecessary for a 55k MAU site generating no revenue. Same with cloud hosted metabase. You could run that on your own hardware - a spare laptop or probably even a raspberry pi for effectively nothing.
On the other hand, a hobby project/side gig where you can demonstrate real world experience in those two things could _easily_ pay off in the first week of a new job it helps you land.
If it's _just_ that extra $100/month they're spending there, it seems difficult to justify. If it's commercial experience doing that which is helping him try and land a job paying 20k or more extra per year? That's totally money well spent, in my opinion...
This app could easily be run on the AWS free tier, although even in the paid tier he could probably be managing a lot more than this workload for under $40 / month. (That's for two servers - which as has been pointed-out is wholly unnecessary for an app of this size.) The price he's paying is presently listed at $95.
Maybe I read his conclusion differently, but he said "would be peanuts" about the cost and "The bigger issue is that on the revenue side there’s a big fat zero."
Seems to me he's acknowledging he's built a thing that requires generating revenue to support itself, but that he's neglected the revenue generation part of his project, rather than complaining too much about the price of running it?
I'm mostly agreeing with you (and tristanperry and TekMol), but I'm probably being more sympathetic and ascribing un-supported motivations for why he's happy enough building it this way and spending this much money to run it. (Probably because I've been there before myself, and sometimes that expensive hobby project has paid off, sometimes it hasn't. I've never spend so much I've seriously regretted any of my failures though...)
Pre-compute and cache to reduce your need for beefy servers.
When you can run something on your machine or in the cloud, choose your machine.
EDIT: It's less about saving money and more about not spending it.
EDIT2: Forgot to mention: use SQLite.
During a single request there might be 50+ cache-lookups, each taking a round-trip to a remote redis server to fetch a single key at a time. Batching those up to a set/hash would have been more efficient, but the codebase had evolved in such a way as to make that difficult.
Instead of making 50+ redis fetches it turned out that just fetching all the stuff from the database was faster.
(There will be refactoring to batch up the key fetches, but for the moment there was a measurable increase in performance under current loads just by removing redis.)
My postgres process doesn't come close to using up enough resources to push me out of even the cheap VPS tiers and I don't have to worry about locking if there's a heavy write load.
Step 1:
Copy Peter Levels stack:
https://www.nocsdegree.com/pieter-levels-learn-coding/
If he serves hundreds of thousands of monthly users and makes a million a month with a single VPS, you certainly won't have scaling issues when you start out or just have tens of thousands of users.
Step 2:
If you really scale beyond that, resist the urge to bloat your stack. Think long and hard about every piece you add to it. Really understand each piece you add to it. Don't fall into the trap of paid services. Don't fall into the trap of "best practices".
Honestly, spending $200/mo is insignificant to me. And I'm pretty happy to answer the question of "Why can this guy build this thing on a single VPS and you can't?" with "Well, because he's better than me".
I can be up in 15 mins on Heroku with a Rails+React web app. And in an hour have a thing. Or for a static no-login thing, faster with Netlify.
But it doesn't matter. Because I never made a product as nice as the one he made. If the outcome is I'm -$200/mo that is irrelevant to me. If the outcome is I'm +$50k/mo that is very relevant. So I'm going to optimize for how I can do the latter.
Its an aside, but the mentality of "let them figure it out" is a major issue in education. Foundational knowledge should be easy to acquire so I can worry about higher level thinking issues. Literally spending hours trying to figure out how to set things up through hours of Googling doesn't really help that, nor does it promote the "figuring it out" people think it does - its just stumbling upon the right set of commands that let me move past this particular hurdle.
From the devops perspective, what about telling someone how to set up their own server to do/minimize X is so taxing?
I wouldn't want to read (or write) that code, but thanks for the article.
It is a common misunderstanding amongst software engineers that infrastructure serves "performance". Most of the complexity comes from redundancy and analytics (, realtime especially).
the servers are oversized for the load we're currently seeing. The reason for that is that we tried to solve a production issue by increasing the server specs. It didn't solve the problem, and now we can't down-size the servers without re-provisioning them ️.
You should really learn to add new servers by provisioning them and remove the old servers. Your app seems a perfect fit for it for moving between servers.
The bandwidth usage is just way too high and video compression requires GPU compute.
If my dev uses a slow stack or doesn't optimize v1, maybe I spent $100/mo instead of $10/mo.
Hell, let's say I'm spending $500/mo.
My mixed rate is ~$75/hr for dev time, so a week of dev time is equivalent to 6 months of hosting.
If optimizing (or using a difficult stack) takes one dev an extra week, then I'd better save $3,000 of hosting.
Here’s a bigger point:
If you’ve got 55,000 monthly active users, and $171 per month doesn’t feel like a rounding error to you, then what you made isn’t actually valuable.
Spending any amount of hours to reduce that already small number is a giant waste of time for anybody who has that level of traction.
How much does running a webapp in production actually cost? Maybe more than you think.
So they seem to be trying to "educate" people, when they are wrong and basically giving away a lot of money to Amazon and DO.
And that's why everyone's chiming in with "lots of unnecessary YAGNI crap you got running there!".
There are forums with more traffic than this, which don't make money. They're hobby projects.
However, money is the universal way to measure value. And if you think that you create an enormous value for the community, and it's something that is important to you personally, paying a few hundred bucks a month for it should be a no-brainer.
You heard it boys, unplug those DNS servers, delete 4chan, teardown XKCD, they are worthless!
They mention using a blue-green deployment strategy and a managed database service. That implies their web servers are stateless, or at least stateless enough to switch between the servers seamlessly.
But then they go on to say they don't want to downgrade because it means provisioning new servers.
Even in the worst case scenario of not using configuration management tools, aren't we talking a few hours of work here to save yourself let's say $40 a month which is 25% of their monthly bill? That would be the cost savings of downgrading to a lesser server x 2.
With configuration management tools, spinning up a new server would typically be running 1 or 2 commands and waiting 5 to 10 minutes. That's about how long it takes me to spin up a new server on DO to run a Flask application using Ansible and most of that time is because Ansible isn't exactly well known for its speed to execute tasks.
For the server instances, I can't imagine 4 CPUs/8 gigs RAM is really needed 24/7, but can imagine it being needed in bursts, and I assume GCP has various "elastic" auto-scaling products for that. Would love to know if your metrics indicate that this is the smallest box you could comfortably run on, or if it's just a best-guess. Could potentially spin down blue-green environments after some set amount of time (once you know a deploy "succeeded"), as well.
For Metabase, I can't find any "system requirements," but I'm not _super_ shocked by the price tag. I've always liked the idea of hosting my own tools instead of relying on some SaaS's free/trial tiers (particularly for things like analytics, logging, or metrics), but a lot of the open source options out there assume you have a pretty hefty box to throw it at. At the same time, I haven't found any better alternative other than just doing ad-hoc analyzing in SQL (using a GUI like Postico).
As for web servers, you're totally right. At feeder.co we serve 25 requests / second (on Rails) per VM (we use 4 web servers and one loadbalancer) and we're still database constrained. They are $20 per month and the 4GB 2VCPU "basic" plan.
Hardware is insanely fast nowadays, and it feels like we forget to realise it sometimes.
*using a heroku standard-0 db, so $50/mo with relatively good performance
Yes, the server instances are definitely too large. I was previously running on 2 instances that were half the size and ran into some problems which I thought I could fix by increasing specs. Turns out the problems were not related to specs and now I'm stuck with the instance size (on DigitalOcean you can only up-size not down-size)
I use Postico too, but don't have enough SQL chops to get the answers I need.
* replace the currently inactive server with a smaller instance
* swap to the new instance and test the load
* replace the second server
For such a small app I’d drop the blue/green (most deploys will likely only take a few seconds?) and host Postgres on the same server.
Also, I’d move metabase onto a DO instance.
Any reason you’re using DNSSimple over a cheaper provider (or free in the case of DO)?
Getting to a place where you don't care as you can rotate in new instances at whatever spec you want is even better though.
The only thing I wanted to say is that the time spent learning a bit of SQL pays off massively. Perhaps something for your todo list :)
Often in cloud computing it’s dev time, ops time, cost savings, choose one.
What limitations/constraints of App Engine have you run into?
Metabase is cool but you could probably use Mode Analytics free tier.
My gosh, you are polling each leaderboard for changes every 15 seconds. Again, I would bet perhaps 1 in 1000 mature boards (i.e. online for more than a day) change in any 15 second period. You could severely reduce your server load by utilizing a CDN and statically-generating any board which hasn't changed in say, the past 6 hours.
It is really disconcerting to see that doing similar "do-it-yourself" hosting activities nowadays appear to cost twice as much (judging by the article) while the "raw msterials" - core backbone traffic, compute power, memory and storage - all have gotten waaaaay cheaper in the last decade. Too many new rent-seeking middlemen, I guess...
Too late for them, but if you find yourself similarly needing to increase the capacity to solve a produciton issue on DO: you can upgrade CPU/RAM without increasing disk size. This allows you to downgrade later if you end up over-provisioning.
They're only spending $69/mo total at DigitalOcean, and it sounds like their scaling isn't limited by computational power but rather by operational concerns. So, I'm not entirely sure what the backend language has to do with the costs here.
If you're trying to draw a cost comparison between languages, then the take-home from this writeup is that 55k monthly users is small enough that the backend language doesn't make a difference in costs.
Side note, this kind of transparency is always really nice to see!
I mean, why are you even doing analytics if you’re not generating revenue?
Further,Are you absolutely sure that you have optimised your configuration and code for performance without changing the stack? (Serving static components directly via ngninx, caching responses using flask, caching other resources using memcached, optimizing gunicorn worker counts for the instance type, profiling which endpoints take the most amount of time and trying to optimize them, see if the bottleneck is webserver or the db, considering pypy, and probably 50 other ideas).
Are you also absolutely sure that bluegreen deployments are what you want to use given your cost constraint? Further, if you have bluegreen it should be straightforward to downgrade your instances to smaller ones fairly easily,why not do that first before discussing costs?
We run production webservers on t2.small ec2 instances in elastic beanstalk and (with some assumptions) handle comparable loads during work hours. We have two redundant instances and can easily scale up or down even on schedule with zero extra code. There's not even a need to minimize costs here because our application costs 100x more on data lake costs than the webservers, but it really helps keep the engineers grounded and ensuring they don't write outrageously inefficient code that's covered up by excessive server sizes.
Not that I'm saying you should use Disqus since they have some privacy issues
I was excited for Commento and signed up for a paid plan. I even contributed code.[0] The author sent me an onboarding email which included the line, "please reply to this email (I'm a real person)." I replied with some questions about the service and billing, but he never responded. Four months later, nobody has responded to my merge request, either.
I canceled my service at the end of the month.
Basically, at some point it gets expensive of course but when you are simply testing out stuff and don't expect a lot of users to show up, it's actually not bad.
Obviously don't use this if you have a lot of cpu/memory requirements but otherwise this should be fine for a well crafted stateless server.
Startup is fine with both ktor and spring-boot but obviously takes a bit of time. I noticed there's startup overhead if your container gets shut down because there is no traffic. In that case, it takes around 30 seconds for the first request to go through. That includes everything from booting the container and then starting the process. I imagine simply pinging the server regularly should keep it running. Alternatively, you can configure a minimum amount of servers.
Based on the Techempower benchmarks: https://www.techempower.com/benchmarks/
You can find Java frameworks that are significantly than any of the Python ones. Or you can find ones that are significantly slower.
They mistakenly deleted all of my virtual machines and all of my backups.
If you host anything with them, or anyone I guess for that matter, make sure you have your backups hosted somewhere else.
They sent me a boilerplate e-mail that there was a problem with my account and to contact them to resolve it. I called them within 10 minutes, and they told me 'your account doesn't exist'
They restored my 'account' which means i had a user with the same login and password, but all of the assets to the account were tossed to the wind.
I can only guess that someone jumped the gun, (assuming they had an internal process at all).
However, you should be treating your VMs as disposable and not as pets.
VMs can be disposable, but if you have data you want to keep, you should have a second copy hosted by a separate organization .. well that was my lesson anyway.
I'm mostly just using digital ocean these days. Their API is fantastic.
These days I do a better job of keeping code in github even if I'm the only user, and backups can go anywhere as long as you're not relying on the same provider.
But what caught my eye was DNS Hosting: 5$/Month? Maybe it's a typo, shouldn't be more like 10$ per year to host a domain and its DNS?
Anyway, thanks for sharing, very interesting.
DNS hosting can be cheap (free if you use cloudflare, etc), or very expensive. My prices give me a 50% margin over the raw AWS Route53 costs, but the appeal is that I store records under revision control and let you make changes using git:
AWS charges you a flat-fee per zone, and then additional-fees based on volume of queries. In my case I don't host any domains that go over the threshold where it is billed for - but if I did those costs would be offset by the profit of the other low-volume zones.
That said, are you making the right tradeoffs? Most of your spend is going to 'luxury'. Dual overcapacitated deployments, hosted managed Postgress, hosted Metabase.
It does sound like you could very significantly reduce your spend almost instantly with just a few minor changes, and dramatically if you would do a rethink of your stack.
4 vCPUs, 8GB RAM, 80GB disk costs $40/month now so two servers alone cost $80 which is higher than $69.
Either DO raised pricing or they got some special discount.
Or if you really insist on a VPS, you can get the same configuration with double the disk space at Hetzner for 15.38 per month at Hetzner.
I have a Hetzner VPS and it has been rock-solid.
(I know that they are in Europe, but I assume that there are similarly-priced competitive US counterparts.)
I'm going to edit the article.
I'm very confused what the value add is for this service.
One small advantage I've noticed with Linode over DigitalOcean is that you _can_ perform these down-sizing actions (without some messy rsync scripts or snapshot-and-recreate approach that DigitalOcean suggest). You first need to resize the disk down to the lower Linode's limits, and then you can down-size to a smaller instance.
They could save a good chunk of the 69 USD they spend on Digital Ocean servers.
edit : To clarify, What I meant was that to serve 55k users, perhaps using more efficient languages like C# or Java, would allow them to run on lesser spec machines. And as those users scale up, to say a million users a month, perhaps savings would also increase, if using more performant languages.
1. How do you define "healthy". 2. Genetic abilities. 3. Overall health. 4. Eating habits. 5. Your geographical location. 6. Your daily routine ..... X^60000. {Factor number X^60000}
There are an infinite amount of buttons and dials that will determine how much "X monthly users" will set you back. Back in 2011 I used to own a blog that had something along the lines of 25k daily visitors. My annual bill was less than 100 bucks, domain included. And keep in mind that this was way before AWS, GCP and Azure came into the picture and costs were much higher than they are now. But I had spent months investigating the cheapest and most efficient ways to cut down costs. And it's the same with cloud providers - they can be brutally expensive or dirt cheap for the exact same thing if you don't take your time to see which and what is the best solution for your use case.
Pretty much every bigcorp I've ever worked for has some crucial service on a box under someone's desk...
(plug) Regarding Disqus, I run a competitor which you might like: https://FastComments.com
1. Whenever I see a new company's/project's runtime, I have come to expect a massively overcomplicated system that is "built to scale". But ends up costing a lot and taking way too much time from product-development. A real issue with this is that when looking at the project's feasibility to actually do scale, the runtime-cost will be estimated to a multiple of the current runtime cost which will appear larger than if the systems were built to handle the current load.
2. To me, this seems like a failure of cloud computing, which has a very compelling promise of letting you start with small servers, then easily switch up to bigger servers when needed. This was, in fact, hard before cloud.
3. The biggest issue I have with overspeced and overly complex deployments, is that to me it appears like (novice) developers is led to believe that they have to do the job in a complicated way. Look at a typical tutorial from the big and trend-setting players how something should be deployed. The first hit on my favourite search engine for a "Hashicorp Vault deployment" [1] recommends using nine hosts. I know from experience that it runs fine on ONE host of the smallest kind I could find for our non-trivial use-case. Also, in that use-case it doesn't matter that it is not HA, because it has turned out to be more stable than any of our other stuff, and can be restarted in a less than a minute. (I wouldn't mind at all, if the actual motivation for a large deployment was: "it is fun this way" or "we do this for our own training and experience" or "we choose to do it this way because of specific requirements" or anything of the sort.)
4. It seems to me that, what is needed is enough experience and courage to say: let's do our deployment and setup in a simple way that will work, because we know that we are competent to solve scale issues when they appear and we are not building ourselves into a corner. Also, we can afford to take responsibility if scaling problems do occur because we did not follow industry "recommendations" (i.e. trends).
[1] https://learn.hashicorp.com/tutorials/vault/deployment-guide
Edit: - clarified HA needs in point 3
Does anyone know the minimal provisions they could potentially use in this case?
It’s written in PHP/Go/MySQL
I am on a $10 a month Digital Ocean Droplet hosting like 7 other sites as well, and it’s probably overkill.
I read the top item as 6g aka 6,000 and the next (aws) as $60 and they were like "we can likely cut here".... yo you're spending $6k on the other thing cut there first... reading again yeah true.
Are you blocking fonts.gstatic.com? It's loading the font (Raleway) from there.
Its just trial and error
I thought that was going a really different direction than it ended up going.
55k users is very valuable. If you make a single cent per user per month, you’re in the black operationally (not counting dev time). If you make that into a dollar, you get to quit your job and be upper-middle class indefinitely.
Those were all paid users and the company was profitable with over 70% net margins after all costs including labor and research were factored in.
I’m all for $5/month digital ocean hosting when it makes sense but you also need to be realistic if there are revenues. Hosting should not be a major cost for the business.
Also, related aritcle -> https://m.signalvnoise.com/only-15-of-the-basecamp-operation...
Has the developer thought about using donations instead of ads?
oh yeah, and 10$ a year domain fee
Edit: Guys if you down vote at least let me know what I'm clearly missing... Does dnsimple do something google domains can't?