Urgent.News

What's breaking now, across hundreds of outlets.

Tech

A 500m CPU limit turned 2,000 req/s into 70 % errors – measured on k3s

I moved a small URL shortener from three VMs onto a three-node k3s cluster and measured it with k6 before and after every change. One change looked harmless and wasn't: a CPU limit. The setup k3s, three nodes (one with 4 vCPUs, two with 2 vCPUs) a Go service with two replicas, PostgreSQL via CloudNativePG k6 with a constant arrival rate : 2,000 requests per second for 20 seconds, 90 % redirects,…

A small URL shortener deployed on a three-node k3s cluster experienced a significant degradation in performance when a CPU limit was introduced. The cluster consisted of one node with 4 vCPUs and two nodes with 2 vCPUs each. A Go service with two replicas and PostgreSQL via CloudNativePG was tested using k6 with a constant arrival rate of 2,000 requests per second for 20 seconds.

The results showed that a CPU limit of 500m caused 69-75% of requests to fail, while a limit of 250m caused only 0% failures. This discrepancy was attributed to the CFS throttling mechanism in the Linux kernel, which limits each container to 50 ms of CPU time per 100 ms window. When the CPU limit was reached, the container was no longer scheduled, causing requests to queue up and eventually fail due to a 2-second timeout.

To measure CPU throttling in your own cluster, you can use the kubelet to log CFS periods and throttled periods of containers named with a specific string. A Prometheus alert can be set up to monitor the ratio of throttled periods to total periods. It is recommended to set CPU limits based on measured bursts rather than averages, especially in multi-tenant clusters with guaranteed QoS.

The exact numbers may vary depending on the specific cluster and service, but the underlying mechanism remains the same.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

The 100 KB photo limit: why application forms ask for it, and how to hit it

Visa applications. Passport photos. A university portal. A job site. A marketplace listing. A government form that has been online since 2009.

  • The 100 KB limit balances upload costs and need for clear, legible prints.
  • Photo Size Reducer Android app compresses photos to meet size limits while preserving originals.

More from Thursday 26 November →