# Integration with consul

**URL:** <https://discuss.konghq.com/t/integration-with-consul/3594>\
**Category:** Feature Requests & Feedback\
**Created:** [May 22, 2019, 2:08pm UTC](https://discuss.konghq.com/t/integration-with-consul/3594 "2019-05-22T14:08:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzahimizrahi](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@tzahimizrahi](https://discuss.konghq.com/u/tzahimizrahi)\
**Post date:** [May 22, 2019, 2:08pm UTC](https://discuss.konghq.com/t/integration-with-consul/3594/1 "2019-05-22T14:08:56Z")

</div>

Hi, is there plan to add integration with Consul service discovery in terms of dynamically update upstream configs?

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [June 4, 2019, 4:38pm UTC](https://discuss.konghq.com/t/integration-with-consul/3594/2 "2019-06-04T16:38:33Z")

</div>

Consul has a DNS interface that you can use with Kong:

> **[DNS Interface - Consul by HashiCorp](https://www.consul.io/docs/agent/dns.html)**
>
> One of the primary query interfaces for Consul is DNS. The DNS interface allows applications to make use of service discovery without any high-touch integration with Consul.

You would configure Kong’s Upstream to point to a service and then ensure that Kong uses Consul as it’s DNS server. With this, Kong can dynamically update the targets as the SRV records change in Consul.

---

<div class="post-metadata">

**Author:** ![tzahimizrahi](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@tzahimizrahi](https://discuss.konghq.com/u/tzahimizrahi)\
**Post date:** [June 4, 2019, 5:24pm UTC](https://discuss.konghq.com/t/integration-with-consul/3594/3 "2019-06-04T17:24:42Z")

</div>

Thanks for your reply!  
Is Kong resolve the consul service IP address and port using SRV records or just A dns records?  
Also, is Kong respect consul dns ttl 0?

However as I understood, if Kong respect the dns ttl which is 0 by default it means that Kong should perform dns query for each new session, which means a huge overhead and latency for a new session initializing.

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [June 4, 2019, 9:13pm UTC](https://discuss.konghq.com/t/integration-with-consul/3594/4 "2019-06-04T21:13:50Z")

</div>

> [@tzahimizrahi](#):
>
> Is Kong resolve the consul service IP address and port using SRV records or just A dns records?

Configurable with `dns_order`, by default it will respect SRV record if one is present.

> [@tzahimizrahi](#):
>
> However as I understood, if Kong respect the dns ttl which is 0 by default it means that Kong should perform dns query for each new session, which means a huge overhead and latency for a new session initializing.

Correct. You should have a non-zero DNS TTL for performance reasons. This introduces a problem of a latency between an upstream node going down and Kong being informed that change (upon TTL expiration). To get around this problem, you should be using Active and Passive healthchecking in Kong, which can help Kong detect quickly that an upstream node died. New nodes will be added to Kong once the DNS TTL for that particular service expires.
