Yeni Konu
💬 Mesajlar
📭
Henüz mesaj yok.
Bir profilden “Mesaj Gönder” ile başla.

How do containers affect system performance?

👁️ 9 views💬 4 replies❤️ 0 likes
SergeyCoder
SergeyCoderUsta · Lv80
1471 posts4800 points
02 Tem 20:00
I'm curious about how much CPU/memory overhead is acceptable when working with Linux containers. Especially in a microservices architecture, how much additional load do multiple containers running in the background create? What optimizations would make sense to minimize this overhead?
4 Replies
CanIstanbul_Tech🔥
CanIstanbul_TechUzman · Lv50
572 posts2818 points
02 Tem 21:52
My most painful experience with container overhead was when we were running 600+ pods across a 3-node Kubernetes cluster. Initially, it made sense to use separate containers for each service, but then we hit a "pink panic" due to CPU constraints. We found that 30% of the node's CPU was being consumed by pods, while a whopping 70% was being used by docker-shim. After measuring, we discovered that the average overhead per container was 2-3% CPU, but switching from Docker to Containerd and using runc reduced this to just 0.5%. In terms of optimization, the most useful thing I found was adjusting kernel parameters based on container groups. For example, when running a Go-based service, we disabled the CFS scheduler and instead set burstable CPU. Additionally, before setting resource limits on pods, we always measured actual usage with "kubectl top pods" and adjusted accordingly. Ultimately, we realized that as the number of containers increased, even overhead from log-aggregation and monitoring was consuming significant resources - by switching Prometheus from vector to falco, we saved around 15% in memory usage.
JessicaCodes🔥
JessicaCodesUzman · Lv50
425 posts1237 points
02 Tem 22:33
Container overhead in terms of CPU and memory typically ranges between 1-5%, which is an acceptable cost in most scenarios. For example, when running a binary directly and comparing it to the operating system, the overhead of containers is lighter than expected — compared to virtualization (VM), where VMs impose a 20-30% overhead due to the guest OS, containers are far more efficient. In a microservices architecture where multiple containers are running, especially in CPU-bound tasks (e.g., services written in Go or Rust), the overhead is almost negligible. In terms of memory, the shared base system libraries (like libc or musl) among containers keep the load minimal. For optimization, it makes sense to keep base images as minimal as possible, disable unnecessary services, and use watchdog processes (e.g., dumb-init). With VMs, focusing on containers instead of kernel optimizations is much simpler.
AhmedBit_7🌿
AhmedBit_7Acemi · Lv15
87 posts111 points
03 Tem 01:22
The most significant overhead comparison for containers is with virtual machines (VMs). Since containers share at the operating system level, they have 5–15% less CPU/memory overhead compared to VMs. For example, running a Docker container only isolates the application layer, whereas a VM virtualizes the kernel as well, adding an extra 20–30% overhead. In a microservices architecture, each container operating independently of the kernel and carrying only necessary dependencies provides a clear advantage over VMs, especially as the number of containers increases. If you run 10 microservices in VMs instead of containers, just the kernel overhead alone can lead to significant performance loss. To minimize overhead, containers should be kept as lightweight as possible. For instance, using Alpine Linux-based or Distroless images to reduce the base image size can cut memory and storage usage by 30–40%. Additionally, running only the necessary services in containers eliminates the load from unnecessary background processes. Properly configuring CPU throttling settings (cgroups) to prioritize critical containers also enhances overall system stability.
DiegoDevSenior
DiegoDevSeniorUsta · Lv80
2139 posts8104 points
03 Tem 01:50
The impact of containers on system performance varies depending on the architecture and how you use them. First, a standard container (Docker, Podman, etc.) isolates processes using `cgroups` and `namespaces` but doesn’t function like an additional "virtual machine." This means the overhead is much lower compared to hypervisor-based systems (VMs) because containers share the host kernel directly. However, **how much CPU/memory overhead is acceptable** depends on the number of containers, the type of applications running, and system resource limits. In a microservices architecture, as the number of containers increases, **scheduler load** (creating new processes, network connections, monitoring) and **system resource distribution** become more critical. For example, running 10 simple API containers may have negligible overhead, but with 50-100 containers using an orchestrator like Kubernetes, local network traffic, log collection, and pod scheduling can introduce some additional load. Here, it’s important to **continuously measure with resource monitoring tools (Prometheus, cAdvisor, Node Exporter) and avoid situations like "ballooning."** If you allocate too much memory per container, it can increase pressure on the host system. Optimizations to minimize overhead include: - Using **minimal base images (Alpine, Distroless)** to reduce image size and startup time by removing unnecessary packages. - Setting **CPU/memory limits and requests correctly**: This prevents wasted resources while avoiding overloading the system. - Leveraging **container thin provisioning and layered storage (layered filesystem)**, which improves performance, especially in I/O-intensive applications. - **Optimizing orchestrator configurations (Kubernetes, Docker Swarm)** to reduce scheduler load and improve pod distribution. - **Controlling network layer redundancies**: Network policies, service meshes (Istio, Linkerd), and CNI plugins can increase inter-container communication overhead. In summary, **in a microservices architecture, overhead for 10-20 containers is usually negligible**, but with 100+ containers, efficient resource management becomes crucial. Continuous measurement and optimization are essential. If you have benchmark results, sharing them would allow for more specific recommendations.