☰ See All Chapters |
What are microservices?
There is no official definition of Microservices by industry standards because Microservices is not a technology, not a framework, it is an architecture style. Microservices is an evolution of Service-Oriented Architecture (SOA). Each service could be developed, built, tested, and deployed independently, where each service provides the services to other services or external entities. Microservices are the solutions to the limitations of monolithic architecture. So then what is monolithic architecture and which are its limitations?
Monolithic Architecture
Monolithic architecture allows the development of different modules/sections of application in a single unit. All the modules depend on one or other modules. In monolithic architecture entire application is bundled together in Enterprise Archive (EAR) or Web Archive (WAR) files.
A large bank application can consist of following modules:
Deposit module
Withdraw module
Loan Module
Logging Module
Error Handling Module
Session Module etc…
As we can see above, application has three layers and each layer has all the modules. All these three layers may contain different technologies but finally will be packaged into one single unit.
Microservice Architecture
Each component could be developed, built, tested, and deployed independently. Here, even the application User Interface (UI) component could also be a client and consume the microservices.
Limitation of monolithic architecture
All the modules are bundled together and tightly coupled in monolithic architecture. In microservices, design components are not bundled together and have loose coupling. Each service has its own layers and DB, and is bundled in a separate archive.
In the above example if deposit module is consuming more resource like memory, then if you increase the memory resource it increases for all modules where it is not necessary, you cannot scale the resource to individual modules in monolithic architecture. Microservices gives the flexibility to scale only those services where scale is required and it allows optimal utilization of the resources.
If one module failed to operate then in monolithic architecture, entire system stops as all the modules are in single unit. In microservices if one service fails, rest of the service can still be running. If deposit service fails withdraw, debit services can still be running.
If you want upgrade the technology in one module, as an example if you want to upgrade java version you may have to upgrade your server to support new java implementations. This server up gradation affect entire unit and all modules now need to adopt new java version. But in microservices architecture technology adoptions can be done in any service without touching other services.
In monolithic architecture, development teams should be aware of all the modules. But in microservices architecture teams can work independently without worrying about other team services. This increases the productivity in organizations.
What are the technologies/frameworks available in java to support microservices architecture?
There is no particular technology or framework to support microservices architecture. It is big miss understanding among developers that they say application is using microservices technology where they use spring boot with spring rest template. They just use spring boot to make development faster and at the end they package into single WAR or EAR and deploy in one server. Where is the microservices architecture here?
To call an application/service as microservices it should be able to run independently providing service to other external entities. Below technologies/frameworks fasten the development in microservices architecture.
Spring Boot
Wildfly swarm
Swagger
Spark Framework
Paly Framework
Any implementations of JAXRS API
JAXWS API
Restx etc…
How spring boot is used in microservices?
Now you have a question how the above technologies/frameworks can fasten development in microservices architecture? The answer for this question is all above technologies/frameworks provides their built in embedded servers, we don’t need any external server support to expose services. Yes even JAXRS, JAXWS web services can be published using Endpoint.publish, without any external server.
Now definitely you have another question, any technology/framework with embedded server support can only be used in microservices architecture. This is absolutely wrong; Using above technologies/frameworks just fasten the development in microservices architecture by reducing the external use of deployment servers.
By reading so far you might have understood clearly that Microservices is not a technology, Microservices is an architecture style. This microservices architecture can be understood perfectly only when you work on real time projects with microservices architecture. There is nothing to read and learn in microservices architecture. It is only implement and learn.
All Chapters