MicroServices Flashcards
What are microservices?
Decomposing an application’s processes into separate services that work together independently of one another to process user requests.
Advantages to microservices
- Services are independently deployable and scalable
- It allows for different services to be written in different programming languages.
- Scalability and reusability
- Work well with containers such as Docker
- Better fault isolation; if one microservice fails, the other will continue to work
- Handling traffic well - instances of services created as needed
- Loose coupling
Disadvantages to microservices
- DevOps complexity - Due to several moving parts of the application. It becomes complex.
- Increased Resource use - Initial investment to run these applications are high because all the independently running components need their own containers
- Ease overhead - people need to communicate to make sure update doesn’t occur error on other services, Cost to monitor each individual service
- Databases are more difficult to keep normalized
What is eureka?
- client side discovery pattern
- client obtains the location of a service instance by querying a service registry, which knows the locations of all service instances.
- Ribbon creates requests by load balancing algorithms
What is zuul?
- Zuul acts as an API gateway. It receives all the requests coming from the UI and then delegates the requests to internal microservices.
- The client calls this service as a proxy for an internal microservice, then this service delegates the request to the appropriate service
- The advantage of this type of design is that common aspects like CORS, authentication, and security can be put into a centralized service.
- we can implement any routing rules or any filter implementation
What is a configuration server?
- Configuration server to centralise management of all the configuration files
- mainly responsible for providing properties files to each microservice connected to the discovery server
What is Hystrix?
- Circuit breaker module
- wrap a protected function call in a circuit breaker object, monitors for failures,. and when it happen it trips and further calls to circuit breaker return an error without call being made at all. This will prevent cascade error across multiple system by run out of critical resources.
What is docker?
Docker is a computer program that performs operating-system-level virtualization also known as containerization
Annotations of Eureka and what they do?
- @EnableEurekaServer - to stand up a registry that other applications can talk to
- @EnableEurekaClient - to in the list of registered applications
- @EnableZuulProxy - sets up Zuul so that you can configure routing without Eureka; will turn the Gateway into a reverse proxy that forwards relevant calls to other services
How does Zuul employ discovery for the routes to services?
@EnableDiscoveryClient - to be used with Discovery to enable dynamic routing
Annotations of Hystrix and what they do?
- @HystrixCommand(fallbackMethod = “methodName”) - place this annotation above a method you want Spring Cloud Netflix Hystrix to look for
- The annotation wraps that method in a proxy connected to a circuit breaker so that Hystrix can monitor it
- ONLY WORKS in a class marked with @Component or @Service
- Example of fallbackMethod is reliable; specify it to provide a placeholder of what you need for users
What is spring boot?
Opinionated view of the Spring platform to make it easy to configure Spring applications for various use cases.
What is spring data?
Spring module for abstracting database connection and querying operations using Hibernate as its ORM (Object Relational Mapper)
What is the docker workflow?
- code app
- make a docker file
- build an image using the docker file
- run a container from the image
- push to docker hub if you want
What is a docker image?
A snapshot of the system that contains everything needed to run the application on any machine. Build code plus the needed environment.