SlideShare a Scribd company logo
1 of 72
Download to read offline
PostgreSQL High-Availability and
Geographic Locality using consul
Sean Chittenden
Engineering, HashiCorp
@SeanChittenden
sean@hashicorp.com
https://keybase.io/seanc
Quick Demo
Consul Consul
dc2dc1
PostgreSQL
Follower
PostgreSQL
Leader
PostgreSQL
Follower
CONSUL
HASHICORP
HASHICORP
Key Value Store
HTTP API
Host & Service
Level Health
Checks
Datacenter Aware
Consul solves four central challenges with SOA
Service
Discovery
HTTP + DNS
HASHICORP
Consul Installation
HASHICORP
Overview
1. Introduction to Consul
2. Review of Consul
a. Architecture
b. Agent Functionality
c. Agent Configuration
d. Features
3. Further Reading
HASHICORP
Introduction
HASHICORP
Consul powers runtime orchestration
CONSUL
HASHICORP
1. Service discovery
2. Service registry
3. Key/value store
4. Health checks
HASHICORP
Glossary
Agent - Long-running daemon on every member of the Consul
cluster. The agent is able to run in either client or server mode.
Client - Agent that forwards all RPCs to a server and
participates in the LAN gossip pool.
Server - Agent that maintains cluster state, responds to RPC
queries, exchanges WAN gossip with other datacenters, and
forwards queries to leaders of remote datacenters.
Consensus - Agreement upon the elected leader
HASHICORP
Glossary
Gossip - Random node-to-node communication primarily over
UDP that provides membership, failure detection, and event
broadcast information to the cluster. Built on Serf. Consul has
both LAN and WAN Gossip.
Datacenter - Networking environment that is private, low latency,
and high bandwidth. A Consul cluster is run per datacenter, so its
important to have low latency for the gossip protocol.
HASHICORP
Consul vs. Other Software
- Opinionated framework for service discovery using DNS
or HTTP
- Scalable gossip system that links server nodes and clients
- Distributed health checking with edge triggered updates
- Globally aware with multi-datacenter support
- Operationally simple
- Incorporation into the HashiCorp ecosystem
HASHICORP
Architecture
HASHICORP
Single Datacenter
CLIENT CLIENT CLIENT CLIENT CLIENT CLIENT
SERVER SERVER SERVER
REPLICATION REPLICATION
RPC
RPC
LAN GOSSIP
HASHICORP
Multi-Datacenter
CLIENT CLIENT CLIENT CLIENT CLIENT CLIENT
SERVER SERVER SERVER
REPLICATION REPLICATION
RPC
RPC
LAN GOSSIP
SERVERSERVER SERVER
REPLICATION REPLICATION
WAN
GOSSIP
HASHICORP
Raft Introduction
~/src/raft/thesecretlivesofdata/raft
open index.html
~/src/raft/raftscope
open index.html
HASHICORP
TCP and UDP Ports
Client HTTP RPC
TCP/8500
DNS
TCP/8600
UDP/8600 LAN Gossip
TCP/8301
UDP/8301
LAN Gossip
TCP/8301
UDP/8301
RPC
TCP/8400
RPC
TCP/8400
WAN Gossip
TCP/8301
UDP/8301
Clients consul1.dc1
Client RPC
(HTTP)
DNS
TCP/8600
UDP/8600
Server RPC
TCP/8300
consulN.dc2 consul2.dc1
HASHICORP
Agent functionality (client or server)
- RPC, HTTP, DNS APIs
- Health Checks
- Event Execution
- Gossip Participation
- Membership
- Failure detection
HASHICORP
Agent functionality (server)
- State replication
- Query Handling
- Leader election
- WAN Gossip
HASHICORP
Failover via DNS
HASHICORP
DNS Failover
• Works across L3 boundaries
in LAN environments
• Works across L3 boundaries
in WAN environments
• Small TTLs
• Workload Distribution
• Clients cache DNS data
• Not subject to spanning-tree
• Requires TCP connections
be reset on failover
• Clients can cache stale DNS
data
Pro Con
HASHICORP
Consul Installation
HASHICORP
consul Server 1/3
% cat config.json
{
"acl_datacenter": "lab1",
"acl_default_policy": "deny",
"acl_master_token": "rootToken",
"addresses": {
"dns": "0.0.0.0",
"http": "unix:///tmp/.consul.http.sock",
"https": "0.0.0.0",
"rpc": "unix:///tmp/.consul.rpc.sock"
},
"bootstrap_expect": 3,
"datacenter": "lab1",
"data_dir": "./svc/data",
"disable_remote_exec": true,
HASHICORP
Consul Server 2/3
"dns_config": {
"allow_stale": true,
"max_stale": "10080m",
"node_ttl": "60s",
"service_ttl": {
"*": "5s",
"stable-service": "86400s"
}
},

"encrypt": "[ random mime encoded data ]",
"log_level": "debug",
"ports": {
"https": -1
},
"server": true,
"unix_sockets": {
"mode": "0700"
}
}
HASHICORP
Consul Server 3/3
% cat svc/run
#!/bin/sh --
set -e
exec 2>&1
exec 
/usr/bin/env -i 
./bin/consul agent 
-config-file=./config.json 
-config-dir=./conf.d/
% cat svc/log/run
#!/bin/sh —
set -e
set 2>&1
exec chpst -u _log:_log svlogd ./main
HASHICORP
Consul Cluster
% consul members
Node Address Status Type Build Protocol DC
vm1 172.16.139.140:8301 alive server 0.7.0dev 2 lab1
% consul join 172.16.139.139 172.16.139.138
Successfully joined cluster by contacting 2 nodes.
% consul members
Node Address Status Type Build Protocol DC
vm1 172.16.139.140:8301 alive server 0.7.0dev 2 lab1
vm2 172.16.139.138:8301 alive server 0.7.0dev 2 lab1
vm3 172.16.139.139:8301 alive server 0.7.0dev 2 lab1
HASHICORP
Consul Cluster
% consul info
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 1
build:
prerelease = dev
revision = 'fa26d5f
version = 0.7.0
consul:
bootstrap = false
known_datacenters = 2
leader = false
leader_addr = 172.16.139.139:8300
server = true
[snip]
HASHICORP
Consul Cluster
% consul info
[snip]
raft:
applied_index = 103339
commit_index = 103339
fsm_pending = 0
last_contact = 82.95803ms
last_log_index = 103339
last_log_term = 50663
last_snapshot_index = 98437
last_snapshot_term = 2228
num_peers = 2
raft_peers =
172.16.139.139:8300,172.16.139.138:8300,172.16.139.140:8300
state = Follower
term = 50663
[snip]
HASHICORP
dnsmasq Config
% cat /usr/local/etc/dnsmasq.conf
local-service
port=53
server=/consul/127.0.0.1#8600
rev-server=172.16.0.0/12,127.0.0.1#8600
server=208.67.222.222
server=208.67.220.220
cache-size=65536
% cat /etc/resov.conf
search localdomain
nameserver 127.0.0.1
HASHICORP
Service Discovery
HTTP + DNS
HASHICORP
- Nodes, Services, Checks
- Simple registration (JSON)
- DNS Interface
- HTTP API
Service Discovery
HASHICORP
PostgreSQL Service
% hostname
pg002
% cat config.d/pg-db.json
{
"service": {
"name": "pg-db",
"tags": ["follower"],
"port": 5432,
"checks":
[{
"id": "pg-alive",
"notes": "Make sure connect and queries work",
"script": "/usr/local/bin/check_postgresql",
"interval": "10s"
}]
}
}
Terminal
HASHICORP
$ dig follower.pg-db.service.consul
Terminal
HASHICORP
$ dig follower.pg-db.service.consul
; <<>> DiG 9.8.3-P1 <<>> follower.pg-db.service.consul
; (3 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 946
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0,
ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;follower.pg-db.service.consul. IN A
;; ANSWER SECTION:
follower.pg-db.service.consul. 0 IN A 172.16.139.141
Terminal
HASHICORP
$ dig follower.pg-db.service.consul SRV
; <<>> DiG 9.8.3-P1 <<>> follower.pg-db.service.consul
SRV
; (3 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 480
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0,
ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;follower.pg-db.service.consul. IN SRV
;; ANSWER SECTION:
follower.pg-db.service.consul. 0 IN SRV 1 1 5432
HASHICORP
DNS Interface
- Zero Touch
- Randomized Round-Robin DNS
- Filters on Health Checks
HASHICORP
HTTP API
- HTTP API
- Custom Integrations
HASHICORP
Host & Service Level
Health Checks
HASHICORP
What is a health check?
0PASSING
1WARNING
_
_FAILING
Any command that returns an exit code
HASHICORP
Health Checks & Monitoring
- Nagios-compatible
- Scalable
- Actionable
- Edge Triggered
Text Editor
HASHICORP
% cat conf.d/mem-check.json
{
"check": {
"id": "mem-util",
"name": "Memory utilization",
"script": "/usr/local/bin/mem_check.sh",
"interval": "10s"
}
}
Creating a check
Use a custom script
Text Editor
HASHICORP
% cat conf.d/http-check.json
{
"check": {
"id": "api",
"name": "HTTP API on port 4455",
"http": "http://localhost:4455/_health",
"interval": "10s",
"timeout": "1s"
}
}
Creating a check
Use a built-in check type
HASHICORP
Traditional Health Checking (pull)
HEALTH
CHECKING
SERVICE
DB 1
DB 2
DB N
"Are you healthy?"
HASHICORP
Traditional Health Checking (pull)
HEALTH
CHECKING
SERVICE
DB 1
DB 2
DB N
"Are you healthy?"
"Yessir!"
HASHICORP
Traditional Health Checking (pull)
HEALTH
CHECKING
SERVICE
DB 1
DB 2
DB N
"Are you healthy?"
"What about you?"
"Yessir!"
HASHICORP
Traditional Health Checking (pull)
HEALTH
CHECKING
SERVICE
DB 1
DB 2
DB N
"Are you healthy?"
"What about you?"
"Yessir!"
"Nah"
HASHICORP
Traditional Health Checking (pull)
DB 1
DB 2
DB N
HEALTH
CHECKING
SERVICE
"Are you healthy?"
"What about you?"
"Yessir!"
"Nah"
HASHICORP
Traditional Health Checking (pull)
DB 1
DB 2
DB N
HEALTH
CHECKING
SERVICE
1,000'S OF
REQUESTS
HASHICORP
Consul Health Checking (push)
CONSUL
DB 1
DB 2
DB N
My status has changed
HASHICORP
Consul Health Checking (push)
CONSUL
DB 1
DB 2
DB N
10'S OF
REQUESTS
HASHICORP
Liveness
- No Heartbeats
- Gossip-based Failure Detector built
on Serf
- Constant Load
HASHICORP
HTTP UI
http://172.16.139.138:8500/ui/#/lab1/services
HASHICORP
Key Value Store
HTTP API
Terminal
HASHICORP
$ curl -X PUT -d 'bar' http://localhost:8500/v1/kv/foo
true
Terminal
HASHICORP
$ curl -X PUT -d 'bar' http://localhost:8500/v1/kv/foo
true
$ curl http://localhost:8500/v1/kv/foo
[
{
"CreateIndex": 100,
"ModifyIndex": 200,
"Key": "foo",
"Flags": 0,
"Value": "YmFy"
}
]
% echo -n 'bar' | base64
YmFy
% echo -n 'YmFy' | base64 -d ; echo
bar
Terminal
HASHICORP
% cat <<EOF > acl.anonymous.json
{
"ID": "anonymous",
"Name": "Anonymous Token",
"Type": "client",
"Rules": "# Default all keys to read-only
key "" {
policy = "read"
}
# Default all services to read-only
service "" {
policy = "read"
}
# Allow hearing any user event by default.
event "" {
policy = "read"
}
Terminal
HASHICORP
# Default prepared queries to read-only.
query "" {
policy = "read"
}
# Read-only mode for the encryption keyring by default
(list only)
keyring = "read""
}
EOF
% curl -v -X PUT -d @acl.anonymous.json --unix-socket /
tmp/.consul.http.sock 'http://consul/v1/acl/update?
token=rootToken'
Prepared Queries
Use Case
• Multiple instances of a given service exist in
multiple datacenters
• Clients can talk to any of them, and always prefer
the instances with lowest latency
• Policies can change, desire to not have the clients
know the details of how to locate a healthy service
Prepared Queries
• New query namespace, similar to services
• Register queries to answer for parts of this
namespace
• Clients use APIs, or “.query.consul” DNS lookups
to run queries
• Magic happens :-)
pg-db with Failover
$ curl -X POST -d 
'{
"Name": "geo-pg-db—follower",
"Service": {
"Service": "pg-db",
"Failover": {
"NearestN": 3
},
"Tags": ["follower"]
}
}’ localhost:8500/v1/query
geo-pgdb—follower.query.consul
PostgreSQL Template
$ curl -X POST -d 
'{
"Name": "geo-db",
"Template": {
"Type": "name_prefix_match",
"Regexp": "^geo-db-(.*?)-([^-]+?)$"
},
"Service": {
"Service": "pg—${match(1)}",
"Failover": {
"NearestN": 3,
"Datacenters": ["dc1", "dc2"]
},
"OnlyPassing": true,
"Tags": ["${match(2)}"]
}
}' localhost:8500/v1/query
geo-db-customer-leader.query.consul
geo-db-customer-follower.query.consul
geo-db-billing-follower.query.consul
leader.pg-customer.service.consul
follower.pg-customer.service.consul
follower.pg-billing.service.consul
Catch All Template
$ curl -X POST -d 
'{
"Name": "",
"Template": {
"Type": "name_prefix_match"
},
"Service": {
"Service": "${name.full}",
"Failover": {
"NearestN": 3
}
}
}' localhost:8500/v1/query
*.query.consul
With a single query template, all
services can fail over to the nearest
healthy service in a different datacenter!
Under the Hood: Network Tomography
• Rides on pings that are part of LAN and WAN
gossip
• Models networking round trip time using simple
physics simulation with masses and springs
• Develops a set of “network coordinates” for round
trip time estimation with a simple calculation
Under the Hood: Network Tomography
HASHICORP
Consul
Conclusion
HASHICORP
Key Value Store
HTTP API
Host & Service
Level Health
Checks
Datacenter Aware
Consul solves four central challenges with SOA
Service
Discovery
HTTP + DNS
HASHICORP
Further reading
- Consul vs. Other Software:
consul.io/intro/vs/index.html
- Consul Agent:
consul.io/docs/agent/basics.html
- Consul Commands:
consul.io/docs/commands/index.html
- Consul Internals:
consul.io/docs/internals/index.html
Questions?
Thanks!
sean@hashicorp.com

