Nagesh Kumar Siddu
Nagesh Kumar Siddu
  • 34
  • 944
BASE and 2 Phase Commit
BASE, Two Phase Commit and Saga
Let us assume our application has 3 microservices.
1. Order Service: Manages orders placed by customers.
2. Inventory Service: Manages product stock levels.
3. Payment Service: Handles payment processing.
Introduction to BASE
Distributed systems often adopt the BASE principle over strict consistency for scalability and availability:
• Basically Available: Guarantees that the system remains available for most operations, even under failure conditions.
• Soft state: The state of the system may change over time, even without external input (due to eventual consistency).
• Eventual consistency: Guarantees that the system will become consistent eventually, as updates propagate.
Example: When a user places an order, services work asynchronously to ensure stock is deducted, payment is processed, and the user is notified. The consistency of all services is eventually achieved.
Handling transactions
1) 2 PC and 2) Saga
1. Two-Phase Commit (2PC)
2PC ensures atomic consistency across distributed services by coordinating operations in two phases: Prepare and Commit/Abort.
How It Works:
1. Prepare Phase:
o A coordinator service initiates the transaction and asks all participating services (e.g., Order, Inventory, Payment) to "prepare" for the operation.
o Each service checks if it can perform the operation (e.g., sufficient stock or payment approval) and locks the necessary resources.
o Services respond to the coordinator with a yes (prepared) or no (abort).
2. Commit Phase:
o If all services respond with yes, the coordinator sends a commit message to all participants, finalizing the transaction.
o If any service responds with no, the coordinator sends an abort message to roll back any partial changes.
Example:
1. The user places an order.
2. The coordinator sends a prepare request:
o Order Service reserves the order.
o Inventory Service locks stock.
o Payment Service holds the payment amount.
3. If all services respond with "prepared," the coordinator sends a commit:
o The order is finalized, stock is deducted, and payment is captured.
4. If any service fails, the coordinator sends an abort, rolling back all changes (e.g., releasing stock and refunding payment).
Challenges with 2PC:
• Performance overhead: Locks held during the prepare phase can slow down the system.
• Single point of failure: The coordinator is critical and can become a bottleneck.
• Not resilient to partial system failures or partitions.
#microservices #cloudnative
Переглядів: 12

Відео

Saga Orchestration and Choreography
Переглядів 814 годин тому
Saga Pattern The Saga pattern offers a more scalable alternative to 2PC by breaking a transaction into a series of smaller, independent steps with associated compensating actions (for rollback). It ensures eventual consistency. How It Works: 1. Orchestration Saga (Coordinator-Based): 2. Choreography Saga (Event-Based): Orchestration Saga (Coordinator-Based): A central saga orchestrator coordina...
CAP Theorem
Переглядів 3014 годин тому
CAP Theorem The CAP theorem (also known as Brewer's theorem) is a fundamental principle in distributed systems, particularly relevant to microservices. It states that in a distributed system, it is impossible to simultaneously guarantee all three of the following: 1. Consistency (C): Every read receives the most recent write or an error. 2. Availability (A): Every request (read or write) receiv...
TLS and mTLS
Переглядів 1214 годин тому
TLS and mTLS TLS TLS (Transport Layer Security) is a protocol that secures data when it’s being sent over the internet, preventing others from reading or tampering with it. How TLS Works (in Simple Terms) Imagine you’re sending a letter to a friend across the country. If you don’t secure the letter, anyone who intercepts it could read it. TLS is like sealing the letter in a special locked box. ...
Securing Microservices- 12 Best Practices
Переглядів 1314 годин тому
Microservices Security The microservices architecture expands the attack surface with multiple microservices communicating with each other remotely. There are multiple perspectives in securing microservices: 1. secure development lifecycle 2. test automation 3. security in DevOps 4. application-level security 1. API Gateway • Centralized entry point: An API Gateway serves as a single entry poin...
Observability - Logging, Metrics, Tracing
Переглядів 5614 днів тому
Observability Observability is the measure of how well internal states of a system can be inferred from knowledge of its external outputs. We need to track the throughput of each microservice, the number of success/failed requests, utilization of CPU, memory and other network resources, and some business-related metrics It should be incorporated into the microservices architecture & design. Obs...
Containerization
Переглядів 621 день тому
Containerization A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. C...
Containers Vs Virtual Machines
Переглядів 1821 день тому
Containers versus virtual machines (VMs) A VM is an entire operating system with its own kernel, hardware drivers, programs, and applications. A container is simply an isolated process with all of the files it needs to run. If you run multiple containers, they all share the same kernel, allowing you to run more applications on less infrastructure. #cloudnative #microservicesarchitecture
Service Mesh introduction
Переглядів 621 день тому
Service mesh Service mesh is an infrastructure layer used to manage service-to-service traffic through the capabilities provided by a set of sidecar proxies. It solves the traffic management challenges for microservice applications and manages service communication. Let us take an example Service A was expecting a response from Service B through an API call. Service B may be down or facing a he...
Declarative API
Переглядів 521 день тому
Declarative API 1. A declarative is a process where we describe a desired outcome and then the system internally implements the functionality to satisfy that desired outcome. 2. Imperative process, which tells the system how to do something, and declarative, which tells the system what to do. 3. The declarative API is an important capability of Kubernetes, and the declarative configuration allo...
Service Governance
Переглядів 1521 день тому
Service Governance Microservices need to be governed to manage them successfully. For example, 1. Services do not know each other so they need functionality for service registration and service discovery 2. Services are independent and hence anomalies related to service performance or invocation need to be observed 3. When services are overloaded with requests, they need traffic management Thes...
Microservices Vs Cloud Native
Переглядів 521 день тому
Microservices Vs Cloud Native
Tradeoffs in distributed systems
Переглядів 1521 день тому
Tradeoffs in distributed systems
Microservices trade offs
Переглядів 1321 день тому
Microservices trade offs
Characteristics of microservices application
Переглядів 1321 день тому
Characteristics of microservices application
What is micro services architecture
Переглядів 5021 день тому
What is micro services architecture
5 tips to transform a dysfunctional team to amazing work culture
Переглядів 23Рік тому
5 tips to transform a dysfunctional team to amazing work culture
6 Effective Tips for Leading with Authenticity
Переглядів 25Рік тому
6 Effective Tips for Leading with Authenticity
CBRZPH School Centenary Celebrations 2020 - Invitation by GNB Acharyulu garu of 1967 Batch
Переглядів 4915 років тому
CBRZPH School Centenary Celebrations 2020 - Invitation by GNB Acharyulu garu of 1967 Batch

КОМЕНТАРІ

  • @Shruti68-b9j
    @Shruti68-b9j 6 днів тому

    Good one

  • @Shruti68-b9j
    @Shruti68-b9j 6 днів тому

    1. Timestamps 2. Legibility in notes and explanation through mindmaps 3. Summarisation 4. Practical scenarios and usecases 5. Illustrations

  • @Shruti68-b9j
    @Shruti68-b9j 27 днів тому

    Good to listen to you after a long time nagesh. Looking forward for more transforming content

  • @Shruti68-b9j
    @Shruti68-b9j 27 днів тому

    Well explained with practical leadership focus. Would like to see more leadership lessons from you.

  • @mohanajavvaji3398
    @mohanajavvaji3398 2 роки тому

    Good

  • @tempernagagowdntr3382
    @tempernagagowdntr3382 5 років тому

    Super