48 ms·
The famous J2EE + ESB style pattern. Many of us have worked on dozens of these before and sure they work but microservices were invented specifically to addres
by threeseed 8y ago
The famous J2EE + ESB style pattern.
Many of us have worked on dozens of these before and sure they work but microservices were invented specifically to address the serious concerns with these patterns.
1) It's far too easy to create spaghetti code that spreads across multiple modules. And because they are so intertwined teams are very reluctant to do major refactors. Especially when the original authors eventually leave.
2) It's less flexible at scaling. In a monolith you have to horizontally scale the entire application behind some load balancer. So if you have an Email concern that needs to handle 100x more load what do you do ?
3) API contracts are far easier and safer to evolve than ESB ones. There are also clean mechanisms in APIs for handling versioning, capability discovery e.g. HATEOS, documentation e.g. Swagger, rate limiting, caching, analytics, billing, authentication etc.
4) Microservices are much easier to reason about, test, document, teach new starters about and most importantly replace. If I replace a microservice I just need to verify that the API contract is the same. In a monolith I need to basically retest everything since there is no guaranteed isolation.
I could keep going on. But not sure this blog post offers anything particularly insightful in how to deal with the negatives of a monolith architecture.
- qaq 8y agoOne can create an equally long list of problems with micro services.
- mifreewil 8y agoIt’d be way longer.
- DenisM 8y agoIt seems that apart from scaling your concerns boil down to enforcing discipline? Perhaps there are methods of enforcing discipline that don’t involve serializomg and deserializing a bunch of data several times per request.
- dave_sid 8y agoBingo! Agreed. You’ve summed it up brilliantly. Other than the scaling advantages, micro-services mainly thrive as a method of strictly enforcing separation of concerns. Maybe that’s a good reason to use them. Or maybe there are other ways to do this without incurring the management overhead of micro services. Who knows. Also, I’m not entirely sold on the horizontal scaling advantages either. Are you building a website that’s going to have to scale to millions of requests per second at the click of a button? Probably often not.
- philwelch 8y ago"Strictly enforcing separation of concerns" is not a great argument. If feature teams don't have the technical maturity to handle separation of concerns, they'll make an even bigger hash out of the extra resiliency, testing, and other overhead introduced with microservices.
- threeseed 8y agoMonoliths have been around for decades and much smarter people than me have been thinking about this problem. Unfortunately there is just no way to enforce discipline because monoliths sometimes demand unintuitive behaviour. Often it is better to cut/paste code than it is to link from one module to another. And don't forget that when a deadline hits developer are often forced to do things that aren't always architecturally sound. Microservices forces isolation between modules.
- DenisM 8y agoPerhaps I should have said "there should be methods of enforcing discipline". As in, "we should make/find them". In .NET you could compile individual assemblies separately and use technical measures to prevent developers from one component from touching code in the other component. The external surface of the assembly would be its API, only no network traffic is required. Does this give us enough discipline, in your opinion?
- batiste 8y ago> Often it is better to cut/paste Micro service surely put the dream of code sharing to REST. Not sure it is a good thing.
- closeparen 8y agoHaving extra code in the binary is not a serious scaling issue. You can reserve capacity for specific endpoints with an L7 load balancer, and flip config flags to run different worker processes on different instances. Microservices are not about scaling the runtime, they’re about scaling the engineering organization and deployment processes so that teams can iterate and ship independently. With thousands of engineers committing to the same artifact, the probability that at least one commit is bad (blocking rollout of all others) approaches 1.
- threeseed 8y agoIt is a massive scaling issue. Most enterprise JVM apps for example are running with 8GB+ of RAM. Adding 10x the capacity which is only needed for say sending emails can be hugely expensive or sometimes impossible if you are running on-premise. And scaling different parts of the application is just one of many benefits of microservices.
- guntars 8y agoI would think that the point of writing a single process monolith with components communicating via a bus like this is that it’s a small step to break out one of those components into a separate process and scale it horizontally.
- mattmanser 8y agoIs this a parody or are you being serious? Do you honestly believe this drivel? Take the 'much easier to reason about'. A monolith is simple to reason about. You can literally see the whole call stack in your favourite debugger. It's so simple to reason about, yes? Do you understand how? How a simple breakpoint gives you the whole program in a monolith. That's literally impossible in a micro-service setup. With a microservice setup even the most trivial of bugs become an utter nightmare to debug.
- orf 8y ago> With a microservice setup even the most trivial of bugs become an utter nightmare to debug. Alternative view: It's not. I get your point but with a well designed microservice it's pretty simple as well. You just need proper logging in production and a good development setup. Complex issues involving multiple services are a lot harder, I grant you.
- deleted 8y ago[deleted]
- philwelch 8y agoHmm, I would disagree with some of your points, or at least suggest that similar if not worse problems can arise with microservices: 1. Large-scale refactoring is easier when you have a single build artifact that you can test and deploy. Refactoring a microservice architecture can be significantly harder if that refactor crosses microservice boundaries (say, if you're repeatedly doing the same thing across multiple microservices and want to extract that behavior). Microservices do make it easier to do refactors that don't cross service boundaries, but that assumes that you chose good service boundaries in the first place, and if you can do that, you can also modularize your monolith well enough to make those small-scale refactors easy, too. 2. While this is a valid point, not only do you not have to go to microservices to address it, but using microservices naively can get you worse results. Email isn't a synchronous task, and you should be dropping it on a message queue for an offline worker to pick up anyway. For different feature concerns that are online and need to happen synchronously with requests, it can be handy to route different endpoints to different groups of servers that are scaled and optimized independently of each other. But that doesn't actually require microservices; you can just deploy a monolith that way. 3. Most of those mechanisms only exist because coordinating behavior over a distributed system is inherently harder. When you're calling other code in the same process, you have much firmer guarantees about latency and availability. API contracts within a service don't have to be monitored, metered, or rate limited the way service endpoints do. You don't have to worry about serialization and deserialization--not even from a performance standpoint, but from a reliability standpoint. And you don't have to worry as much about input validation if you're using a strongly typed language. 4. A microservice is easier to test. A full product that is composed of microservices is harder to test. Testing a microservice architecture entails building as many of the microservices as are necessary for a specific piece of functionality, deploying all of them to a shared test environment (or a set of shared test environments that are configured to interoperate), and configuring the microservices to communicate with each other within that test environment. And it's very unlikely that you can test a single feature across your microservice architecture in isolation unless you have at least as many separate, isolated test environments as you have features under active development. Additionally, since these test environments are expensive, they tend to be long-lived and accumulate various operational issues. Functionality that, within a monolith, could be tested within an isolated, repeatable build process, gets punted out to these dirty and unpredictable test environments in a microservice architecture.
- innagadadavida 8y agoRefactoring code is March easier to do if code is in one place and you can run and set breakpoints. It is nightmarish to do this in distributed systems especiallly when minor api semantics can cause huge problems that can go undetected for ever. Lastly Don’t blindly believe some blog article - they are likely written by unemployed folks with too much time on their hands (possibly using the article to find their next gig)
- int0x80 8y agoRe:4 you can absolutely test and reason about modules in a monolith if you design and decouple things correctly. You are throwing a new complex and fragile architecture generalisticaly to fix sloppiness. You will have worse problems I assure you if you can not correctly modularize a plain classic application correctly, no matter how many MS you throw at it. To clarify. I don't think microservices are a bad thing, but monoliths are many (most) of the times perfectly good. Also, I think the middle ground is the better option. You can have services but they don't need to be micro.