ELB for Envoy の IP 1 つあたりの帯域と同時接続数を測ってみた

ELB for Envoy の IP 1 つあたりの帯域と同時接続数を測ってみた

Elastic Load Balancing (ELB) for Envoy 経由で Nginx の HTTP 配信性能を m9g.2xlarge で測ると、IP 1 つあたり約 12 Gbps、20,000 の同時接続も可能でした。負荷をかけ始めて約 1 分 15 秒後に IP が追加されました。
2026.11.28

はじめに

2026年11月25日に、Elastic Load Balancing (ELB) for Envoy が一般提供になりました。

https://aws.amazon.com/about-aws/whats-new/2026/11/elastic-load-balancing-for-envoy-generally-available/

ELB for Envoy は、オープンソースの Envoy プロキシを動かすロードバランサーです。この記事では、プロキシの IP 1 つあたりの帯域と同時接続数、負荷をかけたときの IP の増え方を測りました。

検証環境

  • リージョン: 東京(ap-northeast-1)
  • 測定の経路: 同一 AZ 内で完結(クライアント → 同じ AZ のプロキシの IP → オリジン)

ELB for Envoy

  • Envoy のバージョン(proxyVersion): 1.40
  • IPv4: internal
  • サブネット: 1a と 1c
  • リスナー: HTTP の 80 番と 81 番(1a のオリジンへ)、82 番(1c のオリジンへ)
  • クラスター: STATIC
  • その他の設定: 既定値

EC2(オリジン)

  • インスタンスタイプ: m9g.2xlarge(8 vCPU、メモリ 32 GiB、arm64)。ネットワーク帯域はベースライン 4.25 Gbps、ピーク 17 Gbps
  • 台数: 1a に 1 台。1c にも測定用に 1 台
  • AMI: Amazon Linux 2023(arm64)
  • 接続: パブリック IP あり、操作は SSM 経由
  • Web サーバー: nginx 1.30.7(/etc/nginx/nginx.conf を下の内容に置き換えた)
  • 配信するファイル: 2 つ。/10m.bin は 10,485,760 バイト(10MB)で /dev/urandom の出力、/1k.txt は 1,024 バイトで乱数の base64 文字列。どちらも /srv/www に置き、ページキャッシュに載せた
オリジンの nginx.conf と配信ファイルの作成

ファイルの作成(/srv/www):

mkdir -p /srv/www
head -c 10485760 /dev/urandom > /srv/www/10m.bin
head -c 768 /dev/urandom | base64 -w0 | head -c 1024 > /srv/www/1k.txt
cat /srv/www/10m.bin > /dev/null
chmod -R a+rX /srv/www

/etc/nginx/nginx.conf:

user nginx;
worker_processes auto;
pid /run/nginx.pid;
events { worker_connections 65535; use epoll; }
http {
  access_log off;
  sendfile on;
  tcp_nopush on;
  keepalive_timeout 75;
  keepalive_requests 1000000;
  server {
    listen 80 default_server;
    root /srv/www;
  }
}

EC2(クライアント)

  • インスタンスタイプ: m9g.2xlarge(オリジンと同じ)
  • 台数: 1a に 1 台。1c にも測定用に 1 台
  • AMI: Amazon Linux 2023(arm64)
  • 接続: パブリック IP あり、操作は SSM 経由
  • 負荷ツール: wrk 4.2.0

検証方法

プロキシの作成は、先行記事と同じ手順です。

https://dev.classmethod.jp/articles/aws-elb-for-envoy-ga-create-proxy/

プロキシの作成

プロキシの作成コマンドと設定ファイル

create-proxy-input.json と config-tp.yaml をカレントディレクトリに置いて、次のコマンドを実行しました。

aws elb-proxy create-proxy --cli-input-json file://create-proxy-input.json --cli-binary-format raw-in-base64-out --configuration configurationFile=\{configurationBytes@=file://config-tp.yaml\} --output json

create-proxy-input.json

{
  "name": "elbproxy-tp",
  "type": "envoy",
  "proxyVersion": "1.40",
  "roleArn": "<role-arn>",
  "networkConfiguration": {
    "ipConfiguration": {
      "ipAddressingConfiguration": { "ipv4Addressability": "internal", "ipv6Addressability": "off" }
    },
    "vpcConfiguration": {
      "subnets": [ { "subnetId": "<subnet-1a-id>" }, { "subnetId": "<subnet-1c-id>" } ],
      "securityGroups": [ { "securityGroupId": "<proxy-sg-id>" } ]
    }
  }
}

