Can MicroServices Architecture Solve All Your Problems?

IT is one field where you can find new things coming everyday. Theses days the whole developer community websites are flooded with MicroServices and Docker related stuff. Among them the idea of MicroServices is very exciting and encourages better way of building software systems. But as with any architectural style there will be pros and cons to every approach.

Before discussing what are good and bad sides of MicroServices approach, first let me say what I understood about MicroServices.

MicroServices architecture encourage to build small, focused subsystems which can be integrated into the whole system preferably using REST protocol.

Now lets discuss on various aspects of MicroServices architecture.

The dream of every software architect/developer:
First of all the idea of MicroServices is not new at all. From the very beginning our elders suggest to write classes focusing on one Single Responsibility and write methods to do one particular thing and do it well. Also we were encouraged to build separate modules which can perform some functionally related tasks. Then we bundle all these separate modules together and build an application delegating the appropriate tasks to respective modules. This is what we try to do for many year.

But the idea of MicroServices took this approach to next level where you can deploy each module as an individual deployable unit and each service can communicate with any other Service based on some agreed protocol (preferably REST, another trendy cool thing :-)).

So what are the advantages of this MicroServices architectures? There are plenty.

  • You will have many small services with manageable codebases which is easy to read and understand.
  • You can confidently refactor or rewrite entire service because there won’t be any impact on other services.
  • Each microservice can be deployed independently so that adding new features or upgrading any existing software/hardware platform won’t affect other services.
  • You can easily adopt the next cool technology. If one of microservices is very critical service and performance is the highest priority then we can write that particular service using Scala in order to leverage your multi-core hardware support.
  • If you are a service provider company you can sell each service separately possibly making better money compared to selling whole monolithic product.
  • And most important factor is, the term MicroService is cool ๐Ÿ™‚

What is the other side of MicroServices architecture?

As with any approach, MicroServices also has some down sides and associated cost.

 “Great power comes with great responsibility”. -Uncle Ben

Let us see what are the challenges to implement a system using MicroServices architecture.

The idea of MicroServices is very simple but very complex to implement in reality.
In a monolithic system, the communication between various subsystems are mostly direct object communication. But in MicroServices based system, in order to communicate with other services you may use REST services which means additional HTTP call overhead and its inherent issues like network latency, possible communication failures etc. So we need to consider various aspects while implementing inter-service communication logic such as retry, fail-over and service down scenarios etc.

How good is your DevOps infrastructure?

In order to go with MicroServices architecture, organization should have a good DevOps team to properly maintain the dozens of MicroService applications.
Do your organization has DevOps culture? Or your organization has the problem of blame game between Devs and Ops? If your organization doesn’t have a good DevOps culture and software/hardware resources then MicroServices architecture will be much more difficult to adopt.

Are we fixing the actual problem at all?

Now many people are saying MicroServices architecture is better than Monolithic architecture. But is Monolithic architecture is the actual reason why many projects are failing? Will MicroServices architecture save the projects from failing? I guess NO.

Think, what were the reasons for your previously failed projects. Are those projects failed because of technology issues or people issues?
I have never seen a project which is failed because of the wrong technology selection, or wrong architectural approach. But I have seen many projects failing just because of problems with people.

I feel there are more severe issues than architecture issues which are causing projects to be failed such as:

  • Having developers without sufficient skills
  • Having developers who don’t want to learn anything new
  • Having developers who don’t have courage to say “NO, we can’t do that in that time”
  • Having Architects who abandoned coding years ago
  • Having Architects who think they know everything and don’t need to listen to their developers pain
  • Having Managers who just blame the developers for not meeting the imposed deadlines without ever asking the  developers for time-lines

These are the real problems which are really causing the project failures.

Now do you think just moving to MicroServices architecture saves the IT without fixing these problems?

Continuously innovating new ways of doing things is awesome and is required to move ahead. At the same time assuming “the next cool methodology/technology will fix all the problems is also wrong”.

So those of you who are just about to jump on MicroServices boat..THINK. FIX THE REAL PROBLEMS FIRST. You can’t fill a bottle which has a hole at it’s bottom.

Few Things That I Learned as a Blogger

I started my career as a Java developer in 2006. I was working on a Servlets/JSP project based web application which we thought of migrating it to Struts framework.

I got some issue and struggling with it for hours and hours and couldn’t be able to find any solution. I read all the Struts reference documentation and referred many books on Struts framework. But in all those books and reference documentation I could find the happy path situation guidelines only.

After struggling to find what is the problem for almost 3 days, I found the reason along with a solution in a blog. That was a bug in Struts framework itself and that issue will come only with combination of a particular version of common-collection.jar. That blogger also encountered the same issue, debugged the code by spending lot of time, found the issue and most importantly he blogged about it. You can’t find such type of issues in any books or framework’s reference documentation obviously.

