Csl526 LSTH: Non-Relational Databases L24 Slides

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Ex mple of Consensus 1. Prop g te the order request to ll relev nt inventory systems.

Algorithm: Inventory 2. Initi lize n empty list to store v il bility st tuses received from e ch
Av il bility Consensus inventory system.
Algorithm 3. Iter te through e ch inventory system:
- determining product 3.1 Send request to the inventory system to check the v il bility of the
product.
v il bility cross multiple
3.2 Receive the v il bility st tus response from the inventory system.
inventory systems in n e-
3.3 Add the received v il bility st tus to the list.
commerce pl tform
4. Apply the consensus lgorithm to determine the ggreg ted v il bility
Input: Order request for
st tus:
CSL526 LSTH product
4.1 If ll inventory systems report the product s v il ble, set the
Non-Relational Databases Output: Aggreg ted ggreg ted st tus to " v il ble".
L24 Slides v il bility st tus of the 4.2 If t le st one inventory system reports the product s out of stock,
product set the ggreg ted st tus to "out of stock".
4.3 If there re con licting v il bility st tuses:
4.3.1 Resolve con licts b sed on prede ined rules.
4.3.2 Set the ggreg ted st tus ccordingly.
Anil Mokhade 21 March 2024 5. Return the ggreg ted v il bility st tus s the output of the lgorithm.

Rec p Consensus Algorithm:

- ensuring greement mong distributed nodes nd determining single v lue


despite f ilures or p rtitions

Th t me ns:

1. There w s consistency in inventory


Simil rly one c n think for scen rios where tr de-o s might be necess ry, such s s cri icing
consistency for improved v il bility or p rtition toler nce, or vice vers . 2. It w s v il ble in inventory

3. It could be p rtitioning: the network is physic lly or logic lly divided into
sep r te segments, preventing nodes in one segment from communic ting with
nodes in nother segment
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
f
a
a
a
a
a
a
f
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
f
a
a
a
CAP Theorem:*

e ch component of the CAP theorem s ys:

Consistency: All nodes in the distributed system h ve the s me view of the d t t ny In the lgorithm for determining product v il bility cross multiple inventory systems in n e-commerce
given time. pl tform, we c n observe the following spects from the perspective of the CAP theorem:

Av il bility: The system continues to oper te nd respond to requests despite


f ilures or network p rtitions.

P rtition Toler nce: The system rem ins oper tion l despite network p rtitions or
communic tion f ilures between nodes.

*The origin l reference for the P xos consensus lgorithm is the p per titled "The P rt-Time P rli ment" by Leslie L mport, which w s published in 1998.

Av il bility (A):

For the Inventory Synchronis tion Ex mple of eCommerce System: the CAP theorem c n be The lgorithm prioritizes v il bility by ensuring th t the e-commerce pl tform c n continue
observed in how the system oper tes under di erent conditions: serving customer requests even in the presence of f ilures or p rtitions in some inventory
Consistency (C): systems.
The lgorithm ims to chieve consistency by ggreg ting the v il bility st tuses from multiple
Av il bility is m int ined by llowing the system to respond to customer queries b sed on the
inventory systems nd determining single, consistent v il bility st tus for the product.
ggreg ted v il bility st tus, even if some inventory systems re tempor rily un v il ble or
Consistency is prioritized by ensuring th t ll inventory systems re ch greement on the in l
experiencing issues.
v il bility st tus before responding to the customer.
However, chieving strong consistency m y introduce del ys in the system's response time, s the However, ensuring high v il bility m y le d to eventu l consistency, where customers m y
lgorithm m y need to w it for responses from ll inventory systems. tempor rily see outd ted v il bility inform tion until the lgorithm upd tes the ggreg ted
st tus.
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
ff
a
P rtition Toler nce (P):

The lgorithm must be p rtition-toler nt to h ndle scen rios where communic tion Ex mple: determining product v il bility in n e-commerce pl tform…contd
between the e-commerce pl tform nd inventory systems is disrupted due to network
p rtitions or f ilures. - di erent scen rios m y rise where the system needs to compromise between consistency, v il bility,
nd p rtition toler nce.
P rtition toler nce is chieved by llowing the system to continue oper ting nd re ching
consensus on product v il bility even if some inventory systems re unre ch ble or Scen rio 1: Network P rtition
experience del ys in responding to requests.
Scen rio 2: High Tr ic Lo d
The lgorithm should be resilient to network p rtitions nd ensure th t the system rem ins
oper tion l despite tempor ry communic tion f ilures.

