AdvancedLesson 12 of 127 min read

Capstone: Designing Wren’s Reliable Architecture and Computing Its Availability

Combine the course in one design: load balancer, two zones, queue, database with a standby, backups, and compute the availability of the whole system from its parts using series and parallel rules, with failover that can fail, checked by simulation, plus recovery time and cost.

In this lesson you will

  • Compute availability of series and parallel parts
  • Model an imperfect failover
  • Convert availability to downtime
  • Estimate recovery time from backups

About 28 minutes

What does Wren promise the customers?

Wren’s ticket site now has the pieces from this course: a region chosen by latency, object storage for posters, a queue for slow work, autoscaled servers, a private network with layered security groups, a template that rebuilds everything, and a budget with alerts. The last question is the one that customers ask: how often will it be down? The answer comes from the availability of the parts and from how they are connected. Availability is the share of time a component works, for example 99.9 percent, which is 0.1 percent of 525,600 minutes in a year, about 526 minutes, or 8.8 hours, of downtime. Parts in series, where all of them are needed, multiply their availabilities, so a chain is weaker than its weakest link. Parts in parallel, where one is enough, fail only when all fail, so two parts of availability a give 1 – (1 – a)^2.

Real redundancy is rarely perfect. A standby database takes over only if the failover works, which is a process that can fail, and failures of the two copies are not always independent. The capstone model therefore includes a failover success probability. The design has four parts in series. The load balancer, with 99.99 percent, is a managed service that is already spread over zones. The web tier has two servers in different zones, each 99.5 percent, in parallel. The queue, a managed service, has 99.95 percent. The database has a primary of 99.9 percent and a standby: if the primary is down, the standby takes over with a probability of 95 percent and is itself up with 99.9 percent. All numbers are invented for the exercise, and real figures come from the providers’ service level agreements, which describe what you are owed, usually only as a credit, when they are not met.

Part Availability Connection
Load balancer 99.99% Series
Web servers (2, two zones) 99.5% each Parallel
Queue 99.95% Series
Database + standby 99.9% + failover Parallel with failover
const lb = 0.9999, web = 0.995, queue = 0.9995, db = 0.999, failover = 0.95;
const webPair = 1 - (1 - web) ** 2;
const dbOne = db, dbPair = db + (1 - db) * failover * db;
const mins = a => (1 - a) * 525600;
const whole = (w, d) => lb * w * queue * d;
const designs = { 'one web server, one database': whole(web, dbOne), 'two web servers, one database': whole(webPair, dbOne), 'two web servers, database with standby': whole(webPair, dbPair) };
for (const [k, a] of Object.entries(designs)) console.log(k.padEnd(42), (a * 100).toFixed(4) + '%', ' downtime', mins(a).toFixed(0).padStart(5), 'minutes a year =', (mins(a) / 60).toFixed(1), 'hours');
console.log('web pair alone:', (webPair * 100).toFixed(4) + '%', '| database pair alone:', (dbPair * 100).toFixed(5) + '%');
const backupGB = 200, restoreMBps = 100, rebuildMin = 20, snapshotEveryMin = 60;                 // invented: data size, restore speed, time to rebuild infrastructure from the template, backup interval
const restoreMin = backupGB * 1024 / restoreMBps / 60, rto = rebuildMin + restoreMin;
console.log('disaster recovery: restore', restoreMin.toFixed(1), 'min + rebuild', rebuildMin, 'min => recovery time about', rto.toFixed(0), 'min; recovery point up to', snapshotEveryMin, 'min of data');
console.log('DATA ' + JSON.stringify({ designs, webPair, dbPair, rto, restoreMin }));
one web server, one database               99.3409%  downtime  3464 minutes a year = 57.7 hours
two web servers, one database              99.8376%  downtime   854 minutes a year = 14.2 hours
two web servers, database with standby     99.9324%  downtime   355 minutes a year = 5.9 hours
web pair alone: 99.9975% | database pair alone: 99.99491%
disaster recovery: restore 34.1 min + rebuild 20 min => recovery time about 54 min; recovery point up to 60 min of data

The program computes the availability of three designs. With one web server and one database, the chain of four parts gives 99.341 percent, which is about 3,464 minutes, or 58 hours, of downtime a year. Adding a second web server in another zone makes the web tier 99.9975 percent, and the whole system 99.838 percent, 854 minutes a year. Adding the database standby, with its imperfect failover, makes the database 99.99491 percent and the whole system 99.932 percent, about 355 minutes a year. Each step removes the weakest link in turn, and the result of the last step, close to the load balancer and queue figures multiplied, shows the principle that a system is limited by what is left: the load balancer and the queue now dominate, and further redundancy in the web tier or database would buy almost nothing.

