Skip to content
Elements of Scalable Web Development
ContentsProjectCasesDemosConcepts
Feedback overviewReview comments from across the book

Demos and exercises#

Work through one module at a time: change the inputs, inspect what responds, and connect the result to your own project. Repeat a scenario until you can explain the trade-off without relying on the interface. Where practice is available, switch to its tab to check your understanding. Saved results are shared with the chapter exercises.

For a small local implementation with your own model, download the local exercise workspace. Set up once, choose CSV, test quality, persisted retries or HTTP caching, and run that exercise’s independent checks.

Modules
16
Exercises
13
Mode
Self-guided
Reading investigations Optional depth More practice

Reading investigations

Use these alongside the main chapters. Predict a result, change one condition and explain what the evidence supports.

01

Scalable development

Deterministic boundary lab
Reading

Deterministic boundary lab

Limit the agent to valid transitions

Goal: ship a safe change The agent can choose only events enabled by the statechart.
01

Agent choices

One goal can produce different valid routes through the model.

Current state active.planning
Available next events

Predict whether RELEASE will be accepted. A rejected proposal leaves the state unchanged.

02

Statechart rules XState v5 + ELK

Hierarchy shares rules; parallel regions represent simultaneous facts.

Change delivery statechart Planning leads to implementation and parallel verification. Failed tests or requested changes return to implementation. Successful verification enables release, while cancellation can leave the active hierarchy at any point. active compound state initial planning initial implementing verifying parallel state checks compound state running initial passed review compound state waiting initial reviewing approved ready released cancelled RELEASE: active.ready to released RELEASE CANCEL: active to cancelled CANCEL PLAN_APPROVED: active.planning to active.implementing PLAN_APPROVED PATCH_READY: active.implementing to active.verifying PATCH_READY TESTS_FAIL: active.verifying.checks.running to active.implementing TESTS_FAIL REQUEST_CHANGES: active.verifying.review.reviewing to active.implementing REQUEST_CHANGES both regions final: active.verifying to active.ready both regions final TESTS_PASS: active.verifying.checks.running to active.verifying.checks.passed TESTS_PASS REVIEW_START: active.verifying.review.waiting to active.verifying.review.reviewing REVIEW_START APPROVE: active.verifying.review.reviewing to active.verifying.review.approved APPROVE
Active configuration active.planning
Why this matters

The parent state exposes one shared cancellation rule.

Inspect or export the executable model

Copy the XState machine and paste it into Stately Sketch to inspect or simulate the generated diagram.

Open Stately Sketch ↗
Observed events
  1. No events sent yet.

TESTS_PASS is a supplied event in this executable statechart. This demo runs no application tests; a real workflow must verify test evidence before supplying that event.

Pause & think

Follow the release gates

In this delivery statechart, release readiness requires both passing checks and an approved review. Checks have passed, but review has not started. Select the missing gate and the destination of REQUEST_CHANGES during review.

Automatically checked practice. Saved answers are private to your account.

Sign in to save
Preview the exercise context for the assistant

This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

Checking saved answers…

Your answers to earlier versions
Show worked answer

Passing checks alone does not complete the parallel verification state. Review must also approve. REQUEST_CHANGES returns the patch to implementation.

Practice in the chapter →

02

Architecture

Cache decision lab
Reading

HTTP cache lab

Where does the next response come from?

Fresh cache hit shared cache

Every case begins after one successful response. Change its policy and age, then trace the next request without changing the URL. For an executed browser observation, try the optional local practice workspace and choose http-cache/README.md.

