Microservices and Backend - Q and A
Microservices and Backend - Q and A
Microservices and Backend - Q and A
Microservices Definition.................................................................................................................2
SOA Definition................................................................................................................................3
Microservices vs SOA......................................................................................................................4
Microservices Characteristics.........................................................................................................4
Microservices Advantages and Disadvantages...............................................................................5
Microservices Principles.................................................................................................................6
Microservices Guidelines................................................................................................................6
Microservices Patterns....................................................................................................................7
Improving Performance...................................................................................................................8
Phoenix Server................................................................................................................................8
Microservices Definition
Q: What is a Microservices?
A: Some definitions of Microservices
“The concept of a microservice initially crept into the software development community’s
consciousness as a direct response to many of the challenges of trying to scale (both
technically and organizationally) large monolithic applications. A microservice is a small,
loosely coupled, distributed service. Microservices let you take an extensive application and
decompose it into easy-to-manage components with narrowly defined responsibilities.
Microservices help combat the traditional problems of complexity in a large codebase by
decomposing it down into small, well-defined pieces. The key concepts you need to embrace as
you think about microservices are decomposing and unbundling” (Spring Microservices in
Action-2nd Ed)
SOA Definition
Q: What is a SOA?
A: Some definitions of SOA
Microservices vs SOA
Microservices SOA
Communication Generic Specific
Data Per services Shared
Scope Small Large
Microservices Characteristics
Application logic is broken down into small-grained components with well defined,
coordinate boundaries of responsibility.
Each component has a small domain of responsibility and is deployed independently of
the others. A single microservice is responsible for one part of a business domain.
Microservices employ lightweight communication protocols such as HTTP and JSON
(JavaScript Object Notation) for exchanging data between the service consumer and
service provider. Because microservice applications always communicate with a
technology-neutral format (JSON is the most common), the underlying technical
implementation of the service is irrelevant. This means that an application built using a
microservice approach can be constructed with multiple languages and technologies.
Microservices—by their small, independent, and distributed nature—allow organizations
to have smaller development teams with well-defined areas of responsibility. These teams
might work toward a single goal, such as delivering an application, but each team is
responsible only for the services on which they’re working.
Finding the right set of services is challenging and requires substantial domain
knowledge
o The mistake of distributed monolithic
o You may need to refactor across multiple distinct codebases.
o You may need to migrate data from one service’s database to another.
o You may not have identified implicit dependencies between services, which could
lead to errors or incompatibility on deployment
The right boundaries and contracts between services are difficult to identify and, once
you’ve established them, can be time-consuming to change.
o Good contract
Complete —Defines the full scope of an interaction
Succinct —Takes in no more information than is necessary, so that
consumers can construct messages within reasonable bounds
Predictable —Accurately reflects the real behaviour of any
implementation
Distributed systems are complex, which makes development, testing, and deployment
difficult.
By distributing system components across networks, and increasing technical
heterogeneity, microservices introduce new modes of failure.
o Fallacies
The network is reliable.
Latency is zero.
Bandwidth is infinite.
Transport cost is zero.
Deploying features that span multiple services requires careful coordination
Deciding when to adopt the microservice architecture is difficult.
It’s more challenging to understand and verify what should happen in normal operation.
o Observability is difficult to achieve
o Multiplying services multiplies points of failure
o Questions
If something goes wrong and your user’s order isn’t placed, how would
you determine where the fault occurred?
How do you deploy a new version of a service without affecting order
placement?
How do you know which services were meant to be called?
How do you test that this behaviour is working correctly across multiple
services?
What happens if a service is unavailable?
Microservices Principles
Microservices Guidelines
Right-sized—How you ensure that your microservices are properly sized so that you
don’t have a microservice take on too much responsibility. Remember, properly sized, a
service allows you to make changes to an application quickly and reduces the overall risk
of an outage to the entire application.
Location transparent—How you manage the physical details of service invocation. When
in a microservice application, multiple service instances can quickly start and shut down.
Resilient—How you protect your microservice consumers and the overall integrity of
your application by routing around failing services and ensuring that you take a “fail-
fast” approach.
Repeatable—How you ensure that every new instance of your service brought up is
guaranteed to have the same configuration and codebase as all the other service instances
in production.
Scalable—How you establish a communication that minimizes the direct dependencies
between your services and ensures that you can gracefully scale your microservices.
Microservices Patterns
Improving Performance
Phoenix Server
Benefits in Microservices
Improved Resilience:
If a server becomes unhealthy or experiences an issue, it can be terminated and
replaced with a new instance, minimizing downtime and improving overall
system resilience.
Simplified Deployment Pipeline:
The deployment process is simplified because it focuses on creating new
instances rather than modifying existing ones. This reduces the complexity of
deployments and the potential for errors.
Enhanced Security:
Regularly replacing servers with new instances reduces the window of
opportunity for attackers and ensures that security patches and updates are
consistently applied.
Easier Maintenance:
Maintenance tasks are simplified since there is no need to perform in-place
updates or maintenance on long-lived servers. Instead, new servers are deployed
with the required updates or fixes.
Conclusion
The phoenix server approach in microservices promotes a dynamic, flexible, and robust
infrastructure. By treating servers as disposable and ensuring that each deployment starts fresh,
organizations can achieve greater consistency, reliability, and security in their microservices
architecture.