Java Microservices
Java Microservices
Java microservices ⟶ are a set of small, independent applications written in Java that
work together to form a larger system. Each microservice has a specific, limited scope
and runs in its own process, communicating with other services using lightweight
protocols like HTTP or messaging. Spring Boot, Jersey, and Swagger are some Popular
Java frameworks used for building microservices.
1. Any changes in the code lead you to test the entire application.
2. Developers may not have knowledge of all the modules and that's making it
harder to get started with any module and also fix any issues.
Different services have an different database and servers so it won’t affect others...
1. Embedded Server
2. Support Load Balancer ⟶ Auto scaling
3. Auto Configuration ⟶ session, connection etc..
4. Minimal Code using Annotations
5. Loose Coupling
6. Dependency Management
7. Open Source
Auto-scaling means that there are lots and lots of loads coming to one particular
service like some more customers coming in and logging into the application
1.Service Discovery:
IP and port number of Service-B. All detailed information will be there with
Discovery Service.
Service Registry :
All the services whenever they are starting off they are registering themselves with
the discovery service and now the discovery service is maintaining all their
information inside a particular map or a list or a database.
Key Terminologies:
Eureka: It is the service registry and discovery server and it can provided by
Netflix. It can allow the microservices to register themselves and discover the
other services dynamically. It can enable easy communication between the
services in the distributed environment.
Service Registry: The service registry is the database containing the network
locations of the service instances. It can allows the services to the register
themselves when they become the available and deregister when they are no
longer available.
Service Discovery: It is the process of the dynamically finding and locating the
available service instances within the distributed system. It can allowing the
services to the communicate with the each other without the hardcoding their
network locations.
Eureka Server: It is the service registry server can provided by the Netflix
Eureka. It can hosts the registry of the available microservices and it can
provides the interface for the service registration, discovery and health
monitoring.
Eureka Client: It is the library that can enables the microservices to the registry
itself with the Eureka server and discovery the other services registered with
the server. It can provides the integration with the Spring boot applications to
the enable the service registration and discovery.
Instance Registration: It is the process by the which the microservices registers
itself with the Eureka server upon the startup. It can includes the providing the
metadata such as the service name, host, port, health status etc.
Instance Deregistration: It is the process by the which a microservices removes
itself from Eureka sever registry when it shuts down or becomes the
unavailable.
Service Name: It is the unique identifier assigned to the microservice. It can be
used by the other services to the discover and communicate with the
microservice.
Load Balancing: It is the process of the distributing incoming requests across
the multiple service instances to the ensure optimal resource utilization and
high availability. Eureka can provide the client side load balancing by the
providing the list of the available service instances to the client.
2.API Gateway : It is basically the entry gate for taking entry into any application by
an external source.
3.Load Balancing :
The goal is to optimize response time, and avoid overload per unit.
4.Circuit Breaker
The Circuit Breaker is the mechanism that prevents the application from repeatedly
trying to execute the operation that is likely to fail the application.
It monitors the number of recent failures and when the threshold is reached, breaks
the circuit and stops the operations for the predetermined period.
Tools for implementing the Circuit Breakers are Hystrix and Resilience4j.
5.Messaging and Event-Driven Architecture
1. Apache Kafka
2. RabbitMQ
6.Deployment:
AWS Elastic Beanstalk is a fully managed service that simplifies the deployment,
operation, and scaling of web applications and services in the AWS Cloud.
AWS Elastic Beanstalk is an ideal solution for deploying Spring Boot applications
because it provides a straightforward and cost-effective approach to execute and
grow Java web apps without worrying about the underlying infrastructure.