Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
Flowchart
All Software Architecture templates

Load Balancer with Health Checks — Mermaid Flowchart

Flowchart showing a load-balanced web architecture with health checks, auto-scaling, and failover routing.

What this diagram shows

This Mermaid flowchart places DNS in front of a load balancer. The balancer's health check sends traffic only to healthy app servers. An unhealthy server is drained and the auto-scaling group starts a replacement. Every app server reads through Redis. Redis sits in front of a primary database for writes and two read replicas. The primary replicates to both replicas. The app servers also read static assets from S3.

Use it when you are explaining failover to someone who does not want a cloud-vendor diagram. The drain node is the important one: a failed health check does not delete the server in place, it removes it and asks the group for a new one. The chart is also a compact way to show that the cache is shared, so app server 3 does not have a private Redis.

There is a single diamond, the health check, with one edge per healthy server and one edge for the unhealthy case. The replica edges leave the primary, not the app servers, so replication is not mistaken for a query path.

Mermaid syntax in this template

flowchart TD keeps DNS at the top. Cylinders mark Redis, the primary, and both replicas. S3 stays a rectangle because the template treats it as an asset origin.

  • HC{Health Check}

    One diamond fans out to three Healthy edges and one Unhealthy edge. Repeat the Healthy label; Mermaid allows the same label on several edges.

  • Drain --> ASG[Auto-Scaling Group]

    The replacement path is Drain then the group then a new app server. Do not point the unhealthy edge straight at App4 or the group disappears.

  • Cache[(Redis Cache)]

    All three app servers point at the same cylinder. That shared ID is what makes the cache look shared.

  • Primary --> Replica

    Replication is a separate edge from the query path. The app reaches replicas through the cache node in this drawing.

Variations and ways to customize it

Show a write versus read split

The template sends every app at Redis and lets Redis point at both roles. If the app chooses the replica, draw the read edge from the app and keep writes on the primary only.

App1 --> Primary[(Primary DB - Write)]
App1 --> Replica[(Read Replica)]
Primary --> Replica

Add a second availability zone

Wrap app servers 1-2 in a subgraph named Zone A and the replacement plus app 3 in Zone B. Point the load balancer at both subgraphs. The health-check diamond can stay outside the groups.

subgraph Zone A
    App1[App Server 1]
    App2[App Server 2]
end

Name the balancer algorithm

Change the load balancer label to Load Balancer least-connections or round-robin. The health-check edges do not change. Avoid a second diamond for the algorithm; it is a property of the node, not a branch.

Diagram type

Flowchart

Tags

load balancerscalinghigh availabilityfailoverinfrastructure
Open in Editor

Frequently asked questions

What does the unhealthy branch do in this flowchart?

It drains the server and asks the auto-scaling group for a replacement labeled New App Server. Existing healthy servers keep their edges to Redis. The bad server is not drawn talking to the database.

Why do app servers point at Redis instead of the database?

The template puts the cache on the path for every app server, and Redis points at the primary and both replicas. That is a cache-aside sketch. Rewire the app to the primary if you want the cache to be optional.

How do I add a fourth app server?

Add App4[App Server 4], an HC -->|Healthy| App4 edge, and App4 --> Cache plus App4 --> S3. Copy the two downstream edges from App1 so the new server is not only attached to the balancer.

Is the primary-to-replica arrow a query?

No. Those edges are replication. Queries are the edges from Redis to the primary and the replicas. Keep the labels, or a reader will think the app opens three connections.

Related templates and guides

All Software Architecture templates