1/82
Looks like no tags are added yet.
DSPS =
Distributed Stream Processing Systems
DSPS is
Groups of operator blocks deployed in distributed processing nodes.
DSPS is represented as
A directional acyclic graph with parentheses around operator block groupings.
Eight Requirements of Stream Processing
Keep the data moving
Query using SQL on Streams
Handle Stream imperfections
Generate predicatble outcomes
Integrate stored and streaming data
Guarantee data safety and availability
Partition and scale applications automatically
Process and respond instantaneously
The Publish-Subscribe (Pub-Sub) model provides
decoupling among producers and consumers.
In the pub-sub model
Producers are called publishers and consumers are called subscribers (along three dimensions)
The Pup-Sub Model saves on
Time
As nodes to not have to be up and running at the same time
They can come and go anytime similar to P2P
Space
They do not need to be aware of each other
Synchronization
Nobody blocks for the other
Advantages of Pub/Sub
Three dimensions of decoupling enable
Increased scalability
Improved resilience
Reduction in Coordination
Basic Terminology of Pub/Sub
Event
Is the information generated yb the publisher that must be delivered to the subscriber
Notification
The act of alerting the subscriber of an event of interest to that subscriber
Event Service
Manages the storage of events and deliver of events form publisher to subscribers
Serves as a proxy for both the publisher and subscriber
The modes of Pub/Sub
The mode is based on what is pushing or pulling (taking responsibility of) an event from the event service.
There is:
Publisher-side push
Pushes to event service
Publisher-side pull
Event service pulls form publsiher
Subscriber-side push
Event service pushes to subscriber
Subscriber-side pull
Subscriber pulls from event service
REMEMBER THIS ^^
Types of Pub/Sub Models
Topic-based
Based on events that are named or have an ID
Content-based
Based on the contents of the event
Type-based
Similar to topic-based but provides a programming language level type instead of some name
Data-Centric
A variant that is a hybrid of the above three
Topic Based Pub/Sub
Every event has a unique name such as a URL
Simple interfaces
Hierarchal addressing is supported.
Formed via containment
Each maps to a virtual channel
Each is identified by a key
Strings are usually used as keys (not a requirement)
keys help divide the event space into granularities based on that key.
Content-Based Pub/Sub
Provides finer granularity by subscription based on the actual content
Subscription for content is specified using filters.
Complex filters can be constructed using comparison and logical operators.
More sophisticated implementations may incur more runtime overhead
Type-Based Pub/Sub
Events are recognized as types in the programming language
Improves safety
Compile-time error checking can be done as opposed to at runtime
Any filtering is still the responsibility of the subscriber but we get type safety.
Different types of Lookups
Centralized
Flooding-based
Distributed Hash Table (DHT)
Centralized Lookup
A broker maintains information of a specific service and how to access it
In the networking world the DOmain Name System is used to lookup the host
In CORBA world we have the Naming and Trading Service
A object reference and key is registered with the broker
In web services Universal Description Discovery and Integration is used
Web services registers register with UDDI
SOAP messages are used
Pros of the Centralized Lookup
Simple architecture
O(1) lookup time
Cons of the Centralized Lookup
O(N) storage complexity since information for N services must be maintained at a single place.
Single broker can become a bottleneck for large systems involving frequent lookups
Failure of the broker will render system useless.
Flood-Based Lookup
An alternative to the centralized broker where multiple queries are sent across the network hoping someone responds
Pros to Flooding-based Lookup
Nodes can join and leave the network at any time
No single point of failure yielding a resilient architecture
Storage cost is only O(1) as only the node that offers the service maintains the information
Cons of Flooding Based Lookup
Network links can get congested due to too many search messages.
No proper way to stop unwanted propagation of messages
May often be limited by routers/bridges in how much information is allowed to spread resulting in some lookups having a chance to not succeed
Address Resolution Protocol (ARP) is a well known ___
Flooding-based lookup approach
Distributed Hash Table (DHT) Lookup
Concept of hashing applied in a distributed sense.
Attempts to bring the advantages of both centralized and flooding lookup approaches into one solution while minimizing disadvantages
Achieves O(log(N)) complexity for both storage and traffic/processing
Architecture is inherently resilietn to failures.
A DHT is made up of
A set of nodes.
DHT Nodes
Store roughly O(log(N)) information of services and their data that have registered with that node
Maintains a route to the next hop in the DHT system
As long as a service is registered with a node it is guaranteed to succeed.
DHT API
Put (Key, Value)
Key is the hash value of the data that the service wants to store
Values is the actual value to be stored
Value = Get (Key)
Entity that is doing the lookup uses some name and hashes it ot the key that is used for the lookup.
Value is returned
Issues of importance in DHT
Node arrival
Routing tables must be updated to distribute the load
Node failure
(key, value) pairs associated with the node must somehow be distributed across remaining nodes
Node departure
Similar to failure but the node informs the system ahead of time and proactive steps are taken.
Consistent Hashing has the following properties
Collision free
O(1) time
Each node and key is assigned an m-bit identifer
m is assumed ot be large enough to ensure collision-free
Logic Ring
Following the properties of consistent hashing nodes are set up in a ring.
Identifiers are arranged on this using mod( 2^m)
Key k is assigned to the identifier node equal to or immediately following this key. This is called the successor node.
Key 10 cannot go to Node 8, but it can go to its successor which is Node 14.
When a node leaves its keys are assigned to its successor
When a node joins some keys that were at the successor will get assigned to the new node.
Chord Leverages consistent hashing by adding
A finger table
A finger table is
A table that tracks successor nodes of a given node in a logic ring.
A routing table of max m entried where m = lg(N) >= 0 (lg(N) space complexity)
The ith entry of node n in the table is the first ndoe s who succeeds n by at least 2^(i-1) distance.
The first sucessor
Node s is called the ith finger of Node n
Chord Protocol
it is a scalable lookup idea
As the circle looks bigger the finger entries of a finger table must be spred out to cover as much of the circle as possible so that the iterative search process should not be more than O(lg N) steps.
Even if a node does not know the key such as node 3 not knowing node 50 it can throw it to a node as close as possible to node 50
Key Properties of the Finger Table
REMEMBER THIS
The finger table entries are not the next m consecutive nodes
Tries to jump as far away as possible
Jump distance increases by 2^n
Coordination Issues
Leader Election
Configuration Management
Group Membership
Distributed Resources Locking
Common Coordination Services
Zookeeper
Etcd
Consul
doozerd
Zookeeper Design Rationale
provide a basic kernal upon which applications can build more sophisticated coordination mechanisms
Move away from server oriented models
Move away from blocking so the entire service isnt slowed down just from some components being slower
Support for FIFO request ordering
Participants and Service Model of Zookeeper
Client: uses the service
Server: process that provides the service
Typically implemented as an ensemble of replicated servers for the sake of load balancing and fault tolerance
Session: Duration of time when the client connects to the server and access the services until closing
znode: an in-memory data objected used by the service to store metadata for the clients application
REMBER ZNODES EXISTS AND DO ALOT
Two Types of Znodes
Ephemeral node
Remain alive for the session and can be deleted by client or automatically cleaned on session termination
Regular node
created/deleted explicitly by the user
Coordination Requirements
Wait free data objects
Improves performance
If a collection of processes ere to coordinate among themselves and used blocking, the performance will be dictated by the slowest processes
Pipelined Architecture and FIFO Ordering
Enables clients to submit operations asynchronously instead of a request-response blocking model
Linearizeable Writes
A legitamate/legal sequential computation
A system is linearizeable if each individual object is linearizeable
Allows multiple requests form the same client to be outstanding however FIFO is still ensured
The Watch Mechanism
ZooKeeper uses event notification to inform the clients when a condition becomes true rather than the clinet polling
Watches are installed on a znode that the clinet creates for its needs.
After a watch has given a notification the client must set the watch again
Function Definition
Indicates what a system is supposed to do
Behavior Definition
The actions of the system that implement the function
Structure Definition
What generates the behavior of the system
Key Concepts for Discussing Fault Tolerance
Service: the behavior of a system observed by its users
Correct Service: the conformance to its functional specification
Service Failure: The event that causes the service to deviate from its correct behavior
Service Outage: the time period when incorrect service is delivered
Service Restoration: transition from incorrect to correct service
Failure Modes: different forms that influence the service to deviate from its correct behavior.
Failure: The event that causes the service to deviate from its correct behavior
Error: the deviation from correct behavior
Fault: cause of an error
Dependability is the ability to deliver a service that can be trusted and is comprised of:
Availability: tells if the service is ready for use in a correct manner
Reliability: tells whether the service is continuing to work correctly
Safety: indicates absences of any catastrophic consequences on the user and environment
Integrity: Indicates absence of any improper alterations to the system behavior
Maintainability: ability to make modifications and repairs both at development time and during use
Replication
Achieving fault tolerance through redundancy by having multiple running replicas of the same server.
Passive Replication
One replica chosen as a primary that executes client requests
Backup replicas do not execute requests, thereby conserving resources, but only synchronize state of the primary.
Replica manager manages replica groups
Faults monitored by detector and informed to replica manager
Backup promotion done by replica manager on primary failure
REMEMBER THIS
Cold Passive Replication
State is transferred only when a backup is promoted to primary
REMEMBER THIS
Warm Passive Replication
State is transferred periodically into designated backups
REMEMBER THIS
Active Replication
Client request gets multicast to each replica
Each replica executes the request
Multiple responses are not sent to the client, instead logic is used to suppress duplicates
Often majority voting is implemented on replies coming from replicas
Semi-Active Replication
Several replicas chained together but only one is primary
Client sends request to primary
State is reliably multicast to all secondaries periodically
Response sent to client
First secondary in chain becomes new primary when current primary fails
Replica manager may be used to preserve degree of replication
External storage may be used
Framework Elements needed for Fault Tolerance
Replication Management
Group Communications
State Checkpointing
Insertion into Application
Fault Detection
Capabilities for Supporting Fault Tolerance
A way to create and manage copies of functionality
A way to talk to a set of replicas
A way to checkpoint and restore state
A way to trigger checkpointing and/or state exchange when needed
A way to insert FT capabilities into an application and/or system
A way to detect faults and trigger recovery
The letters in CAP stand for
Consistency
Availability
(network) Partition tolerance
The original CAP theorem stated that
Any netwokred shared data system could only have two of the three desired properties.
This is outdated as the theorem was more meant to illustrate the flexibility of a shared data system that can make tradeoffs along the three dimensions. So given the presence of one of the properties, maximize a combination of the other two properties.
The letters in ACID stand for
Atomicity
No partial operations
Consistency
One valid state to another
Isolation
Durability
Once a transaction has been committed its effect will persist.
ACID properties are crucial for
Database Transactions
ACID focuses on
Consistency
Letters in BASE stand for
Basicaly
Available
Soft State
Eventually Consistent
BASE is designed with
Availability in Mind
Soft State and Eventual Consistency are useful when
Systems get partitioned.
Why is Latency important?
It can be used to determine if a system is partitioned or not.
If a system cannot maintain full consistency wihtin a bounded set of time, then it is declared as partitioned keeping the system available and subsequently handle recovery.
How is the system brought into a consistent state after recovery?
REMEMBER THIS
We look at clocks and the logical clocks. If there is a counter and when something happens that counter is incremented and a timestamp is attached to the increment. When the system catches backup, it checks any new counts and their timestamps and puts the event in the correct order according to the time stamp.
Paxos is a
Consensus algorithm designed to recover from faults. (REMEMBER THIS)
Paxos works in cases where
Processes/processors may stop and restart at some point
Messages may get delayed, lost, or duplicated
Corruption of messages
The three requirements of consensus for Paxos
Termination (process must end at some point in time)
Agreement (must agree on the value)
Validity (the agreed upon value must have been actually proposed by one of the members of the group)
Roles in Paxos
Proposers (agents who propose values)
Acceptors (agents who accept specifc values)
Learners (Agents who finally learn the consensus value)
Paxos Algorithm
Proposer selects a proposal number n and sends a prepare request to a majority of acceptors
If an acceptor recieves a request with n greater than any other request n then it agrees not accept any other request with values less than n
If a proposer receives a response to its prepare request from a majority of acceptors, then it sends an accept request to each of those acceptors.
If an acceptor receives an accept request for a proposal numbered n it accepts it unless it has already responded to a prepare request having a number greater than n
All acceptors after accepting the value will send the accepted value and proposal number to a distinguished learner who will then share it to other learners.
REMEMBER THIS
The Byzantine General Problem (BGP) at a high level.
Traitors exist in the “army”
Despite traitors loyal generals must reach agreement
All loyal generals decide on the same plan of action via consensus
A sall number of traitors cannot cause the loyal generals to adopt a bad plan
Detailed BGP
Let there be n generals
The generals communicate with each other
Each ithe geneeral sends a value to the remaining generals
On receiving all values, each general combines these values into a plan
The function is agreed upon by all generals and the function itself is not manipulated.
BGP is designed for
Fault tolerance not full stop handling.
BGP and Paxos are similar in that they both
Are distributed
About reaching consensus
Execute in phases
Both require final decision to be obeyed
No corruption on the link or a man-in-the-middle
BGP and Paxos are different in that
Messages cannot be corrupted in Paxos
Messages can be lost in Paxos with no need to detect them
Messages can be delayed and ignored in Paxos. BGP needs messages from all generals.
Messages for BGP are sent in
Plain Text
In a practical implementation, of BGP
The messages are encrypted.
Logical Clocks
Assume every process clock ticks through every number
A process can start at any number it wants
A tick is assumed to occur between any two events
The value assigned to an event is the most recent preceding tick value on that process.
Implementation Rules for logical clocks
Each process increments it clock between two consecutive events
Each outgoing message contains a timestamp.
If a process receives a message with a timestamp it sets its local clock to greater than or equal to its present value and certainly greater than the timestamp of the message
Ensures the receiving process’s clock is logically synched up with the sending process.
While logical clock measure time as discrete units (ticks) they ocassionaly need to compare
Continuous times
Reference clock
A physical clock of an external observer with a frequency where all timing measurements are made in relation to the reference clock. Usually the frequency is 10^15 microticks/sec
Used to measure the granularity of another clock
Microtick
The periodic event generated by the oscillator
Digital clock
An oscillator that generates an event periodically which in turn increments a counter
Macrotick
Some subset of microticks from a collection of clocks (e.g. 10 microticks)
Precision
How much clocks drift from each other
Clocks must be internally synched to provide a certain level of procision