7 ms·
The biggest thing we're going to regret looking back on the early Cloud era is the foolish notion that you need 100x as many servers to do 100x as much work. S
by hinkley 6y ago
The biggest thing we're going to regret looking back on the early Cloud era is the foolish notion that you need 100x as many servers to do 100x as much work.
Servers don't scale linearly. It's more likely you'll need, at a minimum, 107-110x as many servers. Between 100 + log(100) and 100 + sqrt(100). So making your code 100x faster saves you more than 100 servers.
I think the arguments never end because it's all fuzzy math. Get too attached to running the whole thing on one server, and your architecture starts making irreversible decisions about where the source of truth is, and you get locked into a single server.
Give up too early, and you spend a lot of energy herding cattle instead of building features. And speed is something you outsource to the guys who write the checks. That's fine if you lock in your vertical, but I've worked on projects that lost out to a more responsive or financially efficient competitor. It really, really sucks.
- missblit 6y agoServers can and do scale effectively linearly depending on the workload. The broader point stands though. The more servers you have, the more money a 1% cpu optimization saves you in raw dollar amounts. At a certain scale it always makes sense to optimize your code.
- hinkley 6y agoThe moment the servers need any consensus at all, you've opened the door to Amdahl's law. That could be sharing caches, running Raft, or talking to a transactional store. Even if it's just to keep my UI in sync between the desktop and mobile site, you have costs. But since so many sites have social aspects now, you need to be able to communicate between accounts, which means interprocess communication. The Amdahl's law fraction is at least logarithmic to the number of users, but more likely to be proportional to the 'surface area' - sqrt(n). Every new server gets you a little bit less oomph than the one before.
- hinkley 6y agoAnd remember, even if we aren't sending more and more data between our users, we're collecting more and more telemetry data from our servers all the time. Coalescing logs and gathering stats requires funneling data from everywhere down to one machine (the one that built the graph)
- missblit 6y agoI actually wasn't thinking of social sites when I said "certain workloads". It's true that every server extra has a bit more overhead because of stuff like caching / load balancing / whatnot, but the amount extra can be tiny even at very large scale. For certain workloads that are parellelizable. (It'd be fun to talk in details from personal experience instead of in general terms, but you know those pesky NDAs...)
- CyberDildonics 6y agoThere is basically no overlap with Amdahl's law here. Amdahl's law just says that there are diminishing returns on the whole when increasing parallelization in a program with significant serial parts. It is a fairly obvious observation, but people seem to distort it and apply it to general scalability. First, everything needs to be synchronized but that doesn't mean synchronization is expensive or blocks computation from happening. Lots of synchronization isn't even dealt with explicitly by users, it happens in queues in the kernel, in networking hardware, or even in the memory controller when talking about reading from memory. The closest thing is the database becoming a bottleneck, but that is not because of Amdahl's law or even synchronization, it just about reads, and those are extremely parallel, so it likely comes down to total CPU power when it is a problem. That's why query caching can be so effective - it isn't about synchronization and definitely not about serial parts of a program, it is just about usage. For connected social media sites, not everything has to be done on a page request. Anything done ahead of time is also done in parallel.
- fefe23 6y agoUnfortunately the probability of failure also scales up. Let's say you bought good hardware and the probability it will fail is x. Let's say you buy a hundred of those. The probability that one of them fails is now 100x. You just increased the probability of failure a hundredfold. You will need a load balancer who can detect failure and not forward to that machine anymore. The load balancer can fail, too. Now it's 101 fold. You also need a separate database if you share sate. 102 fold. Make it redundant. 103 fold. Add router / switches. 105 fold. Make those redundant. 107 fold. I have never used more than one crappy PC for any project of mine, and some of those have had/have pretty substantial load on them. When I say one server, I mean one PC but with two power supplies and RAID storage. I'm not trying to tempt fate here. But I have no devops team, no admins juggling failing machines, I don't have racks. I have one slot in a rack somewhere. The machines have been running for years. Every few years, as I approach MTBF of the hardware, I move to a new server. That entails a small downtime. Result: People use my servers in their "is the internet up" scripts. Because my failure rate is a fraction of what distributed systems have. In fact, practically all of my downtimes have been software bugs in my code, or me fat-fingering input somewhere. I can't even remember the last time the hardware failed. Not even sure I ever had an actual hardware failure that caused downtime. I once had a raid hdd throwing errors and it had to be replaced. I think that's it.
- brightball 6y agoIt’s usually more about specific bottlenecks than specific code in my experience. It’s hard to use too broad of a brush on these things.
- canofbars 6y agoFrom my experience its almost always the database. On any sufficiently complex web app with a ORM its easy to trigger literally 100 queries by loading a single page if you don't make a specific effort to avoid it.
- jimnotgym 6y agoAnd that is the first universal truth in this whole thread. Add tests to check that you have not inadvertently added a massive innefficiency with a simple change.
- dfee 6y agoI think you’re describing fanout, but I’m not sure. What do your math expressions represent?
- garmaine 6y agoThat’s still linear scaling.
- adrianN 6y agoIt's asymptotically linear as your funding goes to infinity, i.e. not linear in the real world.
- nmfisher 6y ago> So making your code 100x faster saves you more than 100 servers. Yeah, but "making your code 100x faster" might cost significantly more than just adding 100x servers. As with most things, the only absolute rule is "it depends".
- bryanrasmussen 6y agocode has a bigger upfront cost but after the initial investment it's all profit. Servers can also go down, but the 100x faster code will remain the same.
- mrmrcoleman 6y agoIf the code has been optimized to the point of being illegible/difficult for others to maintain then, assuming you’d like to update that code at some point, you’ll need to pay for that too.
- midrus 6y agoThat's under the assumption that code doesn't have to be maintained, updated with new features, and that writing it on any programming language has the same cost. Otherwise we would all be writing assembler. Humans are way, way more expensive than servers in almost every case. Exceptions might be small pieces of code ran by millons of devices, but that's far from being the common case.
- otabdeveloper4 6y agoAssembly is expensive because you have you re-write your code every time your architecture changes.
- makapuf 6y agoArchitecture (x86_64 or arm on mobile) hasnt changed in decades. The way to optimize for it changes in years but you get a slightly less optimized version. Im sure software written in 2007 in assemble for linux pc works now, and fast. I think assembly is not cheap because the language is tiny, offers no abstraction and youre on your own for everything, not because of arch turnover.
- Dylan16807 6y ago> The biggest thing we're going to regret looking back on the early Cloud era is the foolish notion that you need 100x as many servers to do 100x as much work. > Between 100 + log(100) and 100 + sqrt(100). I bet it doesn't even make the top ten. You have so many other problems by the time you're scaling to hundreds and thousands of servers and beyond. A few percent difference in server count? Whatever. That's still almost perfect scaling, and not going to be your bottleneck or your huge cost center.
- tempodox 6y agoAnd all of that is on the assumption that 9 women can make a baby in 1 month.
- tutfbhuf 6y agoFrist spent some time and try to optimize. If that's too hard or time consuming for proper reasons, then scale up. If you see many long bars in htop on the biggest machine your provider has to offer, then scale out. Of course, you might want to scale out earlier for other reasons e.g. fault tolerance, if you want to allow different kinds of failures.
- crazygringo 6y agoI'm not sure where this argument is coming from? If you already have a load balancer, you should be able to scale on the server part from 1-100 exactly linearly. Where are your extra 7-10 coming from? And if you already have a database, you usually just upgrade its specs linearly too. And if god forbid you need to shard... that's perfectly linear too. For pretty much all practical planning purposes, servers do scale linearly. The equations you're describing seem to imply a deeper hierarchy of server connections, but that's not usually how it works -- servers (whether load balancers, web servers, or databases) just come in bigger pools, not trees. Where are you getting your log() or sqrt() terms from? Is it some kind of application-specific caching layer or something you've used in the past?
- TacoSteemers 6y ago> If you already have a load balancer, you should be able to scale on the server part from 1-100 exactly linearly. I think this only counts in the simplest of cases? Such as serving HTML straight from memory. In other cases there are various micro or macro services to call to, state to communicate on the enterprise service bus or something equivalent, separate database servers to run queries on, etcetera. A single request might hold up several other requests due to badly-thought-out dependencies between services and physical servers. More servers wouldn't scale exactly, and it might be difficult to find out where the next bottle neck is.
- crazygringo 6y agoThanks... but all the things you're describing are still all linear though in terms of servers, no? All the services you're describing will scale linearly. And if some external bottleneck exists... that's a separate issue and adding more servers isn't going to solve any problems at all. I guess I still just don't see it... I know servers don't scale "exactly" in the sense that one service will require another server before another service does, but that doesn't make it nonlinear. It just gives it variance (fluctuating both upwards and downwards) around a line. It doesn't turn it into a curve.
- ehmmmmmmmm 6y ago> Yeah, but "making your code 100x faster" might cost significantly more than just adding 100x servers. And moreover, it takes time to make code faster. Very realistic scenario is that you have 2 months of runway in the bank and investors have committed to the next round but are holding back the money and still having 3-hour coffees and 2-hour lunches with you about how you can improve your go-to-market strategy instead of letting you get back to work on actually scaling your tech.
- stephen82 6y ago> So making your code 100x faster saves you more than 100 servers. The first thing that came in my mind is the following article from back in 2013: https://blog.iron.io/how-we-went-from-30-servers-to-2-go/ https://blog.iron.io/how-we-went-from-30-servers-to-2-go/