Skip to main content

dtechbits: CAP Theorem

 

Consistency
Every read receives the most recent write or an error.
Availability
Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
Partition tolerance
The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.

When a network partition failure happens, it must be decided whether to do one of the following:

  • cancel the operation and thus decrease the availability but ensure consistency
  • proceed with the operation and thus provide availability but risk inconsistency.
CAP Theorem Euler Diagram

Thus, if there is a network partition, one has to choose between consistency or availability. Note that consistency as defined in the CAP theorem is quite different from the consistency guaranteed in ACID database transactions.[4]




Linearizability  or strict consistencyLinear consistency to execute the operations are executed in an order. It provides the definitely updated data as earlier operations are expected to complete atomically inlinear order even though the operations might have done in parallel or concurrently.

Linearizability can be achieved by

1. Distributed locking

2. Two-phase commit

3. Distributed data store with consensus algorithms like Paxos or Raft



PACELC theorem :

The PACELC theorem is an extension of the CAP theorem, providing additional insights into the behaviour of distributed systems during network partitions. The acronym PACELC stands for:

  1. P (Partition tolerance)

  2. A (Availability)

  3. C (Consistency)

  4. E (Else):

    • The "Else" in PACELC suggests that in the absence of network partitions, the system should strive to achieve both consistency and availability. In other words, when the network is not partitioned, the system should aim to be both consistent and available.
  5. L (Latency):

    • PACELC includes an additional factor, "Latency," which highlights the importance of considering the performance characteristics of the system. It emphasises that the system's behaviour during normal operation (without partitions) should also take into account the latency of operations.
  6. C (Complexity):

    • Some versions of the theorem include an additional "C" for "Complexity," which suggests that the decision-making process during network partitions can introduce additional complexity to the system.







Comments

Popular posts from this blog

Safety property that a deadlock can never occur

Identified four necessary conditions for a deadlock to occur 1. Mutual Exclusion. The nodes claim exclusive control of the resources they require. 2. Wait for. Tasks hold resources already allocated to them while waiting for additional resources. 3. No preemption. Resources cannot be forcibly removed from the tasks holding them until the resources are used to completion. 4. Cyclic Wait. A cyclic chain of tasks exists, such that each task holds one or more resources that are being requested by the next task in the chain. References: For information about system deadlocks please refer: E. G. Coffman, M. Elphick, and A. Shoshani. System Deadlocks

OWASP API Security Top 10 vulnerabilities 2023

API Security Do's and Don'ts Don't trust input data for an API and do validate all inputs. Ensure you understand security and keep sensitive data out of code. Don't hardcode keys/tokens Don't reveal useful info in error messages. Don't have hidden/unadvertised features. Don't filter data in UI - control at app level Don't confuse authentication and authorization Always use API gateways to control access and traffic Do require API documentation. Do expect users/hackers to find and use undocumented endpoints Do continuous testing - attack simulation, test configs, fuzzing, injections OWASP API Security Top 10 Vulnerabilities 2023 API-1:2023 - Broken Object Level Authorization: BOLA is still the leading vulnerability that plagues APIs. When data objects do not have sufficient access controls in place, resources can be accessed by unauthorized users. API-2:2023 - Broken Authentication  Broken Authentication contains all vulnerabilities associated with auth...
Program to print items in single linkedlist in Pendulum order  Single linked list pendulum in java There are sequence of numbers in a single linked list and display the result in pendulum format Input : 1 2 3 4 5 6 7 8 Output : 1 8 2 7 3 6 5 4 Solution :  https://github.com/Bonu/datastructures/blob/main/SingleLinkedListPendulum.java Below is the manual approach: Input: 1 2 3 4 5 6 7 Iteration 1: 1 2 3 4 5 6 7 Iteration 2: 1 7 2 3 4 5 6 Iteration 3: 1 7 2 6 3 4 5 Iteration 4: 1 7 2 6 3 5 4