The second half estimates how long a real disaster would take to recover from. If a whole region is lost, the template of lesson 9 rebuilds the infrastructure in an estimated 20 minutes, and restoring 200 gigabytes from a backup at 100 megabytes per second takes 34.1 minutes, so the recovery time objective, RTO, is about 54 minutes. With hourly snapshots the recovery point objective, RPO, is up to 60 minutes of data. Both numbers are decisions: faster recovery costs more, with a warm copy in another region, and a shorter RPO needs more frequent backups or continuous replication. A design should state RTO and RPO openly, and a recovery that has not been tested should be assumed not to work, so Wren rehearses it every quarter in a test account, from the template, which is exactly what infrastructure as code makes cheap.

Independent check: the three availabilities were recomputed in Python with exact fractions, from the same parts and rules, and agree with the JavaScript numbers to twelve decimals. The most complicated design, with the imperfect failover, was also tested by simulation: four million random years of the system, drawing every component’s state and the success of the failover, gave 99.9352 percent against the formula’s 99.9324 percent, agreeing within the sampling error. The restore time was recomputed by hand: 200 x 1,024 / 100 seconds is 2,048 seconds, 34.1 minutes, and with 20 minutes for the rebuild the total is 54 minutes, which is what the program says. The model assumes independent failures, and in real life a shared cause, such as a faulty deployment, takes down all copies at once, so it gives an upper bound on what you can promise.

Check by hand with the web pair: each server is down 0.5 percent of the time, so both are down together 0.005 x 0.005 = 0.000025, which is 0.0025 percent, and the pair is 99.9975 percent available. The chain of the load balancer, the web pair, the queue and a database pair of about 99.9949 percent is roughly 0.9999 x 0.999975 x 0.9995 x 0.999949 = 0.99932, so about 355 minutes a year, in line with the program. The database pair figure comes from 0.999 + 0.001 x 0.95 x 0.999 = 0.99994905.

Redundancy can fail together

Two servers deployed with the same bad release, or sharing one configuration, fail together, and the formula for independent parts is then too optimistic. Roll out changes gradually, and keep a rollback ready.

Write RTO and RPO down

Agree with the business how long a recovery may take and how much data may be lost, then choose the cheapest design that meets them, and test it on a schedule.

About this course

No cloud account is needed for this course. The cloud services in these lessons are small simulations that run on your own computer, in Python 3.13 or Node.js 22, because the ideas, such as access policies, queues, autoscaling and templates, are the same at every provider. Prices and names are invented or generic, and each provider’s services and prices change often, so check the current documentation of the provider you use. Every result was checked a second way. Service level agreements, availability figures and recovery features differ by provider and service, and they change. Use the current agreements for your own calculation.

Where to go from here

You now have the whole path: what the cloud rents and what it costs, where to place workloads, how to pay, who may do what, how data is stored and kept safe, how queues and autoscaling absorb load, how to run code without servers, how to build the environment from a template, how to isolate it in a network, how to control the bill and how to compute reliability. The next steps are practical. Open a free account with a budget alert already set, rebuild the capstone design from a template in a test account, break it on purpose and time the recovery, and read the provider’s architecture guidance for the services you use, since that is where its own current recommendations live.

Check what you learned

Five quick questions. Pick an answer and you will see straight away whether it is right and why.

How is the availability of parts in series computed?

  1. By multiplying their availabilities
  2. By adding them
  3. By taking the best
  4. By taking the average

A chain is weaker than its weakest link.

How is the availability of two independent parallel parts computed?

  1. a + b
  2. a x b
  3. The smaller of the two
  4. 1 – (1 – a)(1 – b)

Both must fail.

Why include a failover success probability?

  1. Failover is always perfect
  2. To lower the price
  3. Standby servers are slower
  4. Failover is itself a process that can fail

Imperfect failover lowers the gain.

What are RTO and RPO?

  1. Two prices
  2. Two regions
  3. The time to recover and the amount of data that may be lost
  4. Two backups

Recovery time and recovery point objectives.

Why simulate the whole system?

  1. To add servers
  2. To reduce the bill
  3. To confirm the formula for an imperfect failover independently
  4. It is required

The simulation agrees with the formula.

Summary

  • Series multiplies availability, parallel multiplies the failure probabilities.
  • Imperfect failover lowers the benefit of a standby.
  • RTO and RPO come from backup size, speed, and interval, and must be tested.
  • Real failures are correlated, so treat the formula as an upper bound.

Next lesson

You have completed the course.

Questions

Is 99.99 percent availability realistic for a small team?

It is demanding: about 53 minutes of downtime a year. It needs redundancy, automation, tested recovery and discipline, so many small services aim for 99.9 percent and work up.

What if my provider's whole region fails?

Only a design with a copy in another region survives it. Decide with the business whether that is worth the cost, and at least keep backups and a template ready to rebuild elsewhere.

Where should I practise?

In a free-tier or low-cost account with a budget alert, deleting everything after each exercise, and rebuilding it from your template.

Progress is saved in this browser.