cap theorem and distributed systems

25
CAP theorem and distributed systems introduction Nikanovich Yury

Upload: klika-tech-llc

Post on 12-Apr-2017

62 views

Category:

Internet


3 download

TRANSCRIPT

Page 1: CAP theorem and distributed systems

CAP theoremand distributed systems

introduction

Nikanovich Yury

Page 2: CAP theorem and distributed systems

Distributed Systems

Distributed system is a software system in which components located on networked computers communicate and coordinate their actions by passing messages.

Page 3: CAP theorem and distributed systems

Scalability

Scalability is the ability of a system, network, or process, to handle a growing amount of work in a capable manner or its ability to be enlarged to accommodate that growth.

Two particularly relevant aspects  • Performance• Availability

Page 4: CAP theorem and distributed systems

Permformance aspects

• Short response time/low latency for a given piece of work

• High throughput (rate of processing work)• Low utilization of computing resource(s)

Page 5: CAP theorem and distributed systems

Availability

Availability = uptime / (uptime + downtime)

Availability %Downtime per 

year

90 % ("one nine")More than one 

month

99.9 % ("three nines")Less than 9 

hours99.9999% ("six nines") 31 seconds

Page 6: CAP theorem and distributed systems

Fault tolerance

Fault tolerance ­ability of a system to behave in a well­defined manner once faults occur.

Failures are norm.

Page 7: CAP theorem and distributed systems

Replication

Replication is making copies of the same data on multiple machines.

Page 8: CAP theorem and distributed systems

Replication

Pool of Worker Threads

Master-Slave Replication

Node B

Node C

Node A

Node B

Node C

Node D

Multi-Master Replication

Load Balancer

Master

Slave A Slave B Slave C

Write Operation

Read Operation

Replication

Node D

Node BNode A Node C

Page 9: CAP theorem and distributed systems

Replication

Page 10: CAP theorem and distributed systems

Consistency

More Consistency Faster reads/writes

Strong

Probabilistic

CRDTs

Red­Blue

Per­key sequentional

Casual

Eventual

Page 11: CAP theorem and distributed systems

Why strong consistency is hard to achieve

Nodes• each node executes a program concurrently• knowledge is local• global state is potentially out of date• nodes can fail and recover from failure independently• messages can be delayed or lost • clocks are not synchronized across nodes

Links• Asynchronous system model. • No timing assumptions. • No bound on message transmission delay• Useful clocks do not exist.

Page 12: CAP theorem and distributed systems

Distributed Databases

Page 13: CAP theorem and distributed systems

ACID

• Atomic• Consistent• Isolated• Durable

Page 14: CAP theorem and distributed systems

BASE

• Basic Availability• Soft­state• Eventual consistency

Page 15: CAP theorem and distributed systems

CAP theoremIt is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:• Consistency (all nodes see the same data at the same time)• Availability (every request received by a non­failing 

[database] node in the system must result in a [non­error] response)

• Partition tolerance (the system continues to operate despite arbitrary partitioning due to network failures)

Page 16: CAP theorem and distributed systems

CAP theorem

Consistency

AvailabilityPartition tolerance

Pick 2

Page 17: CAP theorem and distributed systems

CAP theorem and Internet

ConsistencyAvailability

Partition tolerance

Page 18: CAP theorem and distributed systems

CP systems

Available Available

Page 19: CAP theorem and distributed systems

CP systems (Partition)

Partition

UnavailableAvailable

Page 20: CAP theorem and distributed systems

CP systems

Protocols:• Strict quorum protocols (paxos, raft, zab)• 2PC Storages:• MongoDB• HBase• Zookeeper

Page 21: CAP theorem and distributed systems

AP systems

Available(consistent

reads/writes)

Available(consistent

reads/writes)

Page 22: CAP theorem and distributed systems

AP systems (Partition)

Partition

Available(inconsistent reads/writes)

Available(inconsistent reads/writes)

Page 23: CAP theorem and distributed systems

AP systems

Protocols:• Partial quorum protocols

Storages:• Couch DB• Cassandra• Amazon Dynamo

Page 24: CAP theorem and distributed systems

CAP fifteen years later●Partitions are rare, there is little reason to forfeit C or A when the system is not partitioned.●Choice between C and A can occur many times within the same system at very fine granularity.●All three properties are more continuous than binary.●Most software doesn’t neatly fit CP/AP definition.

Page 25: CAP theorem and distributed systems

Thank You!

Questions?