ELBのDNS LookupでIPアドレスを8個返すようになりました

今までのELB

今までのELBはあるDNS名に対して1つのIPアドレスを返していました。このIPアドレスは固定ではなく、ELBの混雑状況によって自動的に変化していました。このDNS名に対するIPアドレスの変更は、クライアントアプリ側のDNSキャッシュ等で不具合を起こす危険性がゼロではなく、実際に私は体験しました。

新しいELB

新しいELBは最大で8つのIPアドレスを返してくれます。これによって、ELBの混雑状況によって拡大したり縮小した場合に、さっきまで見えていたキャッシュしたIPアドレスが見つからないといったエラーが無くなります。

8つのIPアドレスを確認する

digコマンドで確認できます。試してみて勘違いしていたのですが、AZの数に応じて最大で8つのようです。以下はAZ1つの場合で、結果のAレコードは1つでした。

$ dig MyLoadBalancer-83p080071.ap-northeast-1.elb.amazonaws.com

; <<>> DiG 9.7.3-P3 <<>> MyLoadBalancer-83p080071.ap-northeast-1.elb.amazonaws.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43600 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 8, ADDITIONAL: 8 ;; QUESTION SECTION: ;MyLoadBalancer-834080071.ap-northeast-1.elb.amazonaws.com. IN A ;; ANSWER SECTION: MyLoadBalancer-834080071.ap-northeast-1.elb.amazonaws.com. 36 IN A 176.32.89.84 ;; AUTHORITY SECTION: elb.amazonaws.com. 905 IN NS ns-941.amazon.com. elb.amazonaws.com. 905 IN NS ns-927.amazon.com. elb.amazonaws.com. 905 IN NS ns-944.amazon.com. elb.amazonaws.com. 905 IN NS ns-916.amazon.com. elb.amazonaws.com. 905 IN NS ns-947.amazon.com. elb.amazonaws.com. 905 IN NS ns-925.amazon.com. elb.amazonaws.com. 905 IN NS ns-935.amazon.com. elb.amazonaws.com. 905 IN NS ns-934.amazon.com. ;; ADDITIONAL SECTION: ns-916.amazon.com. 27 IN A 207.171.178.7 ns-925.amazon.com. 28 IN A 72.21.208.213 ns-927.amazon.com. 28 IN A 72.21.204.209 ns-934.amazon.com. 40 IN A 87.238.84.215 ns-935.amazon.com. 42 IN A 87.238.80.213 ns-941.amazon.com. 894 IN A 204.246.160.5 ns-944.amazon.com. 909 IN A 204.246.161.7 ns-947.amazon.com. 27 IN A 204.246.162.10 ;; Query time: 2 msec ;; SERVER: 192.168.0.3#53(192.168.0.3) ;; WHEN: Thu Oct 27 11:54:17 2011 ;; MSG SIZE rcvd: 394 [/text]

続いてAZを2つにした場合です。Aレコードが2つになりました!!

$ dig MyLB1-1168506832.ap-northeast-1.elb.amazonaws.com

; <<>> DiG 9.7.3-P3 <<>> MyLB1-1168506832.ap-northeast-1.elb.amazonaws.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62308 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 8, ADDITIONAL: 8 ;; QUESTION SECTION: ;MyLB1-1168506832.ap-northeast-1.elb.amazonaws.com. IN A ;; ANSWER SECTION: MyLB1-1168506832.ap-northeast-1.elb.amazonaws.com. 60 IN A 46.51.250.132 MyLB1-1168506832.ap-northeast-1.elb.amazonaws.com. 60 IN A 176.32.89.84 ;; AUTHORITY SECTION: elb.amazonaws.com. 2631 IN NS ns-934.amazon.com. elb.amazonaws.com. 2631 IN NS ns-916.amazon.com. elb.amazonaws.com. 2631 IN NS ns-925.amazon.com. elb.amazonaws.com. 2631 IN NS ns-935.amazon.com. elb.amazonaws.com. 2631 IN NS ns-944.amazon.com. elb.amazonaws.com. 2631 IN NS ns-941.amazon.com. elb.amazonaws.com. 2631 IN NS ns-947.amazon.com. elb.amazonaws.com. 2631 IN NS ns-927.amazon.com. ;; ADDITIONAL SECTION: ns-916.amazon.com. 860 IN A 207.171.178.7 ns-925.amazon.com. 862 IN A 72.21.208.213 ns-927.amazon.com. 860 IN A 72.21.204.209 ns-934.amazon.com. 1 IN A 87.238.84.215 ns-935.amazon.com. 55 IN A 87.238.84.215 ns-941.amazon.com. 2624 IN A 204.246.160.5 ns-944.amazon.com. 2638 IN A 204.246.161.7 ns-947.amazon.com. 862 IN A 204.246.162.10 ;; Query time: 140 msec ;; SERVER: 192.168.0.3#53(192.168.0.3) ;; WHEN: Thu Oct 27 13:30:31 2011 ;; MSG SIZE rcvd: 402 [/text]

さらに、AZがたくさんあるUSリージョンで試してみます。

$ dig MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com

; <<>> DiG 9.7.3-P3 <<>> MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40479 ;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 8, ADDITIONAL: 8 ;; QUESTION SECTION: ;MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com. IN A ;; ANSWER SECTION: MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com. 60 IN A 107.20.220.100 MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com. 60 IN A 184.73.247.162 MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com. 60 IN A 107.20.162.34 MyLoadBalancer-808957587.us-east-1.elb.amazonaws.com. 60 IN A 107.20.177.26 ;; AUTHORITY SECTION: elb.amazonaws.com. 736 IN NS ns-916.amazon.com. elb.amazonaws.com. 736 IN NS ns-941.amazon.com. elb.amazonaws.com. 736 IN NS ns-934.amazon.com. elb.amazonaws.com. 736 IN NS ns-944.amazon.com. elb.amazonaws.com. 736 IN NS ns-925.amazon.com. elb.amazonaws.com. 736 IN NS ns-947.amazon.com. elb.amazonaws.com. 736 IN NS ns-927.amazon.com. elb.amazonaws.com. 736 IN NS ns-935.amazon.com. ;; ADDITIONAL SECTION: ns-916.amazon.com. 767 IN A 207.171.178.7 ns-925.amazon.com. 770 IN A 72.21.208.213 ns-927.amazon.com. 769 IN A 72.21.204.209 ns-934.amazon.com. 55 IN A 87.238.84.215 ns-935.amazon.com. 48 IN A 87.238.84.215 ns-941.amazon.com. 744 IN A 204.246.160.5 ns-944.amazon.com. 745 IN A 204.246.161.7 ns-947.amazon.com. 767 IN A 204.246.162.10 ;; Query time: 113 msec ;; SERVER: 192.168.0.3#53(192.168.0.3) ;; WHEN: Thu Oct 27 13:51:48 2011 ;; MSG SIZE rcvd: 437 [/text]

今度は4つAレコード返ってきました!こんな感じで最大8個まで返してくれるんですね。

ちなみに、今までのELBを使っている場合には、3週間以内に新しいELBに切り替わるようです。

まとめ

まさに、日進月歩の進化を続けるAWSサービス群。今後の進化にも期待大です!