The Kubernetes Native Gateway Series (Part 1): Envoy at Scale
Time to get things scaling properly.
Join the DZone community and get the full member experience.Join For Free
Gloo Edge is our Kubernetes native API gateway based on Envoy.
It provides Authentication (OAuth, JWT, API keys, JWT, …), Authorization (OPA, custom, …), Web Application Firewall (based on ModSecurity), function discovery (OpenAPI based, Lambda, …), advanced transformations, and much more.
One of the first questions our customers are generally asking us is how many instances of Envoy (the
gateway-proxy Pod in Gloo Edge) are needed for their use case.
We generally answer that they need 2 instances to get High Availability, but that’s very rare that someone needs to deploy more instances for performance reasons.
In this blog post series, I’m going to perform benchmarks to provide more accurate data.
I’ll start in this Blog post by benchmarking Gloo Edge without any filter (basic HTTP requests).
In the next post, I’ll show the impact of enabling different security features (HTTPS, JWT, API keys, WAF, …).
Finally, I’ll write a blog post about benchmarking Web Assembly (WASM).
To perform my tests, I decided to deploy KinD in a VirtualMachine on GCP. I know that the CPU should be a bottleneck, so I decided to use a `n1-highcpu-96` instance type. You can find more information about this instance type in the table below:
I’ve deployed a Kubernetes cluster on this VM and Gloo Edge on this cluster.
I decided to use only one Envoy instance and to scale it only if I wasn’t able to use all the CPUs.
I did my first tests using the httpbin Docker image for the backend (Upstreams) and was getting some 5xx errors (between 0.1 and 0.2%) and after some investigations I found that the errors were caused by the
httpbin Pods. Scaling the number of Pods didn’t have any effect.
echoenv as follow:
And I scaled it to 20 replicas. Even if I could probably have used fewer replicas without impacting the results.
To expose it using Gloo, I created the following
Finally, I needed a benchmarking tool and I opted for Apache JMeter. One could argue that there more Kubernetes native and sexy tools, but I knew this one would scale for sure.
I deployed a JMeter server and 8 JMeter clients (remote nodes) on my Kubernetes cluster.
Here is the test plan I used:
As you can see, I’ve configured the test plan to send `GET` requests to `http://gateway-proxy.gloo-system.svc.cluster.local`.
1 Billion Requests in a Little Bit More Than 3h!
The first test I performed was without setting any CPU and Memory limits.
As you can see, the average throughput was higher than 85,000 RPS (Requests Per Second).
Note that I was originally using the
-l option of the
jmeter.sh script to store on disk information about the test but it was slowing down the test after a few minutes. So, I removed this option and used the stats generated by Envoy and stored in Prometheus.
First of all, this number is amazing. It means that Gloo Edge can handle more than 7 billion requests per day. And with a single instance!
The other useful information is its ability to use most of the CPU available in the machine.
You can see that the average utilization of the 96 CPUs is higher than 85%.
And if I look at the Kubernetes metrics, I can see that Envoy is using half of it, while the remaining is used by the JMeter components and the Upstreams.
I’ve also tried running 2 instances of the
gateway-proxy (Envoy) Pod (which is the common deployment pattern) and I was getting the same results, with half of the requests processed by each instance.
What About Standard Environments?
Most of our customers are deploying Gloo Edge in Kubernetes clusters that are composed of smaller machines.
So, I decided to run the benchmark several times with different CPU limits set on the
As you can see, it scales linearly, so it’s very easy to predict what performance you’ll get based on the number of CPUs, you’ll allocate to it.
I was able to get a little bit more than 2000 RPS per CPU, which means around 175 million requests a day!
What about memory usage?
I didn’t speak much about the quantity of memory used during my tests because it was really low. The
gateway-proxy Pod never used more than half a GB of RAM.
Gloo Edge takes full advantage of Envoy to deliver incredible performance. I didn’t have to tweak a single parameter of Gloo Edge to get these numbers. And I didn’t get a single error during all these tests. It’s really easy to size Gloo Edge according to your needs.
In my next blog post, I’ll measure the impact of implementing different security features of Gloo Edge.
Opinions expressed by DZone contributors are their own.