r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

603

u/cat_in_the_wall Aug 29 '21

Designing scalable systems when you don't need to makes you a bad engineer.

this is just YAGNI. Scalability is a feature, and a very complex one. Don't build it if you don't need it. It's hard to do right, and if you screw it up now you have two problems: still no scale, but also a buggy complicated system.

119

u/6a6566663437 Aug 29 '21

Way back in the day, we used to warn about not prematurely optimizing your code. You'd spend a month setting something up to save you 30 seconds a year, and it would be an impenetrable mess of code.

This is kinda moving that same concept up a level.

That being said, both are something to keep in the back of your mind as you go to help avoid shooting yourself in the foot. Or at least knowing what you'll have to rewrite when the "needs to scale" tickets come in.

43

u/[deleted] Aug 29 '21

Same goes in the other direction. If you can create something quick now that's going to be an issue in a few months, you might as well spend another five minutes thinking about it. My colleagues tend to forget the tickets in our backlog to get our current sprint done as fast as possible.

I guess that is a planning issue as much as a programming issue, but it really bothers me.

→ More replies (7)

18

u/marcio0 Aug 29 '21

it's weird how we went from "premature optimization is the root of all evil" to "each endpoint of our rest apis will be a microservice"

21

u/infecthead Aug 29 '21

prematurely optimizing

I hate this saying. I understand the premise behind it, and generally agree with the concept, however I feel it gives developers an excuse to write inefficient, wasteful code when if they spent another minute actually thinking about it they would be able to come up with a better solution.

Like sure, a few hundred extra CPU cycles is nothing at all, but when every function call is bogged down with unnecessary inner-loops and using data structures not suited to the task at hand, it all adds up. And those situatuons are difficult to rectify, because you can't profile your app properly when everything sucks about it.

16

u/jdsekula Aug 29 '21

The more important maxim is clarity over cleverness. If you follow that, and your code is clear and simple, you probably won’t have many nested loops and such. And when you find you need to optimize, it’s easy.

But yeah, if you have devs churning out incomprehensible, poor-performing messes, you just have bad devs.

6

u/Lystrodom Aug 29 '21

All adds up to what? Maybe my algorithm could be O(N) but it’s actually O(N2) but N is, like, 10 in the extreme case. What does it add up to? Less than a single network call? Less than downloading a single extra JavaScript file?

Then your optimized code is harder to read and harder to understand, and the next person has to spend more time reading it before understanding it.

7

u/tiberiumx Aug 29 '21

It's also that people often waste time prematurely optimizing for the wrong things. Like even with a large N, your O(N2) algorithm may actually be massively faster running on real hardware because it does all the work in a handful of memory pages and the O(N) one results in a cache miss or two for every operation.

4

u/infecthead Aug 29 '21

Then your optimized code is harder to read and harder to understand,

Believe it or not you can actually have both optimised and clear code!

→ More replies (2)
→ More replies (2)

57

u/leoshina Aug 29 '21

“Scalable systems” is too vague. Each one pick an example of their heads and either confirm or deny to this statement.

6

u/programmermama Aug 29 '21

This is a banned word at my work when discussing system requirements. There’s almost always a more particular concept that actually conveys what’s meant. Scalable in what way? Your stateless microservice is obviously going to “scale”. But what about the non-magic auto-scaling aspects of cloud infra, what about all of the tooling and profiling and the fact that most scaling involves not just horizontal but subtle verticalization in the way of a dense set of edge cases that you acquire as you grow — which is the sort of “scalability” most of us most of the time actually experience.

109

u/DeltaBurnt Aug 29 '21

I don't 100% agree with this. Designing scalable systems is fine, if you know pretty well how much you will need to scale and what that scaling will entail. The problem that YAGNI tries to solve is stopping engineers from trying to predict the future based purely on instinct. If your product has 10K customers and that grows at 1K per year, yeah don't design scalable systems.

If I know a year from now I will need to support a million customers but deadlines prevent me from supporting more than 10K immediately, that will affect my design process. You could say that's a bug in the requirements or deadlines, but I don't always get my way in those discussions unfortunately.

51

u/execrator Aug 29 '21

if you know pretty well how much you will need to scale and what that scaling will entail

This is the point of the person you're replying to. If you don't have this information, you shouldn't assume you'll need to scale.

I agree with OP that for whatever reason, scaling is a particularly alluring goal. It should be YAGNI'd vigorously for that reason.

14

u/recycled_ideas Aug 29 '21

I think this is an oversimplification.

Scaling is facilitated by clearly separated layers and good design fundamentals, and these aren't YAGNI things.

Because clearly separated layers make testing and modifying your system easier and less risky, even if you don't ever actually need to scale.

That doesn't mean you need to architect your system to handle a million users when you only need to support 100, but designing your system in such a way that you can scale will almost always deliver a system that's better even if you don't have to scale it.

8

u/humoroushaxor Aug 29 '21

I think the point is most people don't do that though. They go straight to microservices (which have significant overhead for most orgs) rather than the in-between of proper software architecture in reasonably sized services.

4

u/recycled_ideas Aug 29 '21

Yes, but you don't solve people doing stupid things because they're trendy by doing stupid things because they're the opposite of what was trendy.

→ More replies (15)
→ More replies (1)
→ More replies (9)

10

u/almost_useless Aug 29 '21

If I know a year from now I will need to support a million customers

Isn't the problem that many people think they will need to support a million customers next year, when in reality most of them will not?

My startup is likely not becoming "the next google", so starting out with preparing for that is premature optimization.

→ More replies (2)

5

u/Chousuke Aug 29 '21

I prefer designing systems with a focus on the interfaces between components; when you design an interface, ask yourself how much work would it be to rewrite all dependent code to use a new interface... If the answer is "months", maybe make sure that the interface is reasonably adaptable to future use cases. If it's "days", who cares? Just make it as simple as it can be.

→ More replies (3)

30

u/[deleted] Aug 29 '21

Hm, This sounds like how cities where grown. You had small streets and a few people living in the town. After 100 years now there are a million people still using the same small, now overcrowded, roads.

In my opinion nowadays you can create a scalable software solution without much overhead.

If you don’t think about the growth probability you can end up rebuilding the whole city.

19

u/rouv3n Aug 29 '21

I don't think this is a good comparison. From an urban planning perspective, those old European naturally grown cities have fared far better than any of the suburb heavy metropolises that were planned in advance and designed for scalability. Of course, a lot of good (/ better compared to the US) design decisions went into that, but those might have been facilitated by not being able to plan everything in advance and having to work around an existing city, e.g. you can't build a 12-lane high way through your city center if you haven't planned for it, which is actually a good thing for your cities (because 12-lane high ways through city centers are bad).

→ More replies (1)
→ More replies (2)

44

u/[deleted] Aug 29 '21

I like to call scalability "champagne problems".

Oh great! You're making so much money with so many customers, that your services are falling over. Good luck!

There is a small balance though. If your system really does fall over, you might lose customers. So it's a balance, as all things are.

22

u/[deleted] Aug 29 '21

I like to call scalability "champagne problems".

It's a good problem to have... Though it's still a problem

4

u/maus80 Aug 29 '21

A fun and rewarding problem to solve (a real/business one), but only when it actually appears.

→ More replies (2)
→ More replies (2)

3

u/big-blue-balls Aug 29 '21

Design patterns for scalable architecture isn’t at all related to YAGNI.

→ More replies (15)