This is a no-hype, pragmatic post about why I think you should consider architecting your next project the way SOA and/or microservices suggest. No matter if it’s a greenfield approach or if you’re in dire need of refactoring. Please note: considering still keeps open the option of not taking that approach. After reading this, you will have a better idea about whether building multiple small components instead of a single, large component makes sense for your project.
This post assumes that you have experience with software architecture and services (you’ll find some words about my experience on the bottom of this post). I won’t go into the details of Wikipedia’s or Martin Fowler’s definitions per se. Much more I will talk about what microservices and/or SOA could and should do for your project.
Microservices? SOA? Both? None?
I’ll leave it up to you if they are both the same. Some say, microservices is just SOA done right. Some say, microservices has common roots with SOA but is really next-gen and lightweight and less-enterprisey and whatnot.
I don’t stand the slightest chance of resolving this. Therefore, I won’t go with either of them. I’ll go with microsoavices instead. It’s not meant to be funny (in the first place, that is), it’s meant to be a pragmatical phrase that saves me from overhead typing.
The perfect software architecture doesn’t exist
There is no perfect generic software architecture approach but you knew that already. Microsoavices might just not be the perfect fit for your project or even your company. What’s a microsoavice anyway? First and foremost, I’d like to reduce it to two simple key points
- fine-grained responsibility
- built for fault-tolerance
Those two things are the least common denominator for me on everything you and I already have read about the topic. They should be the basis for any project, no matter if it’s your shiny (shabby?) little garage project or if you’re out for something really big.
Microsoavices may be single-task or single domain. Here’s an example for a single-task microsoavice.
Most likely, projects not merely consist of business logic and application domains. There are always some plain utilities involved. I once worked on a project that needed to convert RTF files to HTML. We used a library for that, so it was really easy. On the other hand, updating the library required us to re-deploy all instances of our application. Deployment was automated and we didn’t have to send out floppy-disks with the new versions to our customers but anyway, for a team of three maintaining dozens of instances it required quite some attention.
Wrapping that same library into a stand-alone application that’s listening for incoming HTTP requests was all that was necessary to turn it into a microsoavice (yes, and that final re-deployment of all the instances that changed the internal library call into an external HTTP request). Anyway, from that day on, updating that library was just a matter of re-deploying that single component (as long as the API stayed stable).
Besides single-task microSOAvices there’s also more than enough use-cases for covering application domains instead of just single tasks. Take a shopping cart as an example. There are simple functions like
- add product to cart
- remove product from cart
- update product’s quantity in cart
Nobody seriously thinks about creating separate services for those tasks and that’s the reason why it’s as fine-grained as it needs to be (and should be, probably).
Built for fault tolerance
In-process method calls, are replaced with external calls between components. The big difference is that external calls are much more likely to fail. And they will. This requires attention but taking care of it appropriately makes your whole system much more stable and fault-tolerant by design already.
It’s up to you whether you go for a library that handles the issue for you or if you want to take care of it yourself but don’t make the mistake of not taking care. Fault tolerance really is a central issue. Getting it done right early on is the key to succeed with microSOAvices.
Building, deploying and maintaining an ecosystem of many small, independent components poses its own problems. You not only face the problem of fault tolerance, but also the problems of
- configuration (where do I reach that service?)
- monitoring (what services are available?)
- deployment (how many instances are up? on which hosts are they running)
- testing (what to do in case of a failing service call?)
- and quite some more.
Testing and deployment should be taken care of by continuous integration and deployment tools that are available. Monitoring was not there until recently but is already catching up with new products entering the market. Central configuration of a microsoavice environment is probably something that could be solved by using some ESB-like tool.
You see, there seems to be a solution for everything, you might just not be all too happy with them. And I honestly think that we’re not fully there yet when it comes to tooling. The future will bring lots of good tools that make building, deploying and maintaining microSOAvices much easier.
From my own experience I can say that going down microsoavice lane is not just about all the technical problems. It’s a little bit like the agile thing, which is really also quite a bit about the mindset.
If you are concerned about increased danger of failure because of single failing services, then you probably need to think about it again. If you see how all those small components help you decrease the likeliness of failure, you’re probably settled.
One most important thing not to forget is your developers. Make sure they get the idea of what microSOAvices are all about. I will try to cover in a future post, how microSOAvices change and improve a developer’s everyday life.
Looking back, I did some projects which would have really benefitted from doing the microsoavice approach and some others, which surely would have not. And I did one project that was forced into the enteprise-SOA thing in a very dogmatic way, which is why I want to write about the topic pragmatically and from a practical perspective.
This was just a short introduction to the topic to get your mouth wet. I just touched some keypoints briefly but I will go much more into detail in the posts to follow.
While you’re waiting, why not sharing some of your worst experiences with the topic so far? Tell me about ignorant software architects and blind followers of dogmas, I’m always in for a good laugh.