I am using the "nginx-ingress-controller" to use 'active connections' metrics in my HPA. But Nginx ingress is creating few connections to handle a large number of users. I am new to Nginx ingress so I don't know if it is expected behavior. I was expecting that 'active connections' should close to the number of concurrent users. Now due to less connection, my application is not scaling.
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: ggs-hpa
spec:
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metricName: custom.googleapis.com|nginx-ingress-controller|nginx_connnections
targetAverageValue: 6
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ggs
I am using JMeter to create these users and my deployment is on the GKE cluster. I am using the default setting of 'nginx-ingress-controller', no customizations in Nginx config.
Can someone please help me to understand this behavior of connections? Thank you.
Sorry I missed to post the solution of the issue. I was not using 'nodeSelector' so nginx pod's node was having multiple pods and these pods were also required high number of connection and a node is having limited number of connections and ports (even after increasing it by tweaking linux settings).
Solution: So I created labels for nodes and using these labels in my nodeSelector to control the deployment of application. Labels I created -
Now everything is working fine.