Monday, August 21, 2017

We continue discussing the ZooKeeper. It is a co-ordination service with elements from group messaging, shared registers and distributed lock services. It provides a interface that guarantees wait-free property and FIFO execution of requests from each client.  Requests across all clients are also linearized.
We were discussing the components of ZooKeeper - the request processor, the atomic broadcast and the replicated database. The request processor is one which prepares the request for processing that also includes co-ordination activities among servers for write requests. If the request processing involves co-ordination, it is handled by an agreement protocol which is an implementation of atomic broadcast. The changes are committed in ZooKeeper database that is replicated across all servers.  This database is periodically snapshot because replaying all the messages in order would take too long to recover state. During the snapshot, the ZooKeeper state is not locked so the snapshots don't really reflect the state of the ZooKeeper at any point of time. However since the transactions are idempotent, snapshots allow the state to be restored because the changes can be applied more than once and they are in the same order as in replay.
We will now see how ZooKeeper provides durability.  On every read request, a zxid is returned that relates to the last transaction seen by the server. Since the writes are all transactional, this zxid indicates a partial order of the read requests. All responses including the heartbeats during periods of idle activity include the last zxid seen by the server that the client is connected to. If a client connects to a different server, that server ensures that its view of the ZooKeeper data is at least as current as that of the client by comparing its zxid with that of the client. If the client is more recent, the server does not reestablish a session until it has caught up. Since a majority of the ZooKeepers would be current before the client received the zxid, the client is guaranteed to find another server that has a recent view of the system. This gurantees durability. ZooKeeper also maintains a session timeout to detect client  session failures. Generally clients re-establish a session. The client library for ZooKeeper actually sends client heartbeats and switches servers if the servers are not responsive enough.
Software for  Email Campaign: https://1drv.ms/w/s!Ashlm-Nw-wnWsEXQ3UmFVYv0GpFe  
#codingexercise
Another method for finding the number of duplicates in a sorted contiguous sequence is similar to the earlier  binary search based method of traversing linearly from the current element but searching for the previous and next elements instead.

No comments:

Post a Comment