8

k8s中nginx ingress的性能优化

 3 years ago
source link: https://zhangrr.github.io/posts/20211102-ingress_nginx/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

kubernetes 中 nginx ingress 的优化分两部分

一、系统sysctl部分优化

首先是对nginx启动前的系统性能进行优化,这部分调整网络的缓冲区,减小闲置 socket 关闭的时间

以阿里 ACK 为例,我们可以编辑 deployments 的 nginx-ingress-controller

      initContainers:
      - command:
        - /bin/sh
        - -c
        - |
          mount -o remount rw /proc/sys
          sysctl -w net.core.somaxconn=65535
          sysctl -w net.ipv4.ip_local_port_range="1024 65535"
          sysctl -w net.ipv4.tcp_tw_reuse=1
          sysctl -w fs.file-max=1048576
          sysctl -w net.ipv4.tcp_keepalive_time = 300
          sysctl -w net.ipv4.tcp_keepalive_probes = 5
          sysctl -w net.ipv4.tcp_keepalive_intvl = 15
          

二、nginx ingress 参数优化

大家制动,nginx ingree 其实是做为一个中间代理,所以上下游的socket参数也需要优化

同样以阿里ACK为例,我们可以编辑 configmaps 的 nginx-configuration

apiVersion: v1
data:
  allow-backend-server-header: "true"
  enable-underscores-in-headers: "true"
  generate-request-id: "true"
  ignore-invalid-headers: "true"
  log-format-upstream: $remote_addr - [$remote_addr] - $remote_user [$time_local]
    "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length
    $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length
    $upstream_response_time $upstream_status $req_id $host [$proxy_alternative_upstream_name]
  proxy-body-size: 20m
  proxy-connect-timeout: "10"
  reuse-port: "true"
  server-tokens: "false"
  ssl-redirect: "false"

  upstream-keepalive-timeout: "900"
  keep-alive-requests: "10000"
  upstream-keepalive-connections: "500"
  max-worker-connections: "65536"

  worker-cpu-affinity: auto
kind: ConfigMap

Recommend

  • 16
    • www.jianshu.com 3 years ago
    • Cache

    使用ingress-nginx访问k8s内服务

    使用ingress-nginx访问k8s内服务bin_x0.0772020.09.09 01:35:49字数 807阅读 2,009在撘完kubernetes后,外部流量无法访问内部的服务。...

  • 8
    • www.v2ex.com 3 years ago
    • Cache

    k8s 使用 ingress 接口卡住

    k8s 使用 ingress 接口卡住 V2EX  ›  Kubernetes k8s 使用 ingress 接口卡住  

  • 5
    • www.cnblogs.com 3 years ago
    • Cache

    k8s~云负载转发ingress解析

    k8s~云负载转发ingress解析 - 张占岭 - 博客园 敢于对过去告一个段落,才有信心掀开新的篇章! 关注:架构设计、领域驱动、统一认证、微服务、分布式、容器编排、持续集成、自动化测试、设计模...

  • 11
    • www.cnblogs.com 3 years ago
    • Cache

    k8s入门之Ingress(七) - 景少

    k8s入门之Ingress(七) Ingress 的功能其实很容易理解:所谓 Ingress,就是 Service 的“Ser...

  • 5

    k8s部署-43-带你深入学习ingress-nginx(下)_12376780的技术博客_51CTO博客很多情况下,nginx会代理https协议,那么我们的ingress-nginx是如何实现这个功能呢,下面看看。我这里没有https证书,所以需要自己生成https证书;

  • 16
    • www.dosk.win 2 years ago
    • Cache

    适用于 k8s 的 frpc ingress 实现

    Usage 我建立了一个 helm repo 用来快速部署,步骤如下 helm repo add infinity-server https://infinity-s...

  • 13
    • www.cnblogs.com 2 years ago
    • Cache

    k8s~ingress限流机制

    Ingress限流 限速的注解定义了对连接和传输速率的限制。这些可以用来减轻DDoS攻击。它采用了 “漏斗” 算法实现限制。

  • 4
    • www.cnblogs.com 2 years ago
    • Cache

    k8s~ingress设置文件传输大小限制

    k8s~ingress设置文件传输大小限制 默认情况下,ingress(ng...

  • 4

    问题的产生 对于我们的容器化部署项目keycloak来说,当它从云端负载均衡LB直接通过 NodePort转发到keycloak时,没有任务问题,一切正常;缺点就是,运维人员要维护一大批端口,哪个端口对应哪个服务,非常容易出乱子。

  • 6
    • www.cnblogs.com 2 years ago
    • Cache

    K8S对外服务之Ingress - 龙Llong

    一、Ingress 简介 service的作用体现在两个方面,对集群内部,它不断跟踪pod的变化,更新endpoint(端点)中对应pod的对象,提供了ip不断变化的pod的服务发现机制;对集群外部,他类似负载均衡器,可以在集群内外部对pod进行访问。 ...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK