단순한 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에서 브라우저 요청, 명령줄 또는 모바일을 통한 컬 요청을 수행할 때 어떤 이유로 네트워크 성능이 엄청나게 느립니다. 일반적으로 약 10배가 될 때 약 200-300kb/s를 얻습니다. 저것.

VPS에서 컬을 통해 동일한 요청을 시도하면 속도가 훨씬 빨라집니다(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

관련 정보