Choose the response profile
Stored response policy Versioned asset
stored fresh for 365 days timeline: 400 days
01Browser cache
02Shared cache
03Origin
Decision trace cache → response
    Response source
    Browser waits?
    Origin body bytes
    Representation used

    What this means

    Reuse the fingerprinted response

    Policy rule immutable means the URL carries the version

    This model begins with warm browser and shared entries of the same age. A stale browser entry is forwarded; only the shared cache uses the stale window here. Reloads and request overrides are not modeled. Real cache keys, platform overrides, authorization, request directives, and invalidation rules must be verified in the deployed path.

    03

    Architecture

    Web architecture lens
    Reading

    Web architecture lens

    What crosses the boundary after an action?

    Three modeled update flowsNo HTTP requests run here; sizes and timing are not measured.

    The first document may be rendered on the server, built ahead of time, or assembled in the browser. That is a separate choice from the later update below. All three examples start from the same loaded activity page.

    After recording an event

    Full-document navigation

      Response
      Replacement scope

      Draft outside the activity list

        A fragment or client render can also discard state if it replaces the draft's owner. In your project, inspect one real action in DevTools: method, status, content type, replaced DOM region and draft behavior. Make one bounded update with your model, then verify the saved event and draft separately.

        04

        Benchmarking

        Tail latency simulator
        Reading

        Tail latency simulator

        An average can hide slow requests

        Choose a claim before measuring A constructed population of 60 requests: 24–34 ms plus 188 ms for the selected slow paths. It does not contact a server.

        01 / Define the run

        Workload controls

        Predict the result

        02 / Read the distribution

        60 records, ordered fastest to slowest

        Typical Slow path

        Make a prediction, then run the workload.

        0 ms —

        The outlined bar is rank 57, the nearest-rank p95. Three slower records can sit beyond it.

        Inspect all ordered records

        Make a prediction to reveal the population.

        Average
        —
        p50
        —
        p95
        —
        Slowest
        —

        A benchmark should test an explicit claim. Which measurement do you expect to cross the objective?

        Pause & think

        Calculate the average and the tail

        A fixed sample contains 20 requests: 18 take 40 ms each and two take 240 ms each. Use the nearest-rank percentile: sort the values, then take rank ceil(0.95 × 20). The objective requires latency strictly below 120 ms. Calculate the mean and p95, then choose which meet the objective. This sample is separate from the adjustable simulation in Explore.

        Automatically checked practice. Saved answers are private to your account.

        Sign in to save
        Preview the exercise context for the assistant

        This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

        Checking saved answers…

        Your answers to earlier versions
        Show worked answer

        The total is 18 × 40 + 2 × 240 = 1200 ms, so the mean is 60 ms. Rank 19 is 240 ms. The average meets the objective while p95 does not; an average can conceal a slow minority.

        Practice in the chapter →

        05

        Benchmarking

        Browser performance workbench
        Reading

        Browser performance workbench

        Compare two browser update strategies

        Ready for five local runs Measurements come from this browser and this device. No data leaves the page.

        01 / Define the workload

        Event-list interaction

        Update strategy

        Predict first: which strategy has the shorter total time, and which has the shorter instrumented JavaScript slice?

        02 / Inspect the runs

        Elapsed time including frame waits

        Local evidence

        Run the same interaction five times to reveal its distribution.

        Median total
        —
        Fastest
        —
        Slowest
        —
        Longest JS slice (median)
        —

        Five runs show variation in this browser. Frame callbacks are a scheduling proxy, not proof of pixel presentation; slices exclude later layout and rendering.

        06

        Benchmarking

        OpenTelemetry trace explorer
        Reading

        OpenTelemetry trace explorer

        Follow one request, span by span

        Inspect the evidence first A client-only trace simulation. No telemetry is collected, exported, or stored.
        Applicationstarts + ends spans → OTel SDKbatches span records → Collectorreceives OTLP + routes → Backendstores + explores

        The rows cover one server's handling of an inbound HTTP request. Browser work and time outside this server span are excluded. Select a row to inspect the record the SDK could include in a batched OTLP export.

        Server trace

        POST /events · 286 ms on server

        4bf92f3577b34da6a3ce929d0e0e4736

        Select any span row to inspect its telemetry record.

        0 ms143 ms286 ms

        Selected span

        POST /events

        Duration
        286 ms
        Status
        Unset
        Source
        Automatic

        Attributes

        Inspect conceptual span record

        This keeps the important structure visible. Literal OTLP/JSON adds typed values and a more verbose envelope, and a real export may contain several spans.

        Use duration, parentage and status to choose evidence. What does this span show, and what is still unknown?

        Try this in your project: instrument one operation, record a normal request and a deliberately delayed or failed attempt, then inspect the exported spans. Preserve the request result and explain what a missing span would prevent you from concluding. The records above are authored examples.

        07

        Agent fleets

        Sequential work bound
        Reading

        Amdahl’s Law · S(N) = 1 / ((1 − p) + p/N)

        Find the limit of parallel work

        2.50× ideal speedup

        01 / Describe the workflow

        The ideal bound excludes coordination, conflicts, retries, and review queues.

        One agent100%
        4 agents
        40%
        SequentialParallel share after division
        Ideal speedup
        2.50×
        Relative time
        40.0%
        Efficiency
        62.5%
        Speedup limit
        5.00×

        Four agents divide the parallel work, but the sequential 20% remains.

        Pause & think

        Does a faster feature mean more accepted work?

        Before calculating, predict whether doubling a fleet from four to eight agents will double accepted output, and explain your prediction.

        Each feature needs 80 minutes of implementation with one agent and 20 minutes of review by one person. The agents work together on one feature, divide implementation time perfectly, and start the next feature as soon as implementation ends. Review of earlier features can overlap that implementation. Assume no coordination cost, continuous work, every feature passes review, and no withdrawal.

        Calculate completion time for an isolated feature with no queue ahead, then production and review rates for the eight-agent fleet. Use ongoing rates, not counts in the first clock hour. Finally, calculate unfinished-work growth and assess the effect of doubling the fleet.

        Automatically checked practice. Saved answers are private to your account.

        Sign in to save
        Preview the exercise context for the assistant

        This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

        Checking saved answers…

        Your answers to earlier versions
        Show worked answer

        With four agents, an isolated feature takes 80/4 + 20 = 40 minutes; with eight, it takes 80/8 + 20 = 30 minutes. These correspond to ideal Amdahl speedups of 100/40 = 2.5 and 100/30 ≈ 3.33 for the fixed task. During continuous work, four agents finish implementation every 20 minutes, producing three candidates/hour; eight finish every 10 minutes, producing six. One reviewer can accept at most 60/20 = three features/hour. With eight agents, unfinished work therefore grows by 6 − 3 = three features/hour. Doubling the fleet finishes an isolated feature sooner but leaves accepted throughput unchanged. Later features wait longer as the review backlog grows, so 30 minutes does not describe every feature in that stream. Explain which assumption you would investigate before recommending more agents, and what evidence would justify changing review capacity or admission.

        Practice in the chapter →

        08

        Scaling

        Saturation boundary lab
        Reading

        Capacity limit lab

        Find the first binding limit

        Inspecting pipeline Compare effective demand with every stage.

        Offered events

        Declared stage capacity

        Offered load 140 ev/s one visit per stage; no retries
        Admitted—
        Useful completed—
        Boundary —
        Headroom —
        Queue growth —
        Rejected explicitly —

        Adjust demand or capacity to expose a boundary.

        Predict which stage will limit completion after one capacity increase, then compare.

        What would you measure in a real system?

        Before revealing a hint, choose evidence that could distinguish a resource limit from an enforced quota. A smaller declared number alone cannot distinguish them.

        Reveal a signal for this limit

        A steady-rate model with one visit per stage, successful work and one buffer before the pipeline. Completion is the minimum of admitted load and all declared capacities. Admission limiting rejects excess immediately; without it the buffer grows. Bars compare admitted rate with limits, not measured stage utilization. There are no latency, transient queue or production capacity predictions.

        Pause & think

        Locate the next capacity limit

        Each request visits every stage once. Capacities are API 180, database 110, workers 150, and downstream 130 requests/s. Offered load is 150 requests/s, with no retries. Use the smallest stage capacity as the throughput ceiling. Then raise database capacity to 150 requests/s, leaving all other capacities unchanged.

        Automatically checked practice. Saved answers are private to your account.

        Sign in to save
        Preview the exercise context for the assistant

        This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

        Checking saved answers…

        Your answers to earlier versions
        Show worked answer

        Initially the database limits throughput to 110 requests/s. Increasing its capacity moves the limit to the downstream stage at 130 requests/s. Offered load still exceeds capacity by 20 requests/s.

        Practice in the chapter →

        09

        Scaling

        Latency budget map
        Reading

        Latency budget lab

        Count distance and database waits

        Build the request path An illustrative model of distance, network overhead, and sequential database waits.

        Request topology

        Physical floor

        User App DB
        User to app 500 km 5.0 ms RTT floor
        App to DB 1 km 0.0 ms RTT floor

        Map derived from BlankMap-World.svg by Canuckguy and contributors, public domain, via Wikimedia Commons.

        In fiber, light travels at roughly 200,000 km/s. That is about 200 km per millisecond one way, before routing, queues, TLS, server work, or database execution.

        User RTT floor
        0 ms
        App-DB RTT floor
        0 ms

        Database access pattern

        Compare access shapes

        Sequential DB wait
        0 ms
        DB wait in at most 2 trips
        0 ms
        Round-trip penalty
        0 ms
        Network per DB trip
        0 ms
        Server execution
        0 ms

        Hypothetical timings: these values describe no hardware class. Batching keeps the same queries and execution cost; it is possible only if their dependencies permit at most two trips with identical results.

        Latency budget

          Totals

          Sequential response
          0 ms
          Physical network floor
          0 ms
          Avoidable DB wait
          0 ms
          Response with at most 2 DB trips
          0 ms

          Interpretation

          Adjust distance and database access to see what dominates.

          Optional depth

          Explore a specific mechanism when it helps answer your question. These models and appendix activities do not add required submissions.

          10

          Architecture

          ACID transaction lab
          Optional

          ACID transaction lab

          Keep state and history consistent

          Choose a failure boundary One lifecycle transition must produce exactly one activity event.

          Predict the stored state and client result, then reveal an authored trace. These examples execute no database operations. Transaction scope, the concurrent program and acknowledgement timing answer different questions.

          Isolation applies when concurrent work shares a transaction boundary.

          The concurrent program and a conditional-write alternative

          The simulation uses this read/check/unconditional-write program. Both callers read initial before either writes. The isolation choice changes the result for this program; read committed does not inherently require duplicate transitions.

          BEGIN
          state = SELECT state FROM work_items WHERE id = :id
          IF state = 'initial':
            UPDATE work_items SET state = 'active' WHERE id = :id
            INSERT work_started INTO activity_events
          COMMIT

          A different program can check the current state in the authoritative write. In PostgreSQL, a competing updater waits and rechecks its WHERE condition after the other update commits. Only the caller whose update returns a row appends an event, inside the same transaction:

          BEGIN
          changed = UPDATE work_items SET state = 'active'
                    WHERE id = :id AND state = 'initial' RETURNING id
          IF changed has one row:
            INSERT work_started INTO activity_events
            COMMIT
          ELSE:
            ROLLBACK
            reject transition

          This is illustrative pseudocode, not executed SQL. Event-insert failure must roll back the state update. Check the chosen database's guarantees; see PostgreSQL read committed.

          W

          Work-item record

          The state returned by a fresh read.

          Item
          I42
          Stored state
          Initial
          Client result
          Not run
          E

          Activity-event ledger

          Successful transitions must appear exactly once.

          Seq Event Actor
          No activity events stored.
          T

          Execution trace

          Follow the writes, responses, and failures.

          1. ReadySelect a scenario and run it.
          ?
          Contract check

          Awaiting an operation

          The lifecycle state and activity ledger have not changed.

          This is a deterministic transaction model, not a benchmark of a particular database. Real isolation and durability depend on the database, transaction boundaries, constraints, storage configuration, and failure model. For actual atomic rollback and process-restart records, try the optional course workspace (persisted-retry/). It does not reproduce the isolation-level comparison.

          11

          Appendix D: Agent-system security

          Fleet trace debugger
          Optional

          Fleet trace debugger

          Match fleet activity to resource costs

          Fixed synthetic teaching packet. No models or tools execute in this demo.

          0 of 5 ledger rows assigned Compare planned work, gateway decisions, and the supplied resource ledger.
          01

          Inspect the supplied logs

          Compare orchestration intent with gateway decisions before touching the physical ledger.

          Packet FLT-17A Gateway export complete
          R41
          Patch event filter tr-41 · outcome accepted
          Accepted
          R42
          Publish audit notice tr-42 · outcome cancelled
          Cancelled
          ORCH
          Orchestration log
          Run intent and outcomes
          Time Run Event Evidence
          GATE
          Gateway log
          Selected route and policy result · complete export
          Request Run / trace Selected resource Policy
          02

          Match each resource record to a run

          Map each provider or resource record to R41, R42, or unmatched. Do not infer a run where the linking evidence is absent.

          0 / 5 mapped
          PHY
          Provider and resource ledger Authoritative provider spend and tool-effect records
          Row Time Physical operation Linking evidence Result Cost Map to Reconciliation

          Assign every row before reconciling the packet.

          03

          Reconciled control record

          Each physical row is counted once, including failed, cancelled, and unmatched work.

          5 / 5 accounted
          Physical rows
          5
          Accepted runs
          1
          Fixed-cohort cost
          0.00 EUR
          Cost / accepted run
          0.00 EUR
          Run and route rollup
          Attribution Outcome Rows Selected route / policy Cost
          Consequential findings
            Export the reconciliation record

            The record preserves mappings, route and policy provenance, all costs in the packet, and the denominator used for the result.

            12

            Appendix E: Scalability models

            Reliability chain lab
            Optional

            Lusser’s Law · Rworkflow = ∏ri

            See how step reliability compounds

            60.6% completes correctly

            01 / Set the step assumptions

            Idealized boundary: identical independent steps, every step required, and the first terminal outcome decides the run.

            One step · prediction or recovered error r = .950 + (.050 × .900 × 1.000) = 99.500%
            Series chain · every critical step succeeds R(100) = .99500^100 = 60.6%
            Correct completion across the chain 60.6%
            0 stepsCritical chain →200 steps
            Where runs end Correctness and safety are separate
            Per-step completion
            99.500%
            Correct completion
            60.6%
            Safe stop
            0.0%
            Wrong result
            39.4%

            At 99.500% per step, 100 independent critical steps complete correctly 60.6% of the time.

            13

            Appendix E: Scalability models

            Contention curve lab
            Optional

            Universal Scalability Law · C(N)

            See when more workers reduce throughput

            Capacity is still rising

            01 / Shape the scaling cost

            1 workerConcurrency →32 workers
            Selected capacity
            5.57×
            Best displayed concurrency
            22
            Best displayed capacity
            7.33×
            Next worker
            helps

            At eight workers, added concurrency still increases modeled capacity.

            14

            Scaling

            Orchestration control loop
            Optional

            Browser cluster lab · Webernetes

            Watch controllers restore the desired state

            Starting simulated cluster… Controllers are assembling a three-node teaching environment.
            Simulation boundary This runs Kubernetes-compatible control logic in your browser. It does not run Docker images or measure production capacity. No application-aware readiness check is configured: a running pod can return HTTP 500.
            Desired 3
            Running 0
            Release v1
            Successful responses 0
            Failed responses0

            Predict: can every pod be running while every application request fails?

            NodePort service · :31000 event-api
            round robin
            01node-1
              02node-2
                03node-3
                  Controller feed Newest event first
                  Reconciling
                    Application request logActual responses inside this browser simulation
                      Debrief the mechanism and its limits

                      Roll out v2, send requests, then roll back and repeat. Name the desired state, the observed state, and the controller action after each experiment. Then identify what remains outside this model.

                      • Replicas add service instances; they do not remove database limits.
                      • Replacement demonstrates recovery, not uninterrupted availability.
                      • This simulator omits real images, resource limits, persistent volumes, and production networking.
                      15

                      Appendix F: Durable workflows

                      Durable effect retry lab
                      Optional

                      Durable retry orientation

                      See when a retry duplicates an effect

                      Predict the recovery outcome One command can produce more than one physical attempt.

                      Browser simulation: counts and ledgers below are held in memory. No worker process crashes and no durable storage is written. Predict the effect count, stop at the missing-completion boundary, then recover.

                      01

                      Set the retry contract

                      Choose the facts that survive the worker.

                      After recovery, how many webhook effects exist?
                      Modeled failure window

                      Receiver applies effect → worker stops before recording completion → completion is absent from workflow history.

                      Activity attempts
                      0
                      Webhook effects
                      0
                      Durable completions
                      0

                      Modeled workflow state: Ready. Last recorded fact: None.

                      Inspect the simulated workflow and receiver records
                      H

                      Workflow history

                      Only durable orchestration facts appear here.

                      Seq History event Replay knows
                      Run the first attempt to create history.
                      R

                      Webhook receiver ledger

                      Attempts and externally visible effects.

                      Try Idempotency key Receiver reply Effect
                      No webhook attempts yet.
                      ?
                      Awaiting experiment

                      Make a prediction, then stop the worker inside the failure window.

                      Copy model notes

                      Simulated failure-window notes

                      These notes describe the selected in-memory model, not executed recovery evidence.

                      For actual process loss and persisted records, use persisted-retry/ in the course workspace. Compare worker attempts/completions with receiver effects/receipts, including the fresh-key negative control.

                      16

                      Appendix C: Advanced web boundaries

                      CAP partition lab
                      Optional

                      CAP partition lab

                      Compare write policies during a partition

                      All regions can communicate Cut the network before testing the write policy.

                      Helsinki becomes isolated from the Frankfurt–Dublin majority. Alice and Bob then try to start the same work item from opposite sides of the split.

                      HEL connected
                      Helsinki
                      Item state
                      initial
                      Visible event
                      none
                      Client reply
                      waiting
                      healthy network
                      FRA connected
                      Frankfurt
                      Item state
                      initial
                      Visible event
                      none
                      Client reply
                      waiting
                      DUB connected
                      Dublin
                      Item state
                      initial
                      Visible event
                      none
                      Client reply
                      replica
                      LOG

                      Request and repair log

                      Repair cannot retract a success response already seen by a client.

                      1. 00

                        Replicas agree that I42 is initial.

                      Accepted writes
                      0
                      Rejected writes
                      0
                      Conflicts to repair
                      0
                      C Write consistency
                      One transition history
                      A Availability
                      No partition yet
                      P Partition condition
                      Network connected
                      ↔
                      What this means

                      CAP has not constrained the request path yet

                      With communication intact, the replicas can coordinate before they answer.

                      The model holds workload, topology, and failure constant so the policy is visible. The write-invariant check alone does not establish linearizability for all reads and writes. Real systems also define quorums, timeouts, leases, and conflict resolution.

                      Apply the ideas · 9 exercises

                      More practice

                      Connect the calculations, choose a fair comparison, and separate observations from explanations. Check your answers here or continue in the chapter.

                      01Follow work from events to review 02Choose the question before the equation 03Check whether the averages agree 04Choose a valid comparison 05Check a scaling contract 06Separate response from outcome 07Calculate the whole change cycle 08The status is unchanged. Is the operation idempotent? 09Classify evidence and next steps

                      Pause & think

                      Follow work from events to review

                      A stable event pipeline completes 20 events/s with average end-to-end time 0.5 s. A stable development workflow accepts four changes/hour with average time from submission to acceptance of three hours. Both times include waiting inside their respective boundaries. Calculate the average work in progress implied by Little's Law for each. Then suppose submissions rise to six changes/hour while acceptance stays at four, with no discarded changes. Can the earlier steady-state calculation describe this growing backlog indefinitely?

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      The event calculation is 20 × 0.5 = 10 events. The development calculation is 4 × 3 = 12 changes. The same relationship applies to different work when boundaries, windows, and units agree. After the increase, unfinished changes accumulate at two/hour, so the earlier stable calculation cannot describe the backlog indefinitely. Check arrival/completion balance and waiting time again. Neither calculation identifies the cause of delay or proves the waiting time is acceptable.

                      Practice in the chapter →

                      Pause & think

                      Choose the question before the equation

                      You have two questions. First, a stable event pipeline completes 40 events/s with average time 0.25 s inside one declared boundary: what average work in progress is consistent with those observations? Second, a fixed development task has an 80% parallelizable share and a 20% sequential share: what is the ideal speedup with four workers and no added coordination cost? Choose a law for each question, then calculate its result.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      Little's Law answers the flow-consistency question: 40 × 0.25 = 10 events. Amdahl's Law answers the fixed-workload speedup question: 1 / (0.2 + 0.8/4) = 2.5. Matching averages do not identify a bottleneck or prove acceptable latency. Ideal speedup does not guarantee accepted-change throughput: integration overhead, variable tasks, and correctness can change the result. Explain which measurement or assumption you would check before recommending more workers.

                      Practice in the chapter →

                      Pause & think

                      Check whether the averages agree

                      At one declared boundary you observe L = 25 operations, λ = 40 operations/s, and W = 0.25 s. Calculate λW, then select the conclusion supported by these three values alone.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      λW is 10, not 25. Check compatible boundaries, observation windows, units, omitted waiting, and whether arrivals and completions balance. The discrepancy alone does not locate a bottleneck or show that adding workers will help.

                      Practice in the chapter →

                      Pause & think

                      Choose a valid comparison

                      You want to test whether batching improves useful write throughput while keeping p95 end-to-end latency below 100 ms and errors at or below 0.1%. Select the comparison that isolates batching. Then evaluate a run with higher throughput, p95 = 90 ms, and errors = 0.8% against those declared criteria.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      Keep the workload, dataset, environment, and acceptance criteria comparable while changing batching. A run with p95 = 90 ms passes the latency bound, but 0.8% errors violates the 0.1% error bound. Higher throughput does not compensate for failing a declared acceptance criterion.

                      Practice in the chapter →

                      Pause & think

                      Check a scaling contract

                      A service must handle 200 requests/s while keeping p95 below 150 ms and errors at or below 1%. A run handles 220 requests/s with p95 = 180 ms and errors = 0.5%. Check the run against this contract.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      Throughput and errors pass, but latency fails. Handling more requests is insufficient when the declared quality bound is violated.

                      Practice in the chapter →

                      Pause & think

                      Separate response from outcome

                      An API commits an event to storage, then the network loses its response. The browser times out. Use only these stated facts to classify the outcome.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      The storage commit happened even though the browser received no confirmation. A timeout describes what the caller observed; it does not undo or disprove the commit.

                      Practice in the chapter →

                      Pause & think

                      Calculate the whole change cycle

                      A change passes through four sequential stages with no overlap: clarification 10 minutes, editing 10, checks 15, and review 25. A tool halves editing time; every other stage stays unchanged. Calculate the new total and the time saved.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      The original cycle takes 60 minutes. Editing falls from 10 to 5 minutes, so the new cycle takes 55 minutes and saves 5 minutes. A local speedup affects only its share of the full cycle.

                      Practice in the chapter →

                      Pause & think

                      The status is unchanged. Is the operation idempotent?

                      Before choosing, predict whether an unchanged final status is enough to make an operation idempotent. Write a brief reason naming the effects you would inspect.

                      A work item starts in progress with no completion activity event. Its completion contract promises to set the status to Done and record exactly one activity event for that transition. The first attempt commits both, but its response is lost. A retry on another instance leaves the status at Done and appends a second completion activity event. Both commits are durable, and there is no deduplication.

                      Count the stored completion activity events, assess the whole operation against its contract, and select the mechanism that would prevent the duplicate event for retries of this logical command.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      There are two completion activity events. The status assignment is idempotent in isolation, but the whole operation is not: its promised effect includes exactly one activity event for the transition. Idempotency is this property of the intended effect, rather than the name of a retry mechanism. One implementation reuses a stable command key and atomically enforces that key while recording the state change, activity event, and reusable result in authoritative storage. A retry then returns the recorded outcome without appending another event. A per-instance cache cannot coordinate retries routed elsewhere, and a longer timeout cannot guarantee that a response arrives. The caller's uncertainty does not change the stored facts given in this scenario. Explain why a transaction that commits both writes together still needs a rule for repeated commands.

                      Practice in the chapter →

                      Pause & think

                      Classify evidence and next steps

                      Use observation for a reported measurement, inference for an explanation drawn from evidence, and proposal for an action to try. Classify each statement by its role; you are not being asked whether the explanation is true.

                      Automatically checked practice. Saved answers are private to your account.

                      Sign in to save
                      Preview the exercise context for the assistant

                      This prepares an editable message. Review it in the assistant before sending. Your notebook notes are not included.

                      Checking saved answers…

                      Your answers to earlier versions
                      Show worked answer

                      Measurements describe what was recorded. A causal explanation goes beyond that observation. A proposed experiment states what to do next and can test the explanation.

                      Practice in the chapter →

                      Elements of Scalable Web Development by Juho Vepsäläinen.