<p>I have just gotten into Kubernetes and really liking its ability to orchestrate containers. I had the assumption that when the app starts to grow, I can simply increase the replicas to handle the demand. However, now that I have run some benchmarking, the results confuse me.   </p>

<p>I am running <strong>Laravel 6.2 w/ Apache</strong> on <strong>GKE</strong> with a single <strong>g1-small</strong> machine as the node. I'm only using <code>NodePort</code> service to expose the app since <code>LoadBalancer</code> seems expensive. </p>

<p>The benchmarking tool used are <code>wrk</code> and <code>ab</code>. When the replicas is increased to 2, requests/s somehow drops. I would expect the requests/s to increase since there are 2 pods available to serve the request. Is there a bottleneck occurring somewhere or perhaps my understanding is flawed. Do hope someone can point out what I'm missing.</p>

daisura99
<p>A <a href="https://cloud.google.com/compute/docs/machine-types#n1_shared-core_machine_types" rel="nofollow noreferrer"><code>g1-small</code> instance</a> is really tiny: you get 50% utilization of a single core and 1.7 GB of RAM.  You don't describe what your application does or how you've profiled it, but if it's CPU-bound, then adding more replicas of the process won't help you at all; you're still limited by the amount of CPU that GCP gives you.  If you're hitting the memory limit of the instance that will dramatically reduce your performance, whether you swap or one of the replicas gets OOM-killed.</p>

<p>The other thing that can affect this benchmark is that, sometimes, for a limited time, you can be allowed to burst up to 100% CPU utilization.  So if you got an instance and ran the first benchmark, it might have used a burst period and seen higher performance, but then re-running the second benchmark on the same instance might not get to do that.</p>

<p>In short, you can't just crank up the replica count on a Deployment and expect better performance.  You need to identify where in the system the actual bottleneck is.  Monitoring tools like Prometheus that can report high-level statistics on per-pod CPU utilization can help.  In a typical database-backed Web application the database itself is the bottleneck, and there's nothing you can do about that at the Kubernetes level.</p>
