Chapter 3, Connectivity and Composition Patterns Flashcards
What are native connectivity patterns?
Native connectivity patterns allow you to build connectivity among microservices as well as with other systems in your cloud native application. As discussed in Chapter 1, a cloud native application consists of microservices and may also connect with existing proprietary or legacy systems, external services such as software-as-a-service (SaaS) applications, databases, messaging infrastructure such as message brokers, and more.
Page: 95
What should be considered when connecting more microservices and systems in a cloud native application?
The more microservices and systems we have to connect, the greater the complexity of the entire cloud native application. Before applying connectivity patterns, ensure the appropriate service granularities are used. Too many interactions among microservices indicate a too fine-grained service design scope, necessitating a revisit of the microservice design phase to redefine the service scope directly mapped to business capabilities. The foundational communication patterns should be determined by the business use case. Interactive business capabilities like searching for items in an online store need a synchronous Request-Response pattern, while placing orders requires an asynchronous Single-Receiver pattern. We should identify or define service interaction styles and underlying protocols during the microservice design phase. Ensure infrastructure is not leaked into the application’s connectivity logic to maintain portability. Service connectivity capabilities not mandatory for application behavior should be implemented at other layers, like sidecars.
Page: 100
What is a Kubernetes service?
A Kubernetes service groups a set of pod endpoints into a single resource. You can configure how you access that service in various ways, such as load balancing or cluster IP.
Page: 105
What does a Kubernetes service provide for grouped pods?
Kubernetes service provides seamless load balancing among the grouped pods. Using the service type LoadBalancer, Kubernetes automatically creates a cloud network load balancer of the underlying cloud platform (AWS, Azure, GCP, etc.), which provides an externally accessible IP address that sends traffic to the correct port on your cluster nodes.
Page: 106
What is the Service Abstraction pattern?
With the Service Abstraction pattern, you can expose any other monolithic or proprietary systems consumed by your cloud native application as a service.
Page: 105
What are the considerations for using the Service Abstraction pattern?
Service Abstraction is essential for cloud native applications to achieve scalability, redundancy, and encapsulation of microservices and other systems. While possible to implement without an underlying platform, using a platform like Kubernetes that supports service abstractions as a first-class construct is recommended.
Page: 106
What is a service registry and what information does it contain?
A service registry is a repository containing service information and metadata, such as service URLs, service interface definitions, service-level agreements, and other useful information for service consumers. Implemented as a service offering a registry repository API and discovery API, service owners/developers register and maintain the service information, while consumers use the registry to learn how to consume the service.
Page: 107
What are the two ways to implement the Service Registry and Discovery pattern?
The Service Registry and Discovery pattern can be implemented in two ways: client-side service discovery, where the client is responsible for service discovery, and server-side discovery, where an intermediate component like a load balancer handles service discovery.
Page: 108
How does Kubernetes handle service discovery?
Kubernetes uses DNS names to discover pods, resolving and mapping service names to actual endpoints. Kubernetes uses etcd as the distributed key-value store for service registry, but it may require a dedicated service registry like Consul for complex service registry and discovery requirements.
Page: 110
What should be considered when using the Service Registry and Discovery pattern?
Service Registry and Discovery is essential for building cloud native applications. However, a full-blown solution is not necessary from day one, as platforms like Kubernetes and cloud services (AWS, Azure, GCP) offer primitive capabilities. Invest in a dedicated solution if advanced capabilities like managing service dependencies, health checks, and leader election are required.
Page: 111
What related patterns are used with the Service Registry and Discovery pattern?
Service Registry and Discovery is foundational for most connectivity patterns. In API management, dedicated API registries known as API developer portals are used to store and expose business capabilities as APIs.
Page: 111
What is the purpose of a time-out in service calls?
A time-out prevents a caller service from waiting indefinitely for a response from a target service, enhancing application responsiveness. Realistic time-out values should be set based on network latency and target service processing time.
Page: 113
What is retry logic in resilient connectivity?
Retry logic aims to get the expected response despite network disruption by invoking the same service multiple times. Specify the number of retries and duration between retries, and define logic for handling maximum retry count reached.
Page: 114
What are deadlines in resilient connectivity?
Deadlines specify a fixed point in time for completing a service invocation. They are useful for chains of services, where each service checks the deadline and invokes deadline-exceeded logic if expired.
Page: 115
What is a circuit breaker in resilient connectivity?
A circuit breaker prevents further service invocations if previous invocations failed and the circuit state reaches a threshold. It switches between closed, open, and half-open states to manage service invocation failures and recovery.
Page: 116
What is the fail-fast principle?
Fail-fast detects failures related to service connectivity as quickly as possible, often by validating requests before sending them to the target service.
Page: 117
What are the considerations for resilient connectivity?
Resilient connectivity is essential for cloud native applications and can be implemented as part of the service’s business logic, a separate runtime (sidecar), or via underlying cloud services. Resilient connectivity styles can be combined with various communication patterns.
Page: 119
What patterns are often used with the Resilient Connectivity pattern?
The Resilient Connectivity pattern is often used with the Sidecar and Service Mesh patterns.
Page: 119
How does the Sidecar pattern work for service connectivity?
The Sidecar pattern offloads interservice communication logic to a separate runtime colocated with the main microservice. This is often implemented as a colocated container with the main container in Kubernetes pods, allowing clear separation of concerns and easier management and scaling.
Page: 120
How is the Sidecar pattern used in practice?
The Sidecar pattern is often realized with platforms like Kubernetes, encapsulating a sidecar-based microservices application as a multicontainer pod. This allows clear separation of business logic and enhancement logic while managing and scaling the application as a single unit.
Page: 121
What is a sidecar proxy?
A sidecar proxy mediates inbound and outbound communication to the main microservices it is attached to, handling additional network communication features like security or service discovery.
Page: 122
What is a sidecar bridge?
A sidecar bridge allows communication between two different protocols. For example, a main container communicating with HTTP can connect with messaging systems like Kafka through a sidecar bridge.
Page: 123
What pattern is closely related to the Sidecar pattern?
The Sidecar pattern is closely related to and extended by the Service Mesh pattern.
Page: 126
What challenges does the Service Mesh pattern address?
The Service Mesh pattern addresses challenges in building connectivity between microservices and systems, offloading interservice communication logic to a different layer to keep service code independent. This pattern is used instead of the centralized ESB architecture, reducing the complexity of business logic and development time.
Page: 126
How does the Service Mesh pattern work?
Service Mesh implementations define a configuration language or API to control capabilities and manage the data plane via the control plane. Reliability, security, observability, service discovery, and policy enforcement are applied at the data-plane level and controlled through the control plane.
Page: 129
What is the relationship between the Service Mesh pattern and other patterns?
The Service Mesh pattern is closely related to the Service Connectivity and Sidecar patterns.
Page: 132
What is the Sidecarless Service Mesh pattern?
The Sidecarless Service Mesh pattern eliminates the need for a sidecar by embedding sidecar proxy logic into the microservice runtime, directly managing and controlling network communication via the control plane.
Page: 132
How does the Sidecarless Service Mesh pattern work?
The Sidecarless Service Mesh pattern uses a control plane to manage and configure communication between microservices, embedding mesh traffic logic into the microservice runtime. This requires each implementation technology to support the control plane API and network communication logic at each layer.
Page: 133
What are the considerations for using the Sidecarless Service Mesh pattern?
Sidecarless Service Mesh is an emerging pattern that overcomes the limitations of sidecar-based service mesh architecture. It requires client libraries to support service mesh control plane APIs and network communication logic.
Page: 136
What related patterns are associated with the Sidecarless Service Mesh pattern?
Sidecarless Service Mesh is an alternative to the Service Mesh pattern with a sidecar proxy. Resilient communication patterns are often implemented at the control plane–compliant client libraries used to build microservices.
Page: 136
What is the relationship between Service Orchestration and Service Choreography?
Service Orchestration is used alongside Service Choreography in a hybrid way, often requiring both synchronous and asynchronous service interactions.
Page: 145
What patterns are used in conjunction with Service Orchestration?
Service Choreography is often used with Service Orchestration in a hybrid manner, using asynchronous communication patterns like Single-Receiver and Multiple-Receiver.
Page: 150
What is the main protocol used in implementing distributed transactions?
Distributed transactions use the two-phase commit (2PC) protocol to orchestrate transaction steps through a transaction manager.
Page: 151