Skip to main content


Targetting Dynamic Configuration With Namespaces

Namespaces allow you to share config amongst many applications while still allowing you to override when necessary.

For instance, let's assume that all our code shares an HTTP library. We can configure the HTTP library to get its retry count & timeout duration from our config store. We'll set http.connection.retries and http.connection.timeout in the default namespace.

All of our apps should initialize their config store in a namespace. For instance our User Service may have clients in the namespaces:

  • "")
  • "userservice.daemon.sidekiq")
  • "userservice.cron.sync-to-billing")
  • "userservice.cron.cleanup-job")

It's likely that you have a good namespace already defined as a tag on your pod. Something like namespace = (ENV['DEPLOYED_NAME'] || "").gsub("-",".") may be just what you're looking for.

Prefab config will find the "closest" matching config when the UserService goes to look for a value of http.connection.timeout.

Let's imagine that the UserService starts to go down because too many requests are timing out to a our billing service. We can quickly reduce the http.connection.timeout for our userservice.cron.sync-to-billing namespace and solve the issue without pushing code or restarting.

With the following values namespaces for http-retries

# staging
client =
client.get("http.connection.retries") # returns 1

# staging
client = "userservice.cron.sync-to-billing"))
client.get("http.connection.retries") # returns 1

# production
client = "userservice.web.web"))
client.get("http.connection.retries") # returns 3

# production
client = "userservice.cron.sync-to-billing"))
client.get("http.connection.retries") # returns 0