liveBook · Manning

Load balancing

As explained in Server-Side WebAssembly

Load balancing is the distribution of application requests or work across multiple running instances or hosts.

Load balancing distributes incoming requests across multiple running component instances, allowing work to proceed concurrently instead of waiting behind a single instance. In wasmCloud, the host manages replicas while the NATS lattice routes requests among them. section 6.3

A practical wasmCloud deployment applies the technique progressively:

  • Increase the spreadscaler instance count, such as from 1 to 10, then redeploy the application. section 6.3
  • Benchmark concurrent traffic with oha using ten requests and five concurrent connections. section 6.3
  • Distribute replicas across labeled hosts with weighted placement, such as 80% in us-east-1 and 20% in us-west-1. section 6.4
  • Inspect host inventory and simulate an outage by shutting down one host, then verify the remaining deployment. section 6.4

Ten replicas reduce waiting

A sample HTTP component deliberately sleeps for two seconds per request. With one replica, ten requests complete in about 20 seconds, averaging 0.50 requests per second. With ten replicas, the same benchmark finishes in about 4.09 seconds, averaging 2.44 requests per second, with response times near two seconds. section 6.3

- type: spreadscaler
  properties:
    instances: 10

Shows the compact spreadscaler configuration that changes the application from a single instance to ten replicas. section 6.3

How Server-Side WebAssembly covers it

How deep it goes
Explains replica counts, weighted host placement, benchmarking, and outage simulation, but does not detail the routing algorithm.
Examples
Demonstrates one versus ten replicas, weighted East and West Coast placement, benchmark commands, inventory inspection, and host shutdown.
What it assumes
Assumes a working wasmCloud application and introduces scaling through component replicas, hosts, zones, and deployment commands.
What you can do after
Operate/configure wasmCloud scaling with spreadscaler, deploy replicas, benchmark concurrency, inspect placement, and test host failure.
How it connects
Connects replicas with the NATS lattice, wasmCloud hosts, spreadscaler, persistent key-value storage, geographic distribution, and fault tolerance.

Also explained in

Compare how 13 books explain load balancing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.