config-tp.yaml

admin:
  address:
    socket_address:
      address: 127.0.0.1
      port_value: 9901
static_resources:
  listeners:
  - name: l80
    address: { socket_address: { address: 0.0.0.0, port_value: 80 } }
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: l80
          route_config:
            name: r80
            virtual_hosts:
            - name: all
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: origin_a }
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  - name: l81
    address: { socket_address: { address: 0.0.0.0, port_value: 81 } }
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: l81
          route_config:
            name: r81
            virtual_hosts:
            - name: all
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: origin_a }
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  - name: l82
    address: { socket_address: { address: 0.0.0.0, port_value: 82 } }
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: l82
          route_config:
            name: r82
            virtual_hosts:
            - name: all
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: origin_c }
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: origin_a
    type: STATIC
    connect_timeout: 5s
    load_assignment:
      cluster_name: origin_a
      endpoints:
      - lb_endpoints:
        - endpoint: { address: { socket_address: { address: <origin-a-ip>, port_value: 80 } } }
  - name: origin_c
    type: STATIC
    connect_timeout: 5s
    load_assignment:
      cluster_name: origin_c
      endpoints:
      - lb_endpoints:
        - endpoint: { address: { socket_address: { address: <origin-c-ip>, port_value: 80 } } }

IP の固定と観察

作成直後に DNS が返した IP(1a と 1c に 1 つずつ)を「元の IP」と呼びます。帯域と同時接続数の測定では、1a の元の IP を指定して接続しました。

dig で、DNS が返す IP を取得します。

dig +short A <プロキシの DNS 名>

インスタンスにアタッチされていない ENI(プロキシの ENI)の IP、状態、AZ を取得します。

aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=<vpc-id> --query 'NetworkInterfaces[?Attachment.InstanceId==null].join(`/`,[PrivateIpAddress,NetworkInterfaceId,Status,AvailabilityZone])' --output text

この 2 つのコマンドを 10 秒ごとに実行しました。

帯域の測定

クライアントの EC2 と同じ AZ にあるプロキシの IP を指定して、次の形で wrk を実行しました。

wrk -t<並列度と 4 の小さい方> -c<並列度> -d15s --timeout 30s --latency -s report.lua http://<IP>/10m.bin

帯域(Gbps)は、wrk が数えた受信バイト数(ヘッダー込み)× 8 ÷ 実行時間です。完了時間は、10MB のファイルを 1 本受け取るのにかかった時間の p50 と p99 です。1 回の測定は 15 秒で、測定と測定の間は 5 秒空けました。

CloudWatch の AWS/ProxyELB には帯域のメトリクスがないため、帯域はクライアントの wrk で測りました。

bench.sh と report.lua

bench.sh

#!/bin/bash
# usage: bench.sh <label> <url> <conns> [secs]   クライアント EC2 の /usr/local/bin/bench.sh
label=$1; url=$2; c=$3; d=${4:-15}
t=$(( c < 4 ? c : 4 ))
ulimit -n 1048576 2>/dev/null
echo "=== label=$label url=$url conns=$c threads=$t secs=$d start=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
/usr/local/bin/wrk -t$t -c$c -d${d}s --timeout 30s --latency -s /usr/local/bin/report.lua "$url"
echo "=== end=$(date -u +%Y-%m-%dT%H:%M:%SZ) label=$label"

report.lua

done = function(summary, latency, requests)
  io.write(string.format("RESULT bytes=%d duration_us=%d requests=%d gbps=%.3f err_connect=%d err_read=%d err_write=%d err_status=%d err_timeout=%d p50_us=%d p90_us=%d p99_us=%d max_us=%d\n",
    summary.bytes, summary.duration, summary.requests, summary.bytes * 8 / (summary.duration / 1e6) / 1e9,
    summary.errors.connect, summary.errors.read, summary.errors.write, summary.errors.status, summary.errors.timeout,
    latency:percentile(50), latency:percentile(90), latency:percentile(99), latency.max))
end

同時接続数の測定

各接続で 1KB のファイルを keep-alive の GET で 1 回取得し、応答を受け取った後はアイドルのまま保持しました。

接続は 1a の元の IP の 80 番と 81 番へ半数ずつ張りました。条件は次のとおりです。

  • 段階: 5,000、10,000、20,000、30,000、50,000。各段階で 120 秒保持
  • 新規接続の速度: 0.1 秒ごとに 100 件(1,000 件/秒以下)
  • 保持中の計測: 別の接続で 1KB の GET を 0.1 秒ごとに送って往復時間を測り、保持の終了 20 秒前に別の接続で 10MB のファイルを並列 1 で 1 回取得する
  • 停止条件: 新規接続の失敗、保持中の接続の切断、200 以外の応答、計測用の GET の失敗。また、新規接続の確立時間の p99 または 1KB GET の往復時間の p99 が 5,000 の段階の値の 3 倍を超えたとき
hold.py
#!/usr/bin/env python3
"""プロキシの 1 つの IP へ keep-alive の GET を 1 回送ってアイドルで保持し、段階的に接続数を増やす。
usage: hold.py <proxy-ip>
- 接続は IP の 80 番と 81 番へ交互に張る。各接続で、完結した keep-alive の GET(1KB)を 1 回送り、応答後はアイドルで保持する(HOLD_MODE=get。byte は先頭 1 バイトだけ、none は何も送らない)
- 新規接続の速度は 1,000 件/秒以下(0.1 秒ごとに 100 件)
- 各段階で 120 秒保持。保持中、別の接続で 1KB の GET を 0.1 秒ごとに送り、往復時間を記録する
- 各段階の保持の終了 20 秒前(既定 100 秒目)に、別の接続で 10MB の GET を 1 回行う(並列度 1)
- 停止条件: 新規接続の失敗 1 件 / 200 以外の応答 / 保持中の接続の切断 / 確立時間 p99 が最初の段階の 3 倍超 / 1KB GET の往復 p99 が最初の段階の 3 倍超 / プローブの失敗
"""
import asyncio, time, json, sys, resource, errno, math, os

IP = sys.argv[1]
PORTS = [80, 81]
STAGES = json.loads(os.environ.get('HOLD_STAGES', '[5000, 10000, 20000, 30000, 50000]'))
HOLD = int(os.environ.get('HOLD_SECS', '120'))
MODE = os.environ.get('HOLD_MODE', 'get')   # get | byte | none
REQ = b'GET /1k.txt HTTP/1.1\r\nHost: x\r\n\r\n'
BATCH = 100          # 0.1 秒あたりの新規接続数(= 1,000 件/秒)
CLIENT_SIDE = {errno.EMFILE, errno.ENFILE, errno.EADDRNOTAVAIL, errno.ENOBUFS, errno.ENOMEM}

soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
resource.setrlimit(resource.RLIMIT_NOFILE, (min(hard, 200000), hard))

LOG = open(os.environ.get('HOLD_LOG', '/var/tmp/hold.log'), 'a', buffering=1)
def log(**kw):
    kw = {'ts': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()), **kw}
    LOG.write(json.dumps(kw) + '\n')

def pct(a, p):
    if not a:
        return None
    a = sorted(a)
    return round(a[max(0, math.ceil(p / 100 * len(a)) - 1)] * 1000, 2)  # ms

writers, watchers = [], []
dropped, fails, probe_fails, bad_status = [], [], [], []
stage_conn, probe_conn, probe_rtt = [], [], []
state = {'probing': True}

async def watch(reader, idx):
    try:
        first = True
        while True:
            d = await reader.read(65536)
            if d == b'':
                dropped.append(('eof', idx, time.strftime('%H:%M:%SZ', time.gmtime())))
                return
            if first and MODE == 'get':
                first = False
                if not d.startswith(b'HTTP/1.1 200'):
                    bad_status.append((d[:40].decode('latin1'), idx))
    except Exception as e:
        dropped.append((type(e).__name__, idx, time.strftime('%H:%M:%SZ', time.gmtime())))

def classify(e):
    if isinstance(e, asyncio.TimeoutError):
        return 'timeout', False
    if isinstance(e, OSError):
        return errno.errorcode.get(e.errno, str(e.errno)), e.errno in CLIENT_SIDE
    return type(e).__name__, False

async def open_one(port):
    t0 = time.monotonic()
    try:
        r, w = await asyncio.wait_for(asyncio.open_connection(IP, port), 5)
    except Exception as e:
        kind, client = classify(e)
        fails.append((kind, 'client' if client else 'server-or-network', port))
        return
    stage_conn.append(time.monotonic() - t0)
    if MODE == 'get':
        w.write(REQ)    # 完結した keep-alive の GET を 1 回送り、応答後はアイドルで保持する
    elif MODE == 'byte':
        w.write(b'G')   # リクエスト行の先頭 1 バイトだけ(リクエストは完結させない)
    writers.append(w)
    watchers.append(asyncio.create_task(watch(r, len(writers))))