That day even after going home I could not stop thinking about it. See, somebody whom I don’t know and probably I will never meet helped me a lot. Otherwise I don’t know how many more days I might be struggling with that issue. That blogger might not get paid for writing that tip, and people who took help from that blog post might never meet that blogger in-person to thank him. But unknowingly he helped many people like me.

After that incident I learned one important debugging tip. Search google with the first line of Exception stacktrace, 95% of the times you will find a solution on StackOverflow or any blog.

Also on StackOverflow there are many many enthusiastic people who will help you by answering your questions. For that also they might not get any monitory benefits immediately. Of course, they get some reputation which they deserve for their time and knowledge.

Then I realized this is what the Community support means. We take help from others and we give help to others. We help each other and make our lives easy. Then I decided to start a blog and write down the things that I learned.

I started my blog around 6 years ago. Over the years I have blogged on various topics, most of them are for beginner to intermediate skilled people. After few months my blog started getting some traffic and few people thanked me for writing about Java stuff. I am very happy.

Then things started getting interesting. Among them few things are good, some are disappointing and some are irritating. In this article, I would like to express my opinions about some of the blogging related things.

1. Don’t hurry to write more articles, write few good articles
When your blog started getting traffic then it is very tempting to write more and more. In the process of writing more articles you might not be able to write good quality content. Don’t hurry to get popular. Focus on writing better quality articles.

2. Be open to suggestions
Being open to feedback suggestion is very very important. You might not be good at everything. You might not have correct info on a particular topic or the way you expressed something might be misleading to wrong conclusions or even your English might not be good. In my case, I am not a native English speaker and my English written skills were(are?? :-)) poor. So when someone says you suck at something then smile and try to improve upon it.

3. Respond to your blog readers questions
It is very important to respond to your blog readers questions. You might forget to explain about some configuration which makes others wondering how it is working for you and not working for them. When they ask questions try to answer as much as possible.
4. You don’t need to respond to every question/comment
At first it seems a contradicting statement to my previous point, is not.
At times you will get some requests or comments like “Your SpringMVC CRUD sample with User table is good, but I want a CRUD application for Employees. I want emp_id, fname, lname and email columns for Employee table. Please send it as soon as possible, it is very urgent for me“.
As soon as I read it my first reaction is “What The Hell”.. But as I know how Indian IT organizations work I didn’t respond by saying “Get lost”. I thought he might be a fresher and his employer put a deadline to learn Spring and create an application by end of the day. I created a sample SpringMVC CRUD application  using Employee and sent him. Guess what!! That day evening I got an email from the same guy with an Excel sheet attachment. In the email he mentioned “We have list of courses for each employee. We have to display the list of course that an employee subscribed to. You can find more details in attached Excel sheet. Please send me this functionality by tomorrow“.
After reading this email I was speechless and I realized what mistake I did. Help those who want to learn and ignore those who just want to get it done by delegating it.

5. Don’t take harsh comments personally
At times people may not agree with your point and some may respond very harshly. For example, when I wrote an article title “Are frameworks making developers dump?” all I want to say is “Though your fancy framework is providing nice abstractions over the low-level APIs, knowing how things work under the hood help a lot to better utilize the framework”. Still I didn’t understood what is wrong in that. But many people replied harshly saying “Where did you come from..from MARS??”. At that time I felt very bad about it, but over the time I learned how to take heat and ignore useless comments.

And some other people simply say “Your article is a shit and useless”. If a person know how much time it take to write a decent amount of content for an article no one would say that. So no need to worry about those idiots. Just ignore them.

Anyway, Blogging helped me a lot in many ways. Thank you everyone for encouraging me to write more and more.

How much crap you are keeping because “You might need it in future”?

How much crap you are keeping because “You might need it in future”?

I am planning to move to a new house in a couple of weeks, so I started packing things and throwing away unnecessary stuff.

In the process of identifying unnecessary stuff I realized how much crap I am keeping in my house thinking it might be required in future.

But I only came to know that I have these things while looking for waste to throw away. Lots of stuff..CDs/DVDs with JDK1.4/1.5, Eclipse 3.2, Spring, MySQL4.x, WebLogic Server 10, Utilities(AVG 2007, MS OFFICE 2003, Winamp/VLC players), broken DVD Writer and HardDrive and lots of clothes which I can’t wear anymore, many other electronic goods which are not working and many more.

While cleaning up all these things and throwing away all unnecessary things I got a thought like “Aren’t we doing the same mistake while developing software?”.

