Skip to content

Dynamic configuration

Settings a service re-reads while running, so a change usually needs no redeploy: limits, rules, flags, kill switches. The design questions: how a change reaches the servers, how fast, and how a bad one is undone.

On this page

What it is

Configuration is the interface for changing what a system does without the slow path of rebuilding and redeploying it. The Google SRE workbook describes a system as three parts: the software, the data it works on and its configuration. On this page, dynamic configuration means the settings in that third part a process is designed to re-read while it runs: a per-client request limit, a fraud rule's threshold, a feature flag, a kill switch that turns a code path off. Static configuration, by contrast, is usually loaded when the process starts, and changing it typically means a reload, a restart or a deploy.

The same property that makes it useful makes it dangerous. A code change typically goes through small increments, review and tests; a single configuration option can change behavior dramatically, and the classic example is a firewall rule that locks you out of your own system. Configuration often lives in an untested or untestable environment, and a change may have to be made under pressure during an incident. A dynamic configuration system is worth designing deliberately because of this gap: without validation and a staged rollout, a change can reach live traffic with less testing than the code it steers.

PartWhat it doesDetail to name

Store

Holds the current values and their history

A version per change, a clear owner per entry, a way to list each edit that went into a change

Validation

Rejects a bad change before it is published

Syntax, then meaning: a path that doesn't exist, a memory figure a thousand times too large because of units

Delivery

Gets a published version to all the servers

Streamed to connected clients, or polled on an interval; a local in-memory copy on each server

Rollout

Limits how many callers see a change at once

A percentage per step, a total duration, a bake time watching alarms before the next step

Fallback

Decides what a server does without the store

Keep the last copy it received; with none, use defaults compiled into the code

Delivery, in one product's design. LaunchDarkly's SDK fetches the full flag set when the application launches and keeps it in an in-memory cache that, by default, doesn't expire; flags are then evaluated locally from that copy. When a flag's targeting rules change, the update is streamed to connected SDKs. Polling is a fallback for environments that can't hold a persistent connection, such as mobile apps where a long-lived connection costs the user data, and the vendor recommends against it outside those cases. If the connection drops, the SDK keeps serving from memory; if it can't reach the service during initialization, it uses default values written in the application code. A server-side SDK can add a persistent data store, and a Relay Proxy can act as a cache of flag values for an environment.

Rollout, in another. An AWS AppConfig deployment strategy sets a step percentage, the share of callers that gets the new configuration at each step, a total deployment time, a growth type of linear or exponential, and a bake time, the period during which it watches Amazon CloudWatch alarms before moving to the next step or declaring the deployment complete. You can define up to 20 custom strategies, and the client still has to be configured to retrieve the data, which is the delivery question again. The SRE workbook names the three properties behind a design like this: a change can be deployed gradually, it can be rolled back, and progress stops or reverses automatically when the change would take away the operator's control.

When to use it

Reach for it when a value has to change faster than your deploy cycle allows. Operators use configuration to tune a running system and to respond during incidents, which covers a request limit raised during a traffic spike or a code path turned off while a fix is written. Rules that face an adversary, such as fraud or abuse rules, fit the same shape when the analysts who write them don't ship the binary and a rule is wanted live within hours rather than at the next release. Per-tenant limits and gradual exposure of a feature are two more cases where we'd reach for it.

For a rule that acts on money or blocks users, our advice is to publish it in an observe-only state first, so it logs what it would have done without doing it, and to make that state the default a new rule starts in. A dry-run default is the general form of this idea, a safe answer that fits most users; applied to rules, it means a misfiring rule shows up in a log before it shows up in declined payments.

When not to

Keep a value static when it changes rarely and a wrong value is as harmful as a bug: a database address, a listening port, a schema version. Those changes deserve the review and tests your code path can give them. Per-user or per-record data belongs in the database, not in configuration; our advice is to keep the configuration store for settings that many servers read, and to leave rows that one request reads to the database. And when the "rules" start to carry loops and function calls, you have a program. The workbook's advice is to keep code and data separate and have the infrastructure run on plain static data; a rule language that grew into a programming language should get a test suite and a release process like any other code.

Be wary of configuration that points at something outside itself. A version that references data on a network filesystem isn't hermetic: rolling it back restores the pointer, not what it pointed to. And don't make the store a dependency of each request. A design where a server reads the store synchronously and fails when it's unreachable has turned a convenience into a single point of failure; keeping a local copy and defaults in code, as the LaunchDarkly SDK does, is the simpler and safer shape.

Compared

ApproachHow a change arrivesLag and costWhen it's the right one

Static file, restart to change

Through the deploy pipeline

Slowest; can go through the same review and tests as code

Values that change rarely, or where you want a change to earn its way through the code path

Polling the store

Each server asks on an interval

A change can wait up to one interval before a server even asks, plus the fetch itself; load grows with servers times frequency

Clients that can't hold a persistent connection, or would rather not, such as mobile apps saving the user's data; small fleets where simplicity wins

Streaming push

The store sends the change to connected clients

Fastest; needs long-lived connections and reconnect handling

Large fleets that need fast changes, such as a kill switch

Push through a staged rollout

A growing percentage of callers gets the change, with a pause to watch alarms between steps

Deliberately slower; needs alarms that reflect user harm

Risky changes such as rules and limits; what we'd pick for production traffic

In a picture

Analyst edits ruleSyntax andmeaning

Step 1 of 5

Author and validate

An analyst edits a rule in a UI or a file. Syntax is checked first, then meaning: does the field exist, is the threshold in the right units, does the rule parse to something the engine can run?

How to say it in an interview

The common mistake

Quiz

The configuration store becomes unreachable during a traffic spike. What should a server that already has a copy do?
A rule published an hour ago is declining legitimate payments. What is the fastest safe mitigation?
What is a bake time in a staged configuration rollout?
A configuration version references a file on a shared network filesystem. Why is that a rollback problem?

Questions that use this

Related

Sources

  1. Google SRE workbook, chapter 14: Configuration Design and Best Practices
  2. AWS AppConfig User Guide: Create a deployment strategy
  3. LaunchDarkly documentation: LaunchDarkly architecture
Sign in to report a mistake