More Related Content

What's hot

Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialJean-François Gagné
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep InternalEXEM
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetAlexey Lesovsky
 
Parallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBParallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBMydbops
 
Intro ProxySQL
Intro ProxySQLIntro ProxySQL
Intro ProxySQLI Goo Lee
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsMydbops
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Anastasia Lubennikova
 
Ceph scale testing with 10 Billion Objects
Ceph scale testing with 10 Billion ObjectsCeph scale testing with 10 Billion Objects
Ceph scale testing with 10 Billion ObjectsKaran Singh
 
PostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec PatroniPostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec Patronislardiere
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centersMariaDB plc
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxNeoClova
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniZalando Technology
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2Gang He
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationFrancisco Gonçalves
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyAlexander Kukushkin
 

What's hot (20)

Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication TutorialThe Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication Cheatsheet
 
Parallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBParallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDB
 
Intro ProxySQL
Intro ProxySQLIntro ProxySQL
Intro ProxySQL
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
 
Ceph issue 해결 사례
Ceph issue 해결 사례Ceph issue 해결 사례
Ceph issue 해결 사례
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
 
Ceph scale testing with 10 Billion Objects
Ceph scale testing with 10 Billion ObjectsCeph scale testing with 10 Billion Objects
Ceph scale testing with 10 Billion Objects
 
PostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec PatroniPostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec Patroni
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centers
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
Patroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easyPatroni - HA PostgreSQL made easy
Patroni - HA PostgreSQL made easy
 

Similar to PostgreSQL High-Availability and Geographic Locality using consul

Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesSreenivas Makam
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Giovanni Bechis
 
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeAcademy
 
Smart networking with service meshes
Smart networking with service meshes  Smart networking with service meshes
Smart networking with service meshes Mitchell Pronschinske
 
Service discovery like a pro (presented at reversimX)
Service discovery like a pro (presented at reversimX)Service discovery like a pro (presented at reversimX)
Service discovery like a pro (presented at reversimX)Eran Harel
 
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Ontico
 
Service Discovery Like a Pro
Service Discovery Like a ProService Discovery Like a Pro
Service Discovery Like a ProEran Harel
 
Incrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern AutomationIncrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern AutomationSean Chittenden
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...NGINX, Inc.
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleNeo4j
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsDigitalOcean
 

Similar to PostgreSQL High-Availability and Geographic Locality using consul (20)

Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD
 
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
 
Smart networking with service meshes
Smart networking with service meshes  Smart networking with service meshes
Smart networking with service meshes
 
Service discovery like a pro (presented at reversimX)
Service discovery like a pro (presented at reversimX)Service discovery like a pro (presented at reversimX)
Service discovery like a pro (presented at reversimX)
 
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
 
Soa with consul
Soa with consulSoa with consul
Soa with consul
 
Service Discovery Like a Pro
Service Discovery Like a ProService Discovery Like a Pro
Service Discovery Like a Pro
 
Incrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern AutomationIncrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern Automation
 
tdc2012
tdc2012tdc2012
tdc2012
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
 
Oscon 2011 - ATS
Oscon 2011 - ATSOscon 2011 - ATS
Oscon 2011 - ATS
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
 
REST in Peace
REST in PeaceREST in Peace
REST in Peace
 
How to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking NeedsHow to Leverage Go for Your Networking Needs
How to Leverage Go for Your Networking Needs
 
(Re)discover your AEM
(Re)discover your AEM(Re)discover your AEM
(Re)discover your AEM
 
Consul and Consul Pusher
Consul and Consul PusherConsul and Consul Pusher
Consul and Consul Pusher
 

More from Sean Chittenden

pg_prefaulter: Scaling WAL Performance
pg_prefaulter: Scaling WAL Performancepg_prefaulter: Scaling WAL Performance
pg_prefaulter: Scaling WAL PerformanceSean Chittenden
 
FreeBSD VPC Introduction
FreeBSD VPC IntroductionFreeBSD VPC Introduction
FreeBSD VPC IntroductionSean Chittenden
 
