Citadel - Extreme Scaling with HashiCorp Nomad and Consul
In this talk from HashiConf 2016, Caius Howcroft covers Citadel's use of HashiCorp Nomad and Consul to gain rapid scaling of its compute resources, for immediate market insights.
WatchFeature rich key/value store to easily configure services
Services have many runtime configurations, such as feature flags or maintenance modes, that need to be propagated in real time. Distributing these updates using configuration management or by re-deploying services can take minutes to hours. During these rollout periods, infrastructure can be out of sync and service configurations could be incorrect.
Consul can update service configurations across thousands of services in a globally distributed fleet in real-time. Configuration is stored in a hierarchical key/value store, and efficient edge triggers push changes out to applications quickly.
Feature rich key/value store for dynamic service configuration data. Use it for feature flagging, maintenance modes, and more.
The key/value store supports both read and write transactions. This allows multiple keys to be updated or read as an atomic transaction. Changes to service configuration can be done atomically to minimize churn and avoid inconsistencies.
$ curl http://localhost:8500/v1/txn \
--request PUT \
--data \
'[
{
"KV": {
"Verb": "set",
"Key": "lock",
"Value": "MQ=="
}
},
{
"KV": {
"Verb": "cas",
"Index": 10,
"Key": "configuration",
"Value": "c29tZS1jb25maWc="
}
}
]'
The Consul API supports blocking queries, allowing edge triggered updates. Clients use this to get notified immediately of any changes. Tools like consul-template allow configuration files to be rendered in real-time to third-party sources when any configuration changes are made.
$ curl http://localhost:8500/v1/kv/web/config/rate_limit?wait=1m&index=229
[
{
"LockIndex": 0,
"Key": "web/config/rate_limit",
"Flags": 0,
"Value": "NjAw",
"CreateIndex": 229,
"ModifyIndex": 234
}
]
Watches use blocking queries to monitor for any configuration or health status updates and invoke user specified scripts to handle changes. This makes it easy to build reactive infrastructure.
$ consul watch \
-type=key \
-key=web/config/rate_limit \
/usr/local/bin/record-rate-limit.sh
The key/value store supports distributed locks and semaphores. This makes it easier for applications to perform leader election or manage access to shared resources.