async def http_get(path):
    t0 = time.monotonic()
    r, w = await asyncio.wait_for(asyncio.open_connection(IP, 80), 5)
    t1 = time.monotonic()
    w.write(f'GET {path} HTTP/1.1\r\nHost: x\r\nConnection: close\r\n\r\n'.encode())
    n = 0
    while True:
        d = await asyncio.wait_for(r.read(1 << 20), 30)
        if not d:
            break
        n += len(d)
    t2 = time.monotonic()
    w.close()
    return t1 - t0, t2 - t0, n

async def prober():
    while state['probing']:
        try:
            c, total, n = await http_get('/1k.txt')
            probe_conn.append(c); probe_rtt.append(total)
        except Exception as e:
            probe_fails.append(classify(e)[0])
        await asyncio.sleep(0.1)

async def main():
    log(event='start', ip=IP, ports=PORTS, stages=STAGES, hold_s=HOLD, nofile_soft=min(hard, 200000))
    probe_task = asyncio.create_task(prober())
    base = None
    prev = None
    for N in STAGES:
        stage_conn.clear(); probe_conn.clear(); probe_rtt.clear()
        t_start = time.monotonic()
        i = 0
        while len(writers) + len(fails) < N and not fails:
            b0 = time.monotonic()
            k = min(BATCH, N - len(writers))
            await asyncio.gather(*[open_one(PORTS[(len(writers) + j) % 2]) for j in range(k)])
            await asyncio.sleep(max(0, 0.1 - (time.monotonic() - b0)))
        ramp_s = time.monotonic() - t_start
        log(event='ramp_done', stage=N, established=len(writers), fails=len(fails), ramp_s=round(ramp_s, 1))
        big = None
        t_hold = time.monotonic()
        while time.monotonic() - t_hold < HOLD and not (fails or dropped or probe_fails or bad_status):
            await asyncio.sleep(1)
            if big is None and time.monotonic() - t_hold >= HOLD - 20:
                try:
                    c, total, n = await http_get('/10m.bin')
                    big = {'bytes': n, 'seconds': round(total, 4)}
                except Exception as e:
                    probe_fails.append('big:' + classify(e)[0])
        summ = dict(event='stage', stage=N, established=len(writers), fails=len(fails), fail_kinds=sorted(set(f[:2] for f in fails)),
                    dropped=len(dropped), probe_fails=len(probe_fails), bad_status=len(bad_status),
                    conn_ms_p50=pct(stage_conn, 50), conn_ms_p99=pct(stage_conn, 99), conn_n=len(stage_conn),
                    probe_conn_ms_p50=pct(probe_conn, 50), probe_conn_ms_p99=pct(probe_conn, 99),
                    probe_rtt_ms_p50=pct(probe_rtt, 50), probe_rtt_ms_p99=pct(probe_rtt, 99), probe_n=len(probe_rtt),
                    big_10mb=big)
        log(**summ)
        stop = None
        if fails:
            stop = 'connect-failure'
        elif bad_status:
            stop = 'bad-status'
        elif dropped:
            stop = 'held-connection-dropped'
        elif probe_fails:
            stop = 'probe-failure'
        elif base is None:
            base = {'conn': summ['conn_ms_p99'], 'rtt': summ['probe_rtt_ms_p99']}
            log(event='baseline', **base)
        else:
            if summ['conn_ms_p99'] and summ['conn_ms_p99'] > 3 * base['conn']:
                stop = 'connect-p99-over-3x'
            elif summ['probe_rtt_ms_p99'] and summ['probe_rtt_ms_p99'] > 3 * base['rtt']:
                stop = 'probe-rtt-p99-over-3x'
        if stop:
            log(event='stop', reason=stop, stage=N, previous=prev, fails=fails[:20], dropped=dropped[:20], bad_status=bad_status[:20], probe_fails=probe_fails[:20])
            break
        prev = summ
    state['probing'] = False
    await asyncio.sleep(0.5)
    log(event='release', closing=len(writers))
    for w in writers:
        w.close()
    await asyncio.sleep(2)
    log(event='done')

asyncio.run(main())

測定結果

EC2 同士の帯域

1a のクライアントから 1a のオリジンへ、プロキシを介さずに直接接続して測りました。

