レイテンシーベースルーティング
ユーザーからのDNSクエリに対して、最もレイテンシが低いAWSリージョンのリソースを返すルーティングポリシー
“If your application is hosted in multiple AWS Regions, you can improve performance for your users by serving their requests from the AWS Region that provides the lowest latency.”
仕組み
“When Route 53 receives a DNS query for your domain or subdomain, it determines which AWS Regions you’ve created latency records for, determines which Region gives the user the lowest latency, and then selects a latency record for that Region.”
ユーザー(東京)→ DNS問い合わせ → Route 53
│
レイテンシ測定データを参照
│
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
東京リージョン バージニア フランクフルト
(レイテンシ: 低) (レイテンシ: 高) (レイテンシ: 中)
│
▼
東京のIPアドレスを返す
設定例
“To use latency-based routing, you create latency records for your resources in multiple AWS Regions.”
ルーティング先のリージョンごとに同じ名前のレコードを作成する必要がある
東京とバージニアにALBがある場合、2つのレコードを作成:
レコード1:
名前: api.example.com
タイプ: A (エイリアス)
ルーティングポリシー: レイテンシー
リージョン: ap-northeast-1 (東京)
値: 東京のALB
SetIdentifier: "tokyo"
レコード2:
名前: api.example.com
タイプ: A (エイリアス)
ルーティングポリシー: レイテンシー
リージョン: us-east-1 (バージニア)
値: バージニアのALB
SetIdentifier: "virginia"
SetIdentifierとは
通常、DNSレコードは「名前 + タイプ」で一意だが、レイテンシーベースルーティングでは同じ名前・同じタイプのレコードを複数作る
Route 53内部でこれらを区別するための識別子がSetIdentifier
出典: Values specific for latency records
“Set ID: Enter a value that uniquely identifies this record in the group of latency records.”
SetIdentifierは管理用のラベルで、ユーザーには見えない
注意点
“Latency between hosts on the internet can change over time as a result of changes in network connectivity and routing. Latency-based routing is based on latency measurements taken over a period of time, and the measurements reflect these changes.”
- レイテンシ測定はAWSの過去データに基づく(リアルタイム測定ではない)
- ネットワーク状況により結果が変わる可能性がある
ユースケース
- グローバルWebアプリで最寄りリージョンへ誘導
- マルチリージョンAPIのレスポンス時間最小化
フェイルオーバールーティング
Active-Passive構成を実現するルーティングポリシー
┌─────────────────┐
│ Route 53 │
│ Health Check │
└────────┬────────┘
│
┌────────▼────────┐
│ Route 53 │
│ Failover Record │
└────────┬────────┘
│
┌─────────────────┴─────────────────┐
│ │
┌──────▼──────┐ ┌───────▼──────┐
│ PRIMARY │ ← 通常時 │ SECONDARY │ ← 障害時
│ Server │ │ Server │
└─────────────┘ └──────────────┘
- プライマリが正常な場合: プライマリのIPアドレスを返却
- プライマリが異常な場合: セカンダリのIPアドレスを返却
出典: Active-active and active-passive failover - Amazon Route 53
実際に試してみる
https://github.com/trkoh/AWS/tree/main/Route53/failover-routing