Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use ZooKeeper for discovery at converge time

Use ZooKeeper for discovery at converge time

DevOpsDays Austin

Matthew Hooker

April 30, 2013
Tweet

More Decks by Matthew Hooker

Other Decks in Programming

Transcript

  1. ZooKeeper “ZooKeeper is a centralized service for maintaining configuration information,

    naming, providing distributed synchronization, and providing group services.” [1] Tuesday, April 30, 13
  2. Chef “The Chef Server acts as a hub for configuration

    data. The Chef Server stores cookbooks, the policies that are applied to cookbooks, and metadata that describes each registered node in the infrastructure.”[2] Tuesday, April 30, 13
  3. Why ZooKeeper? ZooKeeper is highly available* ZK is distributed ZK

    uses familiar semantics (k-v) or (znode-data) Solves discovery elegantly. If you use SOA, you have discovery problems *unless there is a network partition Tuesday, April 30, 13
  4. Writing to ZK Each znode is versioned ZooKeeper supports MVCC

    Multiversion concurrency control a way of enforcing consistency ensures multiple writers don’t clobber each other Tuesday, April 30, 13
  5. Writes to ZK are committed to a majority (aka quorum)

    of nodes before success is communicated some nodes may have old data Reads happen from any node Writes are forwarded through master As ensemble size grows, read performance increases while write performance decreases. ZooKeeper can only work if a majority of servers are correct (i.e., with 2f + 1 server we can tolerate f failures). [3] Tuesday, April 30, 13
  6. vs. chef 10 data store is backed by solr impedance

    mismatch Not HA recipes that depend on search cannot (easily) be run by chef-solo see edelight[4] Tuesday, April 30, 13
  7. Replacing Chef Server Hidden agenda chef server <=10 can fail

    at any time. Depending on chef-server at converge-time is a SPOF Tuesday, April 30, 13
  8. Back to reality We can’t replace chef server in one

    fell swoop One step at a time replace search with ZooKeeper Tuesday, April 30, 13
  9. cluster service discovery[5] def  all_providers_for_service  service    search(:node,  "provides_service:#{service}").  

         find_all{|server|  server[:provides_service][service]  &&  server[:provides_service][service        sort_by{|server|  server[:provides_service][service]['timestamp']  }  rescue  [] end def  provide_service  service,  info={}    node.set[:provides_service][service]  =  info    node.save end Tuesday, April 30, 13
  10. Sequence Nodes When creating a sequence znode, ZK appends a

    monotonically increasing counter to the end of path. e.g. 2 calls to create sequence znodes at /lock- will result in /lock-0 /lock-1 sequences are unique to the parent Tuesday, April 30, 13
  11. Ephemeral Nodes Only exist as long as the creator maintains

    a connection to ZK Disappear after a timeout Querying them will effectively tell you what other clients are alive. Tuesday, April 30, 13
  12. ZooKeeper discovery at run-time hard-coding your cluster membership can be

    problematic solution is to have services register themselves with zookeeper when they come up membership always correct Tuesday, April 30, 13
  13. ZooKeeper Cookbook[6] Uses Netflix’s Exhibitor[7] to provide ops support. http

    endpoint for ensemble discovery only one name needed to discover every service abstracts services from their location Tuesday, April 30, 13
  14. ZK Cookbook One method to get zk connection string Helpers

    for interacting with ZK. Useful for priming chroots Tuesday, April 30, 13