Scen rio 1: Network P rtition


Let us ssume there is network p rtition between the e-commerce pl tform nd
some of the inventory systems, le ding to communic tion f ilures. Scen rio 2: High Tr ic Lo d:
To m int in v il bility nd continue serving customer requests, the e-commerce During pe k tr ic periods, the e-commerce pl tform experiences high dem nd, le ding to
pl tform m y decide to respond to queries b sed on the v il bility st tus received incre sed response times from inventory systems due to resource contention or overlo d.
from re ch ble inventory systems only. To m int in v il bility nd respond to customer requests within n ccept ble time fr me, the
However, this compromise on p rtition toler nce m y le d to inconsistencies in the system m y prioritize responding with c ched or st le v il bility inform tion, r ther th n
v il bility inform tion presented to customers, s the ggreg ted st tus m y not w iting for responses from ll inventory systems.
include d t from ll inventory systems. However, this compromise on consistency m y result in customers seeing outd ted v il bility
In this scen rio, v il bility is prioritized over consistency, with the system inform tion, le ding to potenti l confusion or diss tisf ction.
potenti lly providing eventu lly consistent but v il ble responses. In this scen rio, v il bility is prioritized over consistency, with the system providing v il ble but
potenti lly inconsistent responses under he vy lo d conditions.
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
ff
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Scen rio 3: Inventory System Out ge:

Suppose one of the inventory systems experiences n out ge or becomes tempor rily Wh t these scen rios illustr te?
un v il ble due to m inten nce or h rdw re f ilure.
To m int in v il bility nd continue serving customer requests, the e-commerce - how the system m y need to compromise between consistency, v il bility, nd p rtition
pl tform m y decide to respond to queries b sed on the v il bility st tus from other toler nce in di erent situ tions.
re ch ble inventory systems.
However, this compromise on p rtition toler nce m y result in inconsistencies if the - By underst nding the tr de-o s involved, the e-commerce pl tform c n m ke informed
un v il ble inventory system h s di erent v il bility inform tion comp red to the decisions to b l nce these spects b sed on the speci ic requirements nd priorities of the
others. business nd its customers.
In this scen rio, v il bility is prioritized over p rtition toler nce, potenti lly le ding to
tempor ry inconsistencies in v il bility inform tion.

Limit tions of Rel tion l D t b se Model for Working in Clusters:


- rel tion l d t b ses re not designed to be run on clusters
Scen rio 4: D t Replic tion Del ys: - Clustered rel tion l d t b ses, such s the Or cle RAC or Microsoft SQL Server, work on the
concept of sh red disk subsystem
In distributed e-commerce pl tform with replic ted inventory d t cross multiple regions, - They use cluster- w re ile system th t writes to highly v il ble disk subsystem—but
upd tes to inventory v il bility m y be synchronously replic ted between regions with some this me ns the cluster still h s the disk subsystem s single point of f ilure.
del y. - Rel tion l d t b ses could lso be run s sep r te servers for di erent sets of d t , e ectively
To ensure consistency, the system m y choose to w it for the l test v il bility inform tion to sh rding the d t b se.
be replic ted to ll regions before responding to customer queries. - While this sep r tes the lo d, ll the sh rding h s to be controlled by the pplic tion which
However, this compromise on v il bility m y result in incre sed response times or timeouts h s to keep tr ck of which d t b se server to t lk to for e ch bit of d t
for customer requests, especi lly for users in regions where the l test d t h s not yet been
- Also, we lose ny querying, referenti l integrity, tr ns ctions, or consistency controls th t cross
replic ted.
sh rds.
In this scen rio, consistency is prioritized over v il bility, potenti lly le ding to degr ded user
- A phr se we often he r in this context from people who’ve done this is “unn tur l cts.”
experience for customers in regions with replic tion del ys.
- licensing costs
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
f
a
a
a
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
ff
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
How mism tch between rel tion l d t b ses nd clusters h ndled?
- to consider n ltern tive route to d t stor ge.
- Two comp nies in p rticul r—Google nd Am zon—h ve been very in luenti l.
- Both were on the forefront of running l rge clusters of this kind
- furthermore, they were c pturing huge mounts of d t
- Both oper te t sc les f r removed from most org niz tions, so the solutions they
needed m y not be relev nt to n ver ge org niz tion
- Other comp nies beg n to explore m king d t b ses long simil r lines—explicitly
designed to live in world of clusters.
- Bec use cluster thre t w s re l problem
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

You might also like