Microservices are great! Theyâve solved several problems created by large monoliths, like scalability, fault tolerance, and testability, among others. However, let me assure you that everythingâs not rosy yet, and there are tonnes of ways you can blow your microservices to smithereens! Here are 6 sure shot ways to meet failure with microservices, and to spice it up, Iâve included the Batman sound effects too!
Disclaimer: Unless youâre Sheldon Cooper, what is and what isnât sarcasm should be pretty evident in this one!
#1 The Polyglot Conspiracy
One of the most spoken about benefits of using the microservices pattern, is that you can use a variety of tools and languages to build your application. Great! Letâs say youâre building an e-commerce website with a chat option, maybe VR/AR thrown in too, and then the necessities like a payment page, etc. Obviously youâll want to build it with microservices. Now, you also thought you might have different teams work on the app using different languages and tools. Maybe Java for the main app, Golang for some services and JavaScript for something else. Moreover, you also decided to use Angular as well as React on various components of your UI. Then one day the React team needs to fix bugs in production on Angular, because the Angular team called in sick.
Your Ops team is probably pulling out their hair right now! You need to understand that different tech stacks behave differently in production! Going the Microservices route, doesnât give you a free ticket to go to town on polyglot services.
#2 Sharing isnât always Caring
Letâs assume youâve built an app where various microservices connect to a single, shared database. Itâs quite a good design decision, right? Simple, effective and what not. Now a business requirement calls for a change in the character length on one of the microservices. The team goes ahead and changes the length on one of the tables, and...
Thatâs not all, what if you decide to use connection pools so you can reuse request to the database when required. Awesome choice! Imagine your microservices decided to run amok, submitting query after query to the database. It would knock out every other service for weeks!
#3 WET is in; DRY is out?
Well, everybodyâs been saying Don't Repeat Yourself, these days - architects, developers, my mom. Okay, so youâve built this application thatâs based on event sourcing. Thereâs a list or store of events and a microservice in your application, that publishes a new event to the store when something happens. For the sake of an example, letâs say itâs a customer microservice that publishes an event âin-cartâ whenever the customer selects a product. Another microservice, say âaccountâ, subscribes to that aggregate type and gets informed about the event. Now here comes the best part! Suppose your business asks for a field type to be changed, the easiest way out is to go WET (We Enjoy Typing), making the change in one microservice and copying the code to all the others. Imagine youâve copied to a scale of hundreds of microservices!
Better still, you decided to avoid using Git and just use your event history to identify whatâs wrong! Youâll be fixing bugs till you find a new job!
#4 Version Vendetta
We usually get carried away sometimes, when weâre building microservices. You tend to toss Kafka out of the window and rather build your own framework for your microservices. Not a bad idea at all! Okay, so youâve designed a framework for the app that runs on event sourcing. So naturally, every microservice thatâs connected will use event sourcing to communicate with the others. One fine day, your business asked for a major change in a part of the application, which you did, and the new version of one of the microservices sends the new event to the other microservices andâŚ
When you make a change in one microservice, you canât be sure that all others will work fine, unless versions are changed in them too. You can make things worse by following a monolithic release plan for your microservices. You could keep your customers waiting for months to make their systems compatible, while you have your services ready but are waiting to release a new framework on a monolithic schedule. An awesome recipe for customer retention!
#5 SPA Treatment!
Oh yeah, Single Page Apps are a great way to build front end applications! So your application is built on the REST architecture and your microservices are connected to a single, massive UI. One day, your business requests for a new field to be added to the UI. Now, each microservice has itâs individual domain model and the UI has its own domain model. Youâre probably clueless about where to add the new field. So you identify some free space on the front end and slap it on!
Side effects add to the fun! Imagine youâve changed a field on one service, side effects work like a ripple - passing it on to the next microservice, and then to next and they all will blow up in series like dominoes. This could keep your testers busy for weeks and no one will know where to look for the fault!
#6 Bye Bye Bye, N Sync
Letâs consider youâve used synchronous communication for your e-commerce application. What you didnât consider was that not all your services are going to be online at the same time. An offline service or a slow one can potentially lock or slow thread communication, ultimately blowing up your entire system, one service at a time!
The best part is that itâs not always possible to build an asynchronous communication channel within your services. So youâll have to use workarounds like local caches, circuit breakers, etc.
So there you have it, six sure shot ways to blow up your microservices and make your Testing and Ops teams go crazy! For those of you who think that microservices have killed the monolith, think again! For the brave, who still wish to go ahead and build microservices, the above are examples of what you should beware of, when youâre building away those microservices!
How to publish Microservice as a service onto a Docker
How to build Microservices using REST framework
Why microservices and DevOps are a match made in heaven
Â
Â
Read more