First we keep adding unnecessary features assuming we might need them in future to support all types of *bilities(Scalability, Extendability,Maintainability etc). After a while “That future purpose features” becomes a “Dark Room” where no one knows what exactly in there and many people don’t even bother to know why it is there in the first place.

Even horrible thing is you might be in a situation where “whenever you add some new required feature you might have to add some code/configuration in that future purpose module as well”. You don’t know why you have to do it or you have to do it just because to pass the build.

Moving to a new place quickly is painful when you have unnecessary luggage. Being Agile is very difficult if you have unnecessary future purpose code about what you forgot a long time ago.

Less luggage, more comfort. Applies both to personal life and Software Development as well ๐Ÿ™‚

What is your favorite open source project?

I do spend at-least couple of hours everyday reading about what is going on in Java community to be aware where we are heading and what is hot these days.

Because in Java land everyday new frameworks, new libraries came out and few of them might be really good and can drastically simplify the work you are doing. So I thought it is good to know about these new and hot stuff even if you are not going to use them in your official project.

In the last few years it looks like frameworks craze is gone and Programming Languages era begins. Ceylon, Kotlin, XTend, Go, Dart, Swift etc etc…every BIG company is trying to invent their own programming language.

But I feel like again things got changed in 2014, now everyone talks about MicroServices and Platform.

Based on my understanding, Platform means a generic infrastructure tailored to solve one type of domain problem by using one or more programming languages (Polyglot programming) based on the need. You no need to stick to one programming language.

And then I am seeing on web, more and more companies started calling their “framework” as a “platform” which makes me wondering when this framework turned into Platform.

To tell this satirically I posted the following tweet on twitter.

“Seems frameworks & programming languages craze is gone..Now if u want to sound like a model IT developers spel Platform as much as possible.”

Interestingly this turned into another interesting discussion where my favorite twitter buddies participated.

Now the topic of interest is “Whether writing a book is good option or not. If yes, writing on what? Spring, SQL, JOOQ???

My friend @lukaseder feels instead of writing about Spring, better to write on SQL. And @petrikainulaine expressed his opinion that “he is not that passionate about SQL” which is my opinion too.

Twitter isn’t nice place for long discussion because of 140 char limit. So I created this post on my blog so that we can continue on this topic more elaborately.

First is writing a book a good option?

Yes, if you are passionate about technology and the topic you are writing about. No, if you are writing just to earn money. No, if you don’t want to spend your weekends also writing content thinking you could improve content within the page limit :-).

And my friend @dr_pompeii brought up another issue “Piracy”. Yes, that’s one of the problem. You can get a pirated e-copy of most of the books in 2 months.

On what topic should you write? Better to write on SQL instead of Spring?
Here I disagree with LukasEder :-). I write on topics which I am interested in and have good understanding. And let me shamelessly agree that I am not very good at SQL and I can’t write a book on it which is more interesting than any of the existing SQL books. And most importantly I don’t have a passion on SQL.

Promoting the articles on popular website might not be that difficult. I can write couple of posts about JavaEE 7 and let Reza do the promoting part ๐Ÿ™‚

I like Spring not just because of its popularity, I do learn how to design and code in a better by going through its source code. I learn how to write a good abstraction layer by looking into various Template classes and Adapters in Spring source code.

At time I also feel like I am after this Spring framework for a very long time and want to learn something different and more interesting.

So if it is not Spring, what is a good open source project that you suggest worth reading its source code and learn something good?
I thought of taking a deep look into Jersey (JAX-RS) and SLF4J libraries.

What would you suggest? Any ideas?

Do you have defect id to burn the hours spent on code refactoring?

Working on a large legacy code-base is challenging(painful?) and is inevitable.
You may need to keep on refactoring the legacy code to fix bugs, to add new features or enhancements.
For these changes normally we would have a defect or new requirement created in QualityCenter/VersionOne or whatever the tool you use for tracking the tasks. We burn the hours spent on these tasks against the respective defect-id or requirement-id.

Then assume you identify some piece of code which is written in horrible way and thought of refactoring that logic. Generally we will create a defect-id explaining the need for refactoring and refactor, test, commit, done.

In some organizations, as per process every commit to the source code should be associated with some defect-id or requirement-id.

What if your manager said

As per our process, every commit should be associated with a defect/requirement.
We can create a defect for code refactoring that you are suggesting. Every code change should go through all the QA/UAT cycles. But the business will prioritize the defects/features for the next release as per release plan. So I can’t assure you whether this will go in next release or not.

I guess you can understand what that manager’s reply implies :-).

But I felt like from the manager’s perspective it is valid point. His target might be to deliver the planned bug-fixes/features for the next release.

So guys, I am curious to know how is code refactoring is happening in your organizations?