Burak Tokgöz

  • Written in Go
  • Service discovery
  • Health Checking
  • Key / Value store
  • Multi Datacenter support
  • Agent/ Server concept
  • Gossip protocol for all the nodes (discovery)
  • Consensus protocol( Raft-based) for servers
  • 3 consistency modes
  • Access Control List(ACL)
  • Consul provides service discovery
  • Consul provides a consistent view of services
  • Consul provides a consistent view of configuration
  • Consul uses a mircoservice interface to a replicated view of your topoplogy and its configuration
  • Consul can monitor and change services topology based on health

Consul

  • Scalable distributed health checks
  • Minimal dc to dc communication
  • Event system
  • Domain model for managing topology of dcs, server nodes and services running on server nodes along with their configuration

Features

DNS server plus Consistent Key/Value Store + ZooKeeper + Nagios + ... = Consul

All the bits you need in a coherent model available to provide service discovery and replicated config

Consul Like

  • Server also agent with more tasks
  • RAFT quorum, who is leader/master
  • Maintain cluster state
  • Handles WAN gossip to other datacenters
  • Forwards queries to leader/master
  • Forward queries to other datacenters

Server

Gossip

  • Consul is built on top of Serf
  • Serf is a ful gossip protocol
  • Serf provides membership, failure detection and broadcast mechanisms
  • Clustering of server nodes

LAN, WAN and RPC

  • Consul is built on top of Serf- node discovery and orchestration tool(gossip model). It's used for group membership, failure detection and event broadcast;
  • LAN gossip pool for membership and failure detection (distributed checks, good for large clusters)
  • All agent nodes (client and server) on same local network or datacenter

LAN, WAN and RPC

  • WAN gossip pool for inter-datacenter consul servers communication
  • Only agent servers
  • Servers per datacenter( 3 to 5 for redundancy or wide are network)
  • RPC- Remote Procedure Call
  • Request/ Response mechanism allowing a client to make a request of a server

Agent Responsibilities

Maintains:

                  Set of service

                 Check registrations

                 Health information

Updates:

       Health checks

Local state

Catalog

Text

Agent vs. Catalog

Local agent state( agent client node) is different than catalog state(agent server node)

Local Agent notifies Catalog of changes. Updates are synced right away.

Agents check to make sure its view of world matches the catalog and if not the catalog is updated

Example: Registers a new service check with agent,

Agent notifies catalog that this service check exists

When a check is removed from the agent, it is removed from the catalog

Agents vs. Catalog 2

If Agents run health checks and status changes then update is sent to catalog

Agent is the authority of that node and the services that exist on that node

Scope

Agent = Server or Virtual Machine

Catalog = single datacenter, local area network, EC2 availability zone

Changes are also synchronized periodically every minute to ten minutes

Clients

Agent

Agent

Agent

Servers

Agent

Agent

Agent

RPC

Gossip

Leader

Rails and Data Services

Web Server

Discovery

Rails and Data Services

Web Server

Discovery

Dynamically renders templates

Integrate with everything

Reload changes

Real-time

Consul templates to update files and possibly restart applications (haproxy with backend servers)

global
    daemon
    maxconn {{key "service/haproxy/maxconn"}}

defaults
    mode {{key "service/haproxy/mode"}}{{range ls "service/haproxy/timeouts"}}
    timeout {{.Key}} {{.Value}}{{end}}

listen http-in
    bind *:8000{{range service "release.web"}}
    server {{.Node}} {{.Address}}:{{.Port}}{{end}}

Consul Template Example:

Render template based on Consul state

Setup reverse proxy: Nginx, Apache, haproxy 

My Network

Node1

HAProxy

Agent

Frontend

Backend

Consul Server

Consul

By Burak Tokgöz

Consul

consul brief explanation and usage

  • 668