L6 - Monolithic vs. Microservice Application Architecture Flashcards
What is a monolithic architecture?
Design of a software program which is one piece
A typical server-side application has a layered structure with the following components:
- database which consists of many tables in a Relational Database Management System (RDBMS)
- client-side user interface (consisting of HTML pages and/or JavaScript running in a browser)
- a server-side application
client side vs. server side
Client-side means that the processing takes place on the user’s computer. It requires browsers to run the scripts on the client machine without involving any processing on the server.
Server-side means that the processing takes place on a web server. (e.g. authentication)
Benefits of Monolithic Architecture
- easy to develop (everything is handled in the same place)
- simple to test (end-to-end testing can be implemented by launching the application and testing the UI with the desired outputs)
- simple to deploy (copy the package application to a server for deployment)
- easy horizontal scaling (simple to scale horizontally by running multiple copies of the complete application behind a load balancer
Drawbacks of a monolithic architecture
- limitations in size and complexity (you cannot make continuous additions to previous code)
- too large and complex (difficult to make changes fast and correct)
- slow start time (start time depends on size of application)
- re-deployment of the complete application on update (entire application must be re-deployed which increases the downtime)
- reliability (a bug in any module can break down the entire process)
- barriers to adopting new tech and difficult to scale
What is Microservices Architecture?
- split the application into a set of smaller and interconnected services
each service: - communicates with a common communication protocol like REST web service with JSON
- runs individually
- services can be present in a single machine or different ones
- may have own databases
Can a single programmer implement, design, deploy, and maintain a microservice?
Yes
Is the data independent of other services in microservices?
Yes the data is in a single bounded context.
How are services in the Microservices Architecture addressable?
Through the Service Discovery System
How do operations take place on Microservices?
Operations are stateless. Everything the services need to know is supplied on the request and once the request is complete they forget it.
Benefits of Microservice Architecture
- easier to understand and maintain
- independence of services
- no barriers on adopting new technologies
- independent service deployment (continuous deployment is possible for complex applications)
- each service can scale independently
Drawbacks of Microservices
- complexity of creating a distributed system
- deployment complexity
Why is there a complexity of creating a distributed system?
- developer tools/IDEs are oriented on building monolithic applications
- testing is more difficult
- implementation of inter-process communication is necessary
- implementing use cases that span across multiple services without using distributed transactions is difficult
Why is there deployment complexity for Microservices?
- each service will have multiple runtime instances
- each instance needs to be configured, deployed, scaled, and monitored
- you need to implement a service discovery mechanism
What is a Service Mesh
- configurable, low-latency infrastructure layer
- designed to handle a high volume of network-based interprocess communication among application infrastructure services using application programming interfaces (APIs)
- ensure that the communication among containerized and other application infrastructure services is fast, reliable, and secure
Example of a service Mesh provider
Istio
Microservice Application Framework Components
API Gateway (Service Discovery, Service Registry)
Resilience
Deployment Strategies
Rolling Updates
What is an API Gateway?
Server that is the single-entry point into the system. Encapsulates the internal system architecture and provides an API that is tailored to each client.
Do you need a Gateway more for monolithic applications or for microservices?
More for microservices. For Microservices because the client must otherwise query every service individually.
What is backends for frontend patterns?
It defines a separate API gateway for each kind of client. It is a design pattern created with not only the developer but, more importantly, the user and their experience in mind. It is the answer to the ever-growing adoption of applications to meet, interact, and serve customers, ensuring consistency while still meeting their diverse and evolving needs.
Web app has Web API gateway
Mobile app has Mobile API gateway
Others have a public API gateway
What is a service registry?
- database containing the network location of service instances
- it needs to be highly available and up to date
Examples of service registries
- Netflix Eureka: provides REST APIs for registering and querying service instances
- etcd: key-value store used by Kubernetes and Cloud Foundry
Why is the a problem with finding the service location?
- API Gateway and other services (called Service Clients) require to know the network location (IP address and port) of service instances
- in a microservice application each service instance is assigned an IP address dynamically because of autoscaling, failures, and upgrades
Client-Side Service Discovery
- client (API Gateway or other services called service clients) are responsible for determining the network location of available service instances
- the client queries a service registry, which is a database of available service instances
- the client then uses a load-balancing algorithm to select one of the available service instances and makes a request
Pros of client-Side Service Discovery
- straightforward and, except for service registry, there are no other moving parts
- client can make intelligent, application-specific load-balancing decisions as it knows about the available service instances