AWS ELB経由での性能試験注意点

実案件で遭遇した問題ではないのですが、
ELBを使用した構成での性能試験でよく発生する問題があるということを知ったので、
みなさんに共有いたします。

ELBを使用したアーキテクチャ

f:id:iryond:20160807230902p:plain 出典:https://aws.amazon.com/articles/1636185810492479

上記はELBとAutoScalingを利用した一般的なシステム構成です。
EC2インスタンスがAutoScalingによってスケールアウトした場合であっても
自動的にELBに組み込むことができ、拡張性を確保できることがクラウドの強みです。

上記の構成はEC2インスタンスがAutoScalingする図式ですが、
ELBもAWSの技術を使って(=おそらくEC2によって)実装されているため、
下記の通り、ELBも必要に応じて自動的にスケールアウト(多分AutoScaling)します。

f:id:iryond:20160807230911p:plain:w400

ELB経由での性能試験時の注意点

前述の図の通り、ELBは必要に応じてスケールアウトしますが、
その際、Endpointを名前解決して返却されるIPアドレスは一意となりません。

公開情報ではないのであくまで想像にすぎませんが、
ELBを使った負荷分散を実現している場合、下記のような挙動をしていると思われます。

f:id:iryond:20160807230917p:plain

上記を踏まえ、性能試験における観点では、
Jmeterなどの負荷ソフトウェアの
DNS Cacheが有効(長時間)になっている状態で
ELBのスケールアウトが発生した場合、
適切にトラフィックが分散されない可能性がある

というところが注意点となります。

上図でいうと、ELBの特定のインスタンスにしか振り分けられないようなイメージでしょうか。

解決策

解決策としては、下記があげられます。

以上、実家からお送りしました。

出典

Best Practices in Evaluating Elastic Load Balancing : Articles & Tutorials : Amazon Web Services

DNS Resolution
There are a variety of load testing tools, and most of the tools are designed to address the question of how many servers a business must procure based on the amount of traffic the servers are able to handle. To test server load in this situation, it was logical to quickly ramp up the traffic to determine when the server became saturated, and then to try iterations of the tests based on request and response size to determine the factors affecting the saturation point.

When you create an elastic load balancer, a default level of capacity is allocated and configured. As Elastic Load Balancing sees changes in the traffic profile, it will scale up or down. The time required for Elastic Load Balancing to scale can range from 1 to 7 minutes, depending on the changes in the traffic profile. When Elastic Load Balancing scales, it updates the DNS record with the new list of IP addresses. To ensure that clients are taking advantage of the increased capacity, Elastic Load Balancing uses a TTL setting on the DNS record of 60 seconds. It is critical that you factor this changing DNS record into your tests. If you do not ensure that DNS is re-resolved or use multiple test clients to simulate increased load, the test may continue to hit a single IP address when Elastic Load Balancing has actually allocated many more IP addresses. Because your end users will not all be resolving to that single IP address, your test will not be a realistic sampling of real-world behavior.