単純な haproxy TCP パススルーでは、ネットワーク転送速度が非常に遅くなります。

単純な haproxy TCP パススルーでは、ネットワーク転送速度が非常に遅くなります。

Debian 10 Buster のクリーン インストールで、シンプルな haproxy インスタンスをセットアップしました。問題の IP アドレスへのパススルーを有効にするために、いくつかの簡単な必要な構成を追加しました (以下の構成では編集されています)。

設定ファイル:

global
    log /dev/log    local0
    log /dev/log    local1 notice

    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL). This list is from:
    #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
    # An alternative list with additional directives can be obtained from
    #  https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
    ssl-default-bind-options no-sslv3

defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http


frontend myfrontend
  bind *:80
  mode tcp
  default_backend mybackendhttp

frontend myfrontendhttps
  bind *:443
  mode tcp
  use_backend mybackendhttps

backend mybackendhttp
  mode tcp
  option ssl-hello-chk
  server server1 ***********:80

backend mybackendhttps
  mode tcp
  option ssl-hello-chk
  server server1 ************:443

私が行った変更(元のファイルとの差分を取る場合)(IP は編集済み):

+
+
+frontend myfrontend
+  bind *:80
+  mode tcp
+  default_backend mybackendhttp
+
+frontend myfrontendhttps
+  bind *:443
+  mode tcp
+  use_backend mybackendhttps
+
+backend mybackendhttp
+  mode tcp
+  option ssl-hello-chk
+  server server1 ***********:80
+
+backend mybackendhttps
+  mode tcp
+  option ssl-hello-chk
+  server server1 **********:443

すべて正常に動作しますが、何らかの理由で、PC からブラウザー リクエスト、コマンド ラインまたはモバイル経由で curl リクエストを実行すると、ネットワーク パフォーマンスが非常に遅くなります。通常はその 10 倍程度の速度になるところ、約 200 ~ 300 kb/s しか得られません。

VPS 上で curl 経由で同じリクエストを実行すると、はるかに高速な速度 (5000kb/s) が得られます。

haproxy は GCP コンピューティング インスタンス VM 上で実行されているため、ネットワーク帯域幅の問題になるとは考えにくいですが、単純な静的 http サービスを設定して比較してみることはできます。

この問題の原因は何でしょうか? どうすれば診断できるでしょうか? haproxy でログを有効にすると、この問題についてより詳しく知ることができますか?

同様の動作を説明していると思われる次の質問に遭遇しました。

HAProxy SSL 応答が非常に遅い

OpenSSLライブラリでは、/etc/hostsにホスト名が適切に設定されている必要があります。

しかし、「適切に設定」が何を意味するのか私には分かりません。

答え1

十分なレピュテーションがないので回答します。

では/etc/hosts、次の行を見つけます:

127.0.0.1 localhost

localhosthaproxy.domain.com などの FQDN に置き換えます。サーバーのホスト名と同じである必要があります。

Debian では、次のコマンドでホスト名を設定できます。

hostname-ctl set-hostname haproxy.domain.com

関連情報