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

About Consul ~In Depth~

About Consul ~In Depth~

#hbstudy 60 slides #consul

Michael H. Oshita

July 20, 2014
Tweet

More Decks by Michael H. Oshita

Other Decks in Technology

Transcript

  1. ABOUT ME (@IJIN) • Michael H. Oshita • Japanese American

    • 10+ Years in Japan • Software/Infra/Cloud Engineer • http://ijin.github.io
  2. TECHNOLOGY • Consensus Protocol (Raft, FSM) In Search of an

    Understandable Consensus Algorithm - Stanford University • Gossip Protocol (Serf) SWIM: Scalable Weakly-consistent Infection-style Process Group Membership - Cornel University • Sessions (Chuby) The Chubby Lock Service for Loosely-Coupled Distributed Systems - Google • TLS, Jespen Testing !
  3. rpc forwarding & gossip protocol server server (leader) server ARCHITECTURE

    client client client query forward query query forward
  4. consensus protocol using raft server server (leader) server write CONSISTENCY

    server server write write quorum[(n/2)+1] reached, commited!
  5. CONSISTENCY writes: ! "?state" or "?consistent" parameter ɾdefault ɾstrongly consistent

    ɾstale ! consensus protocol using raft reads: ! Always Strongly Consistent
  6. CONSISTENCY default "?state" or "?consistent" parameter ɾMostly Strongly Consistent ɾStale

    reads possible when leader promotion ɾFast ! server server (old leader) server (new leader) A' A leader lease leader lease
  7. CONSISTENCY consistent "?state" or "?consistent" parameter ɾStrongly Consistent ɾLeader validates

    via Qurum ɾLatency affected by Round-trip ! server server (leader) server A A A leader lease
  8. CONSISTENCY stale "?state" or "?consistent" parameter ɾStale Reads, within ~50ms

    ɾNon-Leader Servers can answer ɾVery Fast ! server server (leader) server A A' A''
  9. CONSUL AGENT DNS CACHING Stale Reads ɾࢀর͸σϑΥϧτͰLeader NodeͷΈ ɾ༗ޮԽ͢ΔͱଞͷServer Node͔ΒࢀরՄೳ

    ɾεϧʔϓοτ޲্ ɾmax_staleͰ࣌ؒΛઃఆ ! TTL ɾDNS TTL͸σϑΥϧτͰ0 ɾdnsmasq౳ͰΩϟογϡՄೳʹ { "dns_config": { "service_ttl": { "*": "5s", "web": "30s" } } new! (0.3.0)
  10. CONSUL AGENT HTTP API several endpoint categories: • kv -

    Key/Value store • agent - Agent control • catalog - Manages nodes and services • health - Manages health checks • session - Session manipulation • status - Consul system status • internal - Internal APIs. Purposely
  11. CONSUL AGENT HTTP API /v1/agent/checks /v1/agent/services /v1/agent/members /v1/agent/self /v1/agent/join/<address> /v1/agent/force-leave/<node>

    /v1/agent/service/deregister/<serviceID> agent endpoint: /v1/agent/register /v1/agent/deregister/<checkID> /v1/agent/pass/<checkID> /v1/agent/warn/<checkID> /v1/agent/fail/<checkID> /v1/agent/service/register
  12. CONSUL AGENT HTTP API /v1/catalog/register /v1/catalog/deregister /v1/catalog/datacenters /v1/catalog/nodes catalog endpoint:

    /v1/catalog/services /v1/catalog/service/<service> /v1/catalog/node/<node> * supports blocking queries & consistency modes
  13. CONSUL AGENT HEALTH CHECK { "service": { "check": { "script":

    "curl localhost > /dev/null 2>&1", "interval": "10s" } } check definition:
  14. CONSUL AGENT HEALTH CHECK Exit Code 0 - Check is

    passing ! Exit Code 1 - Check is warning ! Any Other - Check is failing check script:
  15. BENCHMARK GET 8 CPU Cores, 2Ghz 16GB RAM 160GB SSD

    disk 1Gbps NIC Requests/sec rps 0 2750 5500 8250 11000 10,469.54 2,115.61 v0.2.0 v0.3.0
  16. BENCHMARK GET response time distribution # of responses 0.00 3000.00

    6000.00 9000.00 12000.00 response time (s) 0.001 0.004 0.010 0.014 .018 0.023 0.035 0.051 0.067 0.083 v0.2.0 v0.3.0 8 CPU Cores, 2Ghz 16GB RAM 160GB SSD disk 1Gbps NIC
  17. BENCHMARK GET 8 CPU Cores, 2Ghz 16GB RAM 160GB SSD

    disk 1Gbps NIC Requests/sec default consistent stale 0 2750 5500 8250 11000 10,948.2 10,245.562 10,469.54 1,986.771 1,953.555 2,115.61 v0.2.0 v0.3.0
  18. BENCHMARK PUT 8 CPU Cores, 2Ghz 16GB RAM 160GB SSD

    disk 1Gbps NIC Requests/sec rps 0 1250 2500 3750 5000 4,091.67 1,054.031 v0.2.0 v0.3.0
  19. BENCHMARK PUT response time distribution # of responses 0.00 2250.00

    4500.00 6750.00 9000.00 response time (s) 0.006 0.013 0.017 0.024 0.031 0.038 0.047 0.078 0.109 0.140 0.172 v0.2.0 v0.3.0 8 CPU Cores, 2Ghz 16GB RAM 160GB SSD disk 1Gbps NIC