Life Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Life Cycle of Metrics, Alerting, and Performance Monitoring in MicroservicesLife Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Life Cycle of Metrics, Alerting, and Performance Monitoring in MicroservicesSean Chittenden
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL SchemaSean Chittenden
 
PostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesPostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesSean Chittenden
 
Production Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated WorldProduction Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated WorldSean Chittenden
 
PostgreSQL on ZFS Lightning Talk
PostgreSQL on ZFS Lightning TalkPostgreSQL on ZFS Lightning Talk
PostgreSQL on ZFS Lightning TalkSean Chittenden
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningSean Chittenden
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDSean Chittenden
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleSean Chittenden
 

More from Sean Chittenden (13)

BSDCan '19 Core Update
BSDCan '19 Core UpdateBSDCan '19 Core Update
BSDCan '19 Core Update
 
pg_prefaulter: Scaling WAL Performance
pg_prefaulter: Scaling WAL Performancepg_prefaulter: Scaling WAL Performance
pg_prefaulter: Scaling WAL Performance
 
FreeBSD VPC Introduction
FreeBSD VPC IntroductionFreeBSD VPC Introduction
FreeBSD VPC Introduction
 
Universal Userland
Universal UserlandUniversal Userland
Universal Userland
 
Life Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Life Cycle of Metrics, Alerting, and Performance Monitoring in MicroservicesLife Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
Life Cycle of Metrics, Alerting, and Performance Monitoring in Microservices
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
 
PostgreSQL + ZFS best practices
PostgreSQL + ZFS best practicesPostgreSQL + ZFS best practices
PostgreSQL + ZFS best practices
 
Production Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated WorldProduction Readiness Strategies in an Automated World
Production Readiness Strategies in an Automated World
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
PostgreSQL on ZFS Lightning Talk
PostgreSQL on ZFS Lightning TalkPostgreSQL on ZFS Lightning Talk
PostgreSQL on ZFS Lightning Talk
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
 

Recently uploaded

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 

