consul service/session/kv TTLs

276 views
Skip to first unread message

R.B. Boyer

unread,
Oct 6, 2014, 8:33:23 AM10/6/14
to consu...@googlegroups.com
I've read through the documentation for the HTTP API and cannot figure out how to auto-reap stale service/session/kv entries after a certain window of time has elapsed.

Ideally I'd like TTLs on Service, Session, and KV with behavior mimicking memcached key expiration or etcd key TTLs (like https://coreos.com/docs/distributed-configuration/etcd-api/#using-key-ttl )

The primary justification for needing TTLs is one of garbage collection of the keyspace (for all of Service/Session/KV).

One such place this quickly arises is when trying to use Consul for service discovery in a Mesos cluster where an instance of a service floats from host to host each time it restarts.  Since consul seems to require explicit de-registration of Services this leads to cluttering the replicated database with old service instances that are probably never coming back.  Similar problems arise when using KV/Sessions for leader-election according to the published Guide.

With ZK I would use an ephemeral node for announcement (which self-cleans on crash/socket-close/hang).  With etcd I would use a TTL on a key that the service would touch.

Is there a trick to achieving this with Consul?

Armon Dadgar

unread,
Oct 6, 2014, 2:20:39 PM10/6/14
to consu...@googlegroups.com, R.B. Boyer
Hey,

We don’t currently support a TTL or Ephemeral key style for Consul, however that is coming
in the next major release (0.5).

Consul currently assumes a more stable KV set, that isn’t under much flux where
deletes are handled by the application. In the mean time, you would need to write a
“GC” or something for the key space to achieve this…

Hopefully we will have 0.5 sooner rather than later however :)

Best Regards,
Armon Dadgar
--
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages