Book Image

Practical Microservices

By : Umesh Ram Sharma
Book Image

Practical Microservices

By: Umesh Ram Sharma

Overview of this book

<p>A microservice architecture helps you build your application as a suite of different services. This approach has been widely adopted as it helps to easily scale up your application with reduced dependencies. This way if a part of your application is corrupted, it can be fixed easily thereby eliminating the possibility of completely shutting down your software. This book will teach you how to leverage Java to build scalable microservices. You will learn the fundamentals of this architecture and how to efficiently implement it practically.</p> <p>We start off with a brief introduction to the microservice architecture and how it fares with the other architectures. The book dives deep into essential microservice components and how to set up seamless communication between two microservice end points. You will create an effective data model and learn different ways to test and deploy a microservices. You will also learn the best way to migrate your software from a monolith to a microservice architecture.</p> <p>Finishing off with monitoring, scaling and troubleshooting, this book will set a solid foundation for you to start implementing microservices.</p>
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Dominance of microservice architecture over traditional architecture


John's story

John, a good coding developer, joins a company that deals in stock exchange software. The software provided by this company also gives users recommendation of stocks, which are likely to rise in the near future. It is based on some probability logic. John has done his homework, and the very first day, he suggested a tweak in that probability logic that can improve the prediction of stocks. His suggestion was to change a few lines in the code, and John expected to finish this before lunch. The software of the company was a monolithic application with over 40 modules inside it. It took one whole day's effort from John to clone the code, figure out in which module he has to change carry out code, and the setup to run it locally. Third-party tools stub dependencies, configurations mismatch, and many other issues took time to get figured out and be resolved to run the application.

So, challenges faced by John in a monolithic environment can be summarized, as generic problems in monolithic, in the following words:

  • When we talk about monolithic, we are talking about a single large code base. It may or may not be in the small sub modules, but they are not self-dependent or self-deployable.
  • This whole code base is written in a single specific language. Excited or new developers are bound to work in that technology.
  • Being a single bundle application, if traffic increases, the whole application has to scale, even if that traffic is affecting only one module of the whole code base. A monolithic application can be scaled only horizontally by running multiple instances of the whole application.
  • As the code base grows, it becomes more prone to bugs while introducing any new feature. As modules may be interdependent of each other, the testing cycle and deployment cycle increase in the case of a monolithic application.
  • It is hard to find an ownership sense in the case of a monolithic application. Employees generally don't like to take ownership of such big projects.

In other scenario, John suggested a tweak. The application was on microservice architecture. So, John clones the receptive repository. Code cloning was fairly instant (less code, less branches). With less code, John easily figures out where to make changes. Running this microservice in a local environment was fairly easy. He committed the code and pushed for review. CI/CD is in place, so his code merged to branch and deployed in, say DevOps, the Dev environment. John was ready to ship the project just after lunch.

Although the situation is hypothetical, a similar kind of situation is encountered by most of the new joiners. Making their code live on the very first day increases the confidence of an employee. New joiners can be productive on the very first day, if they have to grasp less code base at the beginning. Understanding a big monolithic code base and having working knowledge of a fair number of modules may take a week's time or more by a new joiner before starting.

Microservice architecture brings many benefits to the organization. It breaks the whole application into smaller services, typically each in a different code repository. Smaller codebases are easy to understand. Microservices works on the isolation principle also, so deployment of each microservice doesn't affect the existence of other microservices. It makes applications language agnostic. Each service can be written in a different language with a different database (SQL, MongoDB, Cassandra, and so on). The application can accommodate a completely heterogeneous technology stack. This offers the developer the freedom to choose a language for their microservice.