If we develop all the functionalities in single project then it is called as Monolith architecture based application.
We will package our application as a jar/war to deploy into server.
As monolith application contains all functionalities, it will become fat jar/war.
Advantages
1) Easy to develop and manage.
2) Everything is available at one place.
3) Configuration required only once.
Dis-Advantages
1) Difficult to maintain
2) Single point of Failure
3) If we perform any changes than the complete project is re-deploy and tested.
4) Developer may not be knowledge of entire modules so its harder to get started fixing issue.
5) if some module got to much load than we need to create the multiple instances of the complete application so that takes to much space because each module is tightly coupled with each other.
To overcome the problems of Monolithic, Microservices architecture came into market
Microservices is not a programming language or framework or API. Microservices is an architectural design pattern.
Microservices suggesting to develop application functionalities with loosely coupling.
In Microservices architecture we don't develop all the functionalities in single project. We will divide project functionalities into several REST APIs.
Microservices is not related to only java. Any programming language specific project can use Microservices Architecture.
Microservices is an approach using that we develop the small small services, each service is run on its own container/process/server, the services should be lightweight and independently deployable. This allows for faster development, deployment and scalability.
As you can see that employee module, customer module, address module and course module of monolith application now converted into small small service so here they are like employee service, customer service, address service and course service. and in monolith application there is single database use but in microservice application each service having its own database. and they are now dependent to each other. and each service is communication with each other throw the rest calls.
Advantages
Database Independence.
Each service is independent to each other (Loosely Coupling) so we can deploy each service independently.
if perform the any changes in any service there is no need to deploy all the service, only one service deploy single as well.
Dev working on one service doesn't requires the knowledge of entire application.
The failure of a single microservice does not impact the entire application, enhancing overall resilience.
Smaller codebases and separation of concerns make maintenance and debugging more manageable.
Due to their smaller and independent nature, individual microservices can be scaled independently based on demand, without having to scale the entire application.
Each service can be tested differently.
Disadvantages
company.name=tier3Hub
so if we want to change the name of company than in all the services we need to change the name.
Testing a microservices-based application can be more complex due to the interdependencies and interactions between services.
each service handle the some specific amount of request after that if we send more request than service is down so we need the multiple instances of the that service and to route the request in different instance of the service we need a load-balancer which balanced the request coming from the clients and routes in different instance. but writing the load-Balancer in Java is hard.
Java provides the framework called the Spring-Boot for developing the Rest API's and Spring-Boot provides lots of features like auto-configuration, embedded server, if we are developing the service so there is need of deploying sech service on the server and spring-Boot provides the tomcat server, so each service is running on different ports of tomcat. for example employee service is running on port 8080, course service is running on port 8081 and each service having its own server.
with the help of spring-Boot provides features for fast development, Less configuration, Production Ready application and stater project
and there is project under the Spring Framework Called Spring Cloud that provides the Ready made support microservices, Spring Cloud provides some common tools and technique to quickly develop common pattern of microservices.
We don't have any fixed architecture for Microservices, Dev are customizing microservices architecture according to their Project requirement, Most of the projects will use below components in Microservices Architecture.
1) Service Registry (Eureka Server)
2) Services (REST APIs)
3) Interservice Communication (FeginClient)
4) API Gateway
5) Admin Server
6) Zipkin
Microservices in Java have transformed the way we approach software development, bringing a new level of flexibility, scalability, and resilience to the table. Java's rich ecosystem, combined with frameworks like Spring Boot, Micronaut, makes it an excellent choice for building microservices that can stand up to the demands of modern applications.
As we’ve explored this architecture, it's clear why microservices have gained popularity over traditional monolithic applications. They offer modularity and independence, allowing teams to develop, deploy, and scale services individually. This is especially valuable in a world where cloud-native features are increasingly becoming the standard. However, the journey also reveals challenges like ensuring data consistency, managing inter-service communication, and maintaining robust security across services.
Staying updated with the latest advancements in tools and practices is crucial for Java developers working with microservices. The landscape is constantly evolving, and those who adapt will be best positioned to leverage the full potential of this architecture. The future of microservices in Java looks promising, with ongoing improvements in frameworks and tools, supported by a growing community of developers eager to share their knowledge and experience.
Embracing microservices in Java means opening doors to creating more resilient, scalable, and maintainable applications. By following best practices and staying committed to continuous learning, developers can unlock new possibilities in software development, leading to more innovative and efficient solutions.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3