並列度 Gbps(3 回) 10MB の完了時間 p50(ms、3 回)
1 9.53、9.53、9.53 8.9、8.9、8.8
4 16.89、16.88、16.89 15.4、15.2、19.8
8 16.89、16.89、16.89 30.2、30.3、30.3
16 16.89、16.89、16.89 84.7、64.9、55.4

並列 4 以上では、m9g.2xlarge のピーク 17 Gbps に近い約 16.9 Gbps で一定でした。プロキシ経由の測定の後に測った並列 2 は 16.89、16.83 Gbps、並列 4 は 16.84、16.89 Gbps で、約 16.9 Gbps のまま変わりませんでした。

プロキシの IP 1 つあたりの帯域

プロキシの 1a の元の IP を指定して接続し、同じ条件で測りました。

並列度 Gbps(2 回) 10MB の完了時間 p50(ms) p99(ms)
1 4.96、4.95 16.9、16.9 17.1、17.0
2 9.86、9.86 16.9、17.0 17.5、17.7
4 12.17、11.83 24.1、22.9 221.0、260.0
8 12.17、12.22 46.4、47.3 296.3、277.8

並列 1 は EC2 同士の約半分でした。並列 4 と 8 は約 12 Gbps で頭打ちになり、EC2 同士(約 16.9 Gbps)の約 7 割でした。

IP の増加と新しい IP の帯域

プロキシが active になってから 20〜40 秒後の記録では、DNS が返した IP は 1a と 1c に 1 つずつの計 2 つで、プロキシが管理する ENI も 2 つでした。

時刻 出来事
02:43:04 プロキシの作成を開始
02:45:58 active を確認
02:46:35〜02:52:02 ENI は 2 つ。この間のプロキシ経由の通信は、02:46:52 の 3 秒間の動作確認だけ
02:52:02 1a の元の IP への帯域測定(並列 1、2、4、8 を 2 巡)を開始。1c の IP には負荷をかけていない
02:53:17 1c の新しい ENI が available で現れる(1 巡目の並列 8 の測定中)。約 10 秒後に in-use
02:53:38 1a の新しい ENI が available で現れる。約 10 秒後に in-use
02:54:36 DNS が 1a と 1c の IP を 2 つずつ、計 4 つ返す
03:09 以降 同時接続数の試験。ENI は 03:19 まで 4 つのまま

元の IP は、増加後も DNS の応答に残りました。

新しい IP と元の IP を交互に、15 秒ずつ測りました。1c の測定には、1c の EC2 と 82 番のリスナーを使いました。

AZ 並列度 新しい IP の Gbps 元の IP の Gbps
1a 1 4.96 4.95
1a 8 12.03、12.10 12.21、12.20
1c 1 4.96 4.96
1c 8 12.01、12.07 12.17、12.08

新しい IP と元の IP の性能は同程度でした。

同時接続数

IP が 4 つに増えた後、1a の元の IP で keep-alive のアイドル接続を保持しました。保持の間、ENI は 4 つのままでした。

接続数 確立 失敗 切断 新規接続の確立時間 p50(ms) 新規接続の確立時間 p99(ms) 別の接続の 1KB GET の往復 p99(ms)
5,000 5,000 0 0 5.61 21.97 1.19
10,000 10,000 0 0 5.45 38.56 1.16
20,000 20,000 0 0 5.43 83.51 1.23

表の確立時間は、クライアント(hold.py)で測りました。20,000 の段階で接続確立の p99 に軽度の遅延が見られたため、ここで測定を終えました。

保持中に別の接続で測った値は、段階を通じて同程度でした。

  • 1KB の GET(毎回新しく接続): 接続確立時間の p99 は 0.34〜0.36 ms
  • 10MB の転送(並列 1): 16.7、17.1、16.9 ms(保持していないときは 16.9 ms)

まとめ

今回の測定では、IP 1 つあたり約 12 Gbps の帯域が出ることと、1 万以上の同時接続を保持できることを確認できました。

負荷をかけ始めて約 1 分 15 秒後に、IP が AZ ごとに 1 つから 2 つへ増えました。増えた IP の帯域は元の IP と同程度で、プロキシ全体の帯域は 2 倍になる計算です。

ALB と異なり、ELB for Envoy には LCU を事前に確保する API がありません。大きなスパイクアクセスが見込まれる場合は、スパイクを再現する負荷テストを事前に実施し、性能限界を示すメトリクスを見極めてください。必要に応じて、スパイクの前に負荷をかけておく暖気運転をおすすめします。

この記事をシェアする

AWSのお困り事はクラスメソッドへ

関連記事