# Data Center Aware Load Balancing

**URL:** <https://discuss.konghq.com/t/data-center-aware-load-balancing/5667>\
**Category:** Questions\
**Created:** [February 28, 2020, 4:42pm UTC](https://discuss.konghq.com/t/data-center-aware-load-balancing/5667 "2020-02-28T16:42:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/cbranch/32/1732_2.png) [@cbranch](https://discuss.konghq.com/u/cbranch)\
**Post date:** [February 28, 2020, 4:42pm UTC](https://discuss.konghq.com/t/data-center-aware-load-balancing/5667/1 "2020-02-28T16:42:18Z")

</div>

When deploying a Kong cluster to multiple data centers, is there a way to configure load balancing for an upstream such that requests stay in the same data center and only go to the other data center if/when targets are unhealthy in the local data center?

I saw that this question was asked a few years ago on github, the advice back then was to use DNS to handle this:

> <https://github.com/Kong/kong/issues/3042>
>
> I have a requirement to set up multi-DC cluster using upstream/targets for dynamic load balance. If we add targets of multi-DC...

If I’m not able to modify DNS to return SRV records, are there any other options? One idea I had was to create separate upstreams for each data center and use a custom plugin that would dynamically re-assign the service’s upstream (via kong.service.set\_upstream PDK function) based on health status of the “local” upstream. However, I’m not sure if I have easy access to the current health status for all targets on an upstream within a plugin. Is there a way to accomplish this out of the box? If not, thoughts on whether the plugin idea would work?

---

<div class="post-metadata">

**Author:** ![taotao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/taotao/32/2131_2.png) [@taotao](https://discuss.konghq.com/u/taotao)\
**Post date:** [March 1, 2020, 2:36am UTC](https://discuss.konghq.com/t/data-center-aware-load-balancing/5667/3 "2020-03-01T02:36:47Z")

</div>

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

---

<div class="post-metadata">

**Author:** ![taotao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/taotao/32/2131_2.png) [@taotao](https://discuss.konghq.com/u/taotao)\
**Post date:** [August 5, 2020, 11:51pm UTC](https://discuss.konghq.com/t/data-center-aware-load-balancing/5667/5 "2020-08-05T23:51:55Z")

</div>

Solution:

> <https://github.com/Kong/kong/pull/6189>
