Comparing App Gateway v.s. Ngnix Ingress Controller for Latency in AKS
Introduction
In this article, we’re going to look at latency when comparing Application Gateway and Nginx Ingress Controller for our Ingress Option in our AKS Cluster.
Simple Architecture
The architecture this time is similar to the previous article https://adrianhynes.medium.com/07-12-20-exposing-your-aks-workloads-using-external-dns-and-app-gateway-28a7569cf272 on Nginx Ingress Controller, App Gateway and External DNS, except this time we’re deploying 3 nodes into the cluster.
The sample application this time is based on the kubernetes HPA example (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/), so we have a relatively “real” application load running.
Limitations
- no SSL/TLS Cert Termination is performed
- 60 request over 60 seconds does not take into account the performance capabilities of App gateway v.s. Nginx Ingress Controller
- The cluster will consist of 3 nodes which would not replicate a production grade cluster in many cases
- One 1 Thread (User) in JMeter was used to perform requests
Steps
Azure Resources and Bootstrapping
Follow the last article to install App Gateway Ingress Controller https://adrianhynes.medium.com/07-12-20-exposing-your-aks-workloads-using-external-dns-and-app-gateway-28a7569cf272. Follow this article to install Nginx Ingress Controller and External DNS https://adrianhynes.medium.com/exposing-your-aks-workloads-using-external-dns-and-nginx-ingress-controller-434482ea153b
Sample Applications
Apply the following Ingress, Service and Deployment manifests. One Ingress will be picked up by Nginx and the other by App Gateway. The target application running will be the same but over different deployments.
#example.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-helloworld-one
spec:
replicas: 1
selector:
matchLabels:
app: aks-helloworld-one
template:
metadata:
labels:
app: aks-helloworld-one
spec:
containers:
- name: aks-helloworld-one
#image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
image: k8s.gcr.io/hpa-example
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: aks-helloworld-one
spec:
ports:
- protocol: TCP
port: 80
targetPort: 80
selector:
app: aks-helloworld-one
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: aks-helloworld-one
annotations:
kubernetes.io/ingress.class: azure/application-gateway
spec:
rules:
- host: aido.hynes.pri
http:
paths:
- backend:
serviceName: aks-helloworld-one
servicePort: 80
path: /#example.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: aks-helloworld-two
spec:
replicas: 1
selector:
matchLabels:
app: aks-helloworld-two
template:
metadata:
labels:
app: aks-helloworld-two
spec:
containers:
- name: aks-helloworld-two
#image: mcr.microsoft.com/azuredocs/aks-helloworld:v1
image: k8s.gcr.io/hpa-example
ports:
- containerPort: 80
---apiVersion: v1
kind: Service
metadata:
name: aks-helloworld-two
spec:
ports:
- protocol: TCP
port: 80
targetPort: 80
selector:
app: aks-helloworld-two---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: aks-helloworld-two
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: bido.hynes.pri
http:
paths:
- backend:
serviceName: aks-helloworld-two
servicePort: 80
path: /(.*)
Testing Setup
Connect to the Windows VM and install the following:
- Firefox — Required to be able to download the Java JDK
- JDK — Required by JMeter
- JMeter — For our performance tests
Next we’ll setup JMeter Latency Tests, by creating a Thread group, where we’ll leave the Number of Users at 1, and we’ll set the Loop Count to 60.
Inside the Thread Group we’ll create a
- Constant Timer to delay the time between requests to 1 second
- HTTP Request where we’ll put out URL http://aido.hynes.pri/
- Aggregate Report — to aggregate all the values for the 60 requests we’ll make over 60 seconds
- View Results Tree — to allow us to investigate each request
We’ll run the JMeter Test and record the results. Next we’ll repeat the same for http://bido.hynes.pri/ and record the results
Conclusion
I was expecting App Gateway to out perform Nginx Ingress Controller, considering the less hops that the request would take for App Gateway.
As you can see below, the min response time for both comes in at 85ms and the max for Nginx comes in at 109, slightly higher than App Gateway’s 104.
The average puts App Gateway at 88ms, slightly better than that of Nginx which comes in at 90.
Please take this article as informational only and perform your own tests in your own environment with your own workloads to get a better gauge on which is best for you.
Thanks for taking the time to read.