Skip to content

Commit

Permalink
perf: ⚡️ reduce keepalive time
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria committed Mar 25, 2024
1 parent 6139e50 commit c847241
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
22 changes: 12 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ resource "helm_release" "nginx_ingress" {
version = "4.7.3"

values = [templatefile("${path.module}/templates/values.yaml.tpl", {
metrics_namespace = "ingress-controllers"
external_dns_annotation = local.external_dns_annotation
replica_count = var.replica_count
default_cert = var.default_cert
controller_name = var.controller_name
controller_value = "k8s.io/ingress-${var.controller_name}"
enable_modsec = var.enable_modsec
enable_latest_tls = var.enable_latest_tls
enable_owasp = var.enable_owasp
keepalive = var.keepalive
metrics_namespace = "ingress-controllers"
external_dns_annotation = local.external_dns_annotation
replica_count = var.replica_count
default_cert = var.default_cert
controller_name = var.controller_name
controller_value = "k8s.io/ingress-${var.controller_name}"
enable_modsec = var.enable_modsec
enable_latest_tls = var.enable_latest_tls
enable_owasp = var.enable_owasp
keepalive = var.keepalive
# https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#upstream-keepalive-time
upstream_keepalive_time = var.upstream_keepalive_time
proxy_response_buffering = var.proxy_response_buffering
default = var.controller_name == "default" ? true : false
name_override = "ingress-${var.controller_name}"
Expand Down
1 change: 1 addition & 0 deletions templates/values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ controller:
proxy-body-size: "50m"
keepalive: ${keepalive}
proxy-buffering: "${proxy_response_buffering}"
upstream-keepalive-time: "${upstream_keepalive_time}"

%{ if enable_latest_tls }
ssl-protocols: "TLSv1.2 TLSv1.3"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ variable "keepalive" {
default = 320
}

variable "upstream_keepalive_time" {
description = "Limits the maximum time during which requests can be processed through one keepalive connection. After this time is reached, the connection is closed following the subsequent request processing."
type = string
default = "1h"
}

variable "proxy_response_buffering" {
description = "nginx receives a response from the proxied server as soon as possible, saving it into the buffers set by the proxy_buffer_size and proxy_buffers directives. If the whole response does not fit into memory, a part of it can be saved to a temporary file on the disk. https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering"
type = string
Expand Down

0 comments on commit c847241

Please sign in to comment.