#21 Strike A Balance: Solve Today, Prepare For Tomorrow
Smart architecture is about balancing current needs with future flexibility. It's about solving today's problems while preserving tomorrow's options, and avoiding premature optimization.
Context is king.
This statement has gained popularity recently, and that's a good thing. Instead of applying everything you read or hear related to software architecture, you should always look at what could help you in your case, environment, and the aforementioned context in general.
In a nutshell, the fact that Kubernetes or microservices solved the issues of one company does not mean that they will solve your issues as well. If one of FAANG companies had to write an in-house solution because Kafka could not handle the load (yes, there is an existing case like that), it does not mean you have to implement your own, too. We should not blindly follow everything that we hear.
There is also another concept that gains traction, but unfortunately, it is misinterpreted.
Choose architecture based on your current needs. Not a wishful thinking. - Me
Well, what does it really mean? Lately, I have been asked about it on various channels.
I often hear the objection that it is impossible not to be aware of the next application architecture steps. Yes, it is true. But there is a difference between wishful thinking and having options. Let me explain.
Wishful thinking
Imagine that you are building an application for your company. The application is rather simple and complicated only in a few places. There are 1,000 users who generate low traffic.
But you start to dream. Often together with non-technical people.
We will have 100,000 users in a year from now that will generate heavy traffic. Our application will have tons of complex features, we want to solve all business needs of our customers.
You decide to go with Kubernetes. You plan your application around microservices (to scale units independently) and add a cache to optimize read operations (even though you have no problems with reads today).
In the end, you create an extremely high entry threshold and a quite complex environment to maintain. There is one problem—you don’t need it at all—not today, not tomorrow, maybe in a year from now.
Premature optimization is the root of all evil. - Donald Knuth
This is what I call wishful thinking. Maybe, maybe, maybe. Maybe your business won’t be there anymore. Don’t generate useless costs; don’t optimize before it needs optimization. Observe, react, adapt.
Having options
Having options is completely different from wishful thinking. It is all about not boxing yourself in and keeping as many doors as possible open.
An example of such an option could be an in-memory queue. You know that part of your monolith has to communicate using events. There are several options, including using an external message broker (like RabbitMQ). If you add it today, you already have to take care of additional components in your setup (+ network issues), and you lose the power of communicating within a single process (monolith).
The best part is that you do not need this component today; instead, you can use the in-memory queue. Still, if an external message broker is needed, you can replace it quickly anytime. This is what I call having an option.
Another example: Today, your application might be based on a modular monolith. You invest in proper business discovery and build the solution around highly cohesive modules. It works fine, is performant, and customers are happy. At some point, you observe that one of your modules has problems with scaling or performance, so you decide to extract it. As you thought about it from the beginning (cohesive modules), it's a straightforward move. Again, this is an option.
Summary
Don’t be a dreamer; be as pragmatic as possible. Observe the environment, use what helps you and your team, and focus on your context.
Smart architecture isn't about predicting the future. It is about making moves today that keep your choices open for tomorrow.
It is simple, it is cool, and it works.
While I understand the point you’re trying to make, would be better to cite the…premature optimism full quote.
Good read BTW