AlgoViz

Hardware and software load balancers

easy 24 min

A hardware load balancer is an appliance you install, often with chips made for moving packets or encrypting.

See it run

Look inside each form, fail one, grow one, and change its rules safely.

Operations

Inside an appliance

A packet through a hardware load balancer, and what its special parts do.

Step 1 of 4

The parts

Our systemstateUsersAppliance AactiveAppliance BstandbyServers

inside

ASIC or FPGA · crypto · CPU · ports

Packet chips, a crypto processor, main processor and fast ports in one box. A second box waits.

Step 1: The parts

def appliance(packet):    if chip.knows(packet.flow):        return chip.forward(packet)     # fast path    flow = cpu.decide(packet)           # rules, new flows    chip.learn(flow)    return cpu.forward(packet)
Grows by
Bigger unit, new pair
Looked after by
You and the vendor

Chips help with the work they were made for. Anything else uses the main processor.

In the real world

The same hardware and software load balancers doing real jobs. Pick one and step through it.

A company moves from an appliance to a software tier, in shares.

Step 1 of 4

Write the rules down

Our systemUsersAppliance100%Software tiertestingServers

Rebuild every rule as text, and replay traffic to compare.

Step 1: Write the rules down

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • Buying one unit

    critical

    One large box is a single point of failure, however reliable its parts.

    Wrong
    balancers = [big_box]
    Right
    balancers = [box_a, box_b]   # and test failover
  • Comparing different speeds

    major

    Requests on open connections and new TLS connections cannot be compared.

    Wrong
    choose(max(a.rps, b.cps))
    Right
    choose(test(a, our_traffic), test(b, our_traffic))
  • Reloading an unchecked file

    critical

    A typing mistake on every instance at once stops the site.

    Wrong
    for b in balancers:    write(b, new); restart(b)
    Right
    if syntax_ok(new):    reload_in_steps(balancers, new)
  • Planning for 100% use

    major

    When one instance fails, the rest are overloaded and fail too.

    Wrong
    ceil(peak / each)
    Right
    ceil(peak / (each * 0.6)) + 1

Interview tips

  • How to explain it

    • Built-in oven, or camping stoves.
    • Buy a box, run a program, or rent the result.
  • Choose hardware when

    • Own data centre, steady and very high traffic.
    • A measured need or a certified device.
  • Choose software when

    • Cloud, containers, changing traffic.
    • Custom rules and reviewed changes.
  • Always

    • Two or more.
    • Test with your traffic.
    • Count people and years.