Recently uploaded (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 

PostgreSQL High-Availability and Geographic Locality using consul

  • 6. HASHICORP Key Value Store HTTP API Host & Service Level Health Checks Datacenter Aware Consul solves four central challenges with SOA Service Discovery HTTP + DNS
  • 8. HASHICORP Overview 1. Introduction to Consul 2. Review of Consul a. Architecture b. Agent Functionality c. Agent Configuration d. Features 3. Further Reading
  • 11. CONSUL HASHICORP 1. Service discovery 2. Service registry 3. Key/value store 4. Health checks
  • 12. HASHICORP Glossary Agent - Long-running daemon on every member of the Consul cluster. The agent is able to run in either client or server mode. Client - Agent that forwards all RPCs to a server and participates in the LAN gossip pool. Server - Agent that maintains cluster state, responds to RPC queries, exchanges WAN gossip with other datacenters, and forwards queries to leaders of remote datacenters. Consensus - Agreement upon the elected leader
  • 13. HASHICORP Glossary Gossip - Random node-to-node communication primarily over UDP that provides membership, failure detection, and event broadcast information to the cluster. Built on Serf. Consul has both LAN and WAN Gossip. Datacenter - Networking environment that is private, low latency, and high bandwidth. A Consul cluster is run per datacenter, so its important to have low latency for the gossip protocol.
  • 14. HASHICORP Consul vs. Other Software - Opinionated framework for service discovery using DNS or HTTP - Scalable gossip system that links server nodes and clients - Distributed health checking with edge triggered updates - Globally aware with multi-datacenter support - Operationally simple - Incorporation into the HashiCorp ecosystem
  • 16. HASHICORP Single Datacenter CLIENT CLIENT CLIENT CLIENT CLIENT CLIENT SERVER SERVER SERVER REPLICATION REPLICATION RPC RPC LAN GOSSIP
  • 17. HASHICORP Multi-Datacenter CLIENT CLIENT CLIENT CLIENT CLIENT CLIENT SERVER SERVER SERVER REPLICATION REPLICATION RPC RPC LAN GOSSIP SERVERSERVER SERVER REPLICATION REPLICATION WAN GOSSIP
  • 19. HASHICORP TCP and UDP Ports Client HTTP RPC TCP/8500 DNS TCP/8600 UDP/8600 LAN Gossip TCP/8301 UDP/8301 LAN Gossip TCP/8301 UDP/8301 RPC TCP/8400 RPC TCP/8400 WAN Gossip TCP/8301 UDP/8301 Clients consul1.dc1 Client RPC (HTTP) DNS TCP/8600 UDP/8600 Server RPC TCP/8300 consulN.dc2 consul2.dc1
  • 20. HASHICORP Agent functionality (client or server) - RPC, HTTP, DNS APIs - Health Checks - Event Execution - Gossip Participation - Membership - Failure detection
  • 21. HASHICORP Agent functionality (server) - State replication - Query Handling - Leader election - WAN Gossip
  • 23. HASHICORP DNS Failover • Works across L3 boundaries in LAN environments • Works across L3 boundaries in WAN environments • Small TTLs • Workload Distribution • Clients cache DNS data • Not subject to spanning-tree • Requires TCP connections be reset on failover • Clients can cache stale DNS data Pro Con
  • 25. HASHICORP consul Server 1/3 % cat config.json { "acl_datacenter": "lab1", "acl_default_policy": "deny", "acl_master_token": "rootToken", "addresses": { "dns": "0.0.0.0", "http": "unix:///tmp/.consul.http.sock", "https": "0.0.0.0", "rpc": "unix:///tmp/.consul.rpc.sock" }, "bootstrap_expect": 3, "datacenter": "lab1", "data_dir": "./svc/data", "disable_remote_exec": true,
  • 26. HASHICORP Consul Server 2/3 "dns_config": { "allow_stale": true, "max_stale": "10080m", "node_ttl": "60s", "service_ttl": { "*": "5s", "stable-service": "86400s" } },
 "encrypt": "[ random mime encoded data ]", "log_level": "debug", "ports": { "https": -1 }, "server": true, "unix_sockets": { "mode": "0700" } }
  • 27. HASHICORP Consul Server 3/3 % cat svc/run #!/bin/sh -- set -e exec 2>&1 exec /usr/bin/env -i ./bin/consul agent -config-file=./config.json -config-dir=./conf.d/ % cat svc/log/run #!/bin/sh — set -e set 2>&1 exec chpst -u _log:_log svlogd ./main
  • 28. HASHICORP Consul Cluster % consul members Node Address Status Type Build Protocol DC vm1 172.16.139.140:8301 alive server 0.7.0dev 2 lab1 % consul join 172.16.139.139 172.16.139.138 Successfully joined cluster by contacting 2 nodes. % consul members Node Address Status Type Build Protocol DC vm1 172.16.139.140:8301 alive server 0.7.0dev 2 lab1 vm2 172.16.139.138:8301 alive server 0.7.0dev 2 lab1 vm3 172.16.139.139:8301 alive server 0.7.0dev 2 lab1
  • 29. HASHICORP Consul Cluster % consul info agent: check_monitors = 0 check_ttls = 0 checks = 0 services = 1 build: prerelease = dev revision = 'fa26d5f version = 0.7.0 consul: bootstrap = false known_datacenters = 2 leader = false leader_addr = 172.16.139.139:8300 server = true [snip]
  • 30. HASHICORP Consul Cluster % consul info [snip] raft: applied_index = 103339 commit_index = 103339 fsm_pending = 0 last_contact = 82.95803ms last_log_index = 103339 last_log_term = 50663 last_snapshot_index = 98437 last_snapshot_term = 2228 num_peers = 2 raft_peers = 172.16.139.139:8300,172.16.139.138:8300,172.16.139.140:8300 state = Follower term = 50663 [snip]
  • 31. HASHICORP dnsmasq Config % cat /usr/local/etc/dnsmasq.conf local-service port=53 server=/consul/127.0.0.1#8600 rev-server=172.16.0.0/12,127.0.0.1#8600 server=208.67.222.222 server=208.67.220.220 cache-size=65536 % cat /etc/resov.conf search localdomain nameserver 127.0.0.1
  • 33. HASHICORP - Nodes, Services, Checks - Simple registration (JSON) - DNS Interface - HTTP API Service Discovery
  • 34. HASHICORP PostgreSQL Service % hostname pg002 % cat config.d/pg-db.json { "service": { "name": "pg-db", "tags": ["follower"], "port": 5432, "checks": [{ "id": "pg-alive", "notes": "Make sure connect and queries work", "script": "/usr/local/bin/check_postgresql", "interval": "10s" }] } }
  • 36. Terminal HASHICORP $ dig follower.pg-db.service.consul ; <<>> DiG 9.8.3-P1 <<>> follower.pg-db.service.consul ; (3 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 946 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;follower.pg-db.service.consul. IN A ;; ANSWER SECTION: follower.pg-db.service.consul. 0 IN A 172.16.139.141
  • 37. Terminal HASHICORP $ dig follower.pg-db.service.consul SRV ; <<>> DiG 9.8.3-P1 <<>> follower.pg-db.service.consul SRV ; (3 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 480 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;follower.pg-db.service.consul. IN SRV ;; ANSWER SECTION: follower.pg-db.service.consul. 0 IN SRV 1 1 5432
  • 38. HASHICORP DNS Interface - Zero Touch - Randomized Round-Robin DNS - Filters on Health Checks
  • 39. HASHICORP HTTP API - HTTP API - Custom Integrations
  • 40. HASHICORP Host & Service Level Health Checks
  • 41. HASHICORP What is a health check? 0PASSING 1WARNING _ _FAILING Any command that returns an exit code
  • 42. HASHICORP Health Checks & Monitoring - Nagios-compatible - Scalable - Actionable - Edge Triggered
  • 43. Text Editor HASHICORP % cat conf.d/mem-check.json { "check": { "id": "mem-util", "name": "Memory utilization", "script": "/usr/local/bin/mem_check.sh", "interval": "10s" } } Creating a check Use a custom script
  • 44. Text Editor HASHICORP % cat conf.d/http-check.json { "check": { "id": "api", "name": "HTTP API on port 4455", "http": "http://localhost:4455/_health", "interval": "10s", "timeout": "1s" } } Creating a check Use a built-in check type
  • 45. HASHICORP Traditional Health Checking (pull) HEALTH CHECKING SERVICE DB 1 DB 2 DB N "Are you healthy?"
  • 46. HASHICORP Traditional Health Checking (pull) HEALTH CHECKING SERVICE DB 1 DB 2 DB N "Are you healthy?" "Yessir!"
  • 47. HASHICORP Traditional Health Checking (pull) HEALTH CHECKING SERVICE DB 1 DB 2 DB N "Are you healthy?" "What about you?" "Yessir!"
  • 48. HASHICORP Traditional Health Checking (pull) HEALTH CHECKING SERVICE DB 1 DB 2 DB N "Are you healthy?" "What about you?" "Yessir!" "Nah"
  • 49. HASHICORP Traditional Health Checking (pull) DB 1 DB 2 DB N HEALTH CHECKING SERVICE "Are you healthy?" "What about you?" "Yessir!" "Nah"
  • 50. HASHICORP Traditional Health Checking (pull) DB 1 DB 2 DB N HEALTH CHECKING SERVICE 1,000'S OF REQUESTS
  • 51. HASHICORP Consul Health Checking (push) CONSUL DB 1 DB 2 DB N My status has changed
  • 52. HASHICORP Consul Health Checking (push) CONSUL DB 1 DB 2 DB N 10'S OF REQUESTS
  • 53. HASHICORP Liveness - No Heartbeats - Gossip-based Failure Detector built on Serf - Constant Load
  • 56. Terminal HASHICORP $ curl -X PUT -d 'bar' http://localhost:8500/v1/kv/foo true
  • 57. Terminal HASHICORP $ curl -X PUT -d 'bar' http://localhost:8500/v1/kv/foo true $ curl http://localhost:8500/v1/kv/foo [ { "CreateIndex": 100, "ModifyIndex": 200, "Key": "foo", "Flags": 0, "Value": "YmFy" } ] % echo -n 'bar' | base64 YmFy % echo -n 'YmFy' | base64 -d ; echo bar
  • 58. Terminal HASHICORP % cat <<EOF > acl.anonymous.json { "ID": "anonymous", "Name": "Anonymous Token", "Type": "client", "Rules": "# Default all keys to read-only key "" { policy = "read" } # Default all services to read-only service "" { policy = "read" } # Allow hearing any user event by default. event "" { policy = "read" }
  • 59. Terminal HASHICORP # Default prepared queries to read-only. query "" { policy = "read" } # Read-only mode for the encryption keyring by default (list only) keyring = "read"" } EOF % curl -v -X PUT -d @acl.anonymous.json --unix-socket / tmp/.consul.http.sock 'http://consul/v1/acl/update? token=rootToken'
  • 61. Use Case • Multiple instances of a given service exist in multiple datacenters • Clients can talk to any of them, and always prefer the instances with lowest latency • Policies can change, desire to not have the clients know the details of how to locate a healthy service
  • 62. Prepared Queries • New query namespace, similar to services • Register queries to answer for parts of this namespace • Clients use APIs, or “.query.consul” DNS lookups to run queries • Magic happens :-)
  • 63. pg-db with Failover $ curl -X POST -d '{ "Name": "geo-pg-db—follower", "Service": { "Service": "pg-db", "Failover": { "NearestN": 3 }, "Tags": ["follower"] } }’ localhost:8500/v1/query geo-pgdb—follower.query.consul
  • 64. PostgreSQL Template $ curl -X POST -d '{ "Name": "geo-db", "Template": { "Type": "name_prefix_match", "Regexp": "^geo-db-(.*?)-([^-]+?)$" }, "Service": { "Service": "pg—${match(1)}", "Failover": { "NearestN": 3, "Datacenters": ["dc1", "dc2"] }, "OnlyPassing": true, "Tags": ["${match(2)}"] } }' localhost:8500/v1/query geo-db-customer-leader.query.consul geo-db-customer-follower.query.consul geo-db-billing-follower.query.consul leader.pg-customer.service.consul follower.pg-customer.service.consul follower.pg-billing.service.consul
  • 65. Catch All Template $ curl -X POST -d '{ "Name": "", "Template": { "Type": "name_prefix_match" }, "Service": { "Service": "${name.full}", "Failover": { "NearestN": 3 } } }' localhost:8500/v1/query *.query.consul With a single query template, all services can fail over to the nearest healthy service in a different datacenter!
  • 66. Under the Hood: Network Tomography • Rides on pings that are part of LAN and WAN gossip • Models networking round trip time using simple physics simulation with masses and springs • Develops a set of “network coordinates” for round trip time estimation with a simple calculation
  • 67. Under the Hood: Network Tomography
  • 69. HASHICORP Key Value Store HTTP API Host & Service Level Health Checks Datacenter Aware Consul solves four central challenges with SOA Service Discovery HTTP + DNS
  • 70. HASHICORP Further reading - Consul vs. Other Software: consul.io/intro/vs/index.html - Consul Agent: consul.io/docs/agent/basics.html - Consul Commands: consul.io/docs/commands/index.html - Consul Internals: consul.io/docs/internals/index.html