# Configuring failover for external services

DevFeed: [Configuring failover for external services](<https://devfeed.tech/articles/configuring-failover-for-external-services-48730.md>)

Original publisher: [Read original article](<https://istio.io/latest/blog/2021/external-locality-failover/>)

Author: Ram Vennam (Solo.io)

Published: 2021-06-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [Istio](<https://devfeed.tech/sources/istio-blog.md>)

Topics: [service-mesh](<https://devfeed.tech/topics/service-mesh.md>), [istio](<https://devfeed.tech/topics/istio.md>), [Gke](<https://devfeed.tech/topics/gke.md>), [Amazon DynamoDB](<https://devfeed.tech/topics/amazon-dynamodb.md>), [Load Balancing](<https://devfeed.tech/topics/load-balancing.md>), [Kubernetes](<https://devfeed.tech/topics/kubernetes.md>), [Latency](<https://devfeed.tech/topics/latency.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [amazon-dynamodb](<https://devfeed.tech/tags/amazon-dynamodb.md>), [cluster](<https://devfeed.tech/tags/cluster.md>), [external](<https://devfeed.tech/tags/external.md>), [external-services](<https://devfeed.tech/tags/external-services.md>), [failover](<https://devfeed.tech/tags/failover.md>), [google-kubernetes-engine](<https://devfeed.tech/tags/google-kubernetes-engine.md>), [ingress](<https://devfeed.tech/tags/ingress.md>), [istio](<https://devfeed.tech/tags/istio.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [latency](<https://devfeed.tech/tags/latency.md>), [load-balancing](<https://devfeed.tech/tags/load-balancing.md>), [locality](<https://devfeed.tech/tags/locality.md>), [mesh](<https://devfeed.tech/tags/mesh.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [outlier](<https://devfeed.tech/tags/outlier.md>), [region](<https://devfeed.tech/tags/region.md>), [service-mesh](<https://devfeed.tech/tags/service-mesh.md>), [services](<https://devfeed.tech/tags/services.md>)

## AI overview

A tutorial on configuring Istio for locality-aware load balancing and automatic failover for external services. It uses Amazon DynamoDB endpoints accessed by workloads in a Google Kubernetes Engine cluster, selecting a nearby primary region and a secondary failover region.

## Source excerpt

Istio's powerful APIs can be used to solve a variety of service mesh use cases. Many users know about its strong ingress and east-west capabilities but it also offers many features for egress (outgoing) traffic. This is especially useful when your application needs to talk to an external service - such as a database endpoint provided by a cloud provider. There are often multiple endpoints to chose from depending on where your workload is running. For example, Amazon's DynamoDB provides several endpoints across their regions. You typically want to choose the endpoint closest to your workload for latency reasons, but you may need to configure automatic failover to another endpoint in case things are not working as expected. Similar to services running inside the service mesh, you can configure Istio to detect outliers and failover to a healthy endpoint, while still being completely transparent to your application. In this example, we'll use Amazon DynamoDB endpoints and pick a primary region that is the same or close to workloads running in a Google Kubernetes Engine (GKE) cluster. We'll also configure a failover region. Routing Endpoint Primary http://dynamodb.us-east-1.amazonaws.com Failover http://dynamodb.us-west-1.amazonaws.com Define external endpoints using a ServiceEntry Locality load balancing works based on region or zone, which are usually inferred from labels set on the Kubernetes nodes. First, determine the location of your workloads: $ kubectl describe node | grep failure-domain.beta.kubernetes.io/region failure-domain.beta.kubernetes.io/region=us-east1 failure-domain.beta.kubernetes.io/region=us-east1 In this example, the GKE cluster nodes are running in us-east1. Next, create a ServiceEntry which aggregates the endpoints you want to use. In this example, we have selected mydb.com as the host. This is the address your application should be configured to connect to. Set the locality of the primary endpoint to the same region as your workload: apiVersion: