BeginnerCoder

Lesson 18 — Round-robin balancer

Take turns

A load balancer spreads incoming requests across several servers. Round-robin is the simplest strategy: server 1, server 2, server 3, then back to 1. The % operator (remainder) does the wrap-around: 3 % 3 is 0.

colors[n % colors.length]

Note: real DevOps tools (CI servers, load balancers, Docker, Kubernetes) cannot run in your browser, so this exercise is a small plain-JS simulation of the logic those tools use.

Why it matters: sharing load means no single server melts while others sit idle.

Want it another way?
Task

Return the next server in turn (wrap around with %), then move i on, so 7 requests cycle s1, s2, s3.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with DevOps Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.