Digital twin · use case · online
Anomaly detection.
Disruptions, special events and failed sensors, spotted within five minutes on every party's public feed and on the loads agencies share. The alert goes to the agency, the region, and the neighbours whose connections it breaks. Told as one story in seven chapters: an agency joins, an incident is caught, an agency leaves.
- 24 Mpositions a day from 4,559 road vehicles, one every 10 seconds
- 1,680delay and load series, each with its own expected band
- 5 minone value per route per window; an alert after two windows outside the band
- 3 hearthe agency, the region, and the neighbours whose connections break
Chapter 1
An agency joins.
Brampton Transit joins a region that already watches TTC and MiWay. Five steps, from a signature to the first loads. Names are an illustration: no agency has agreed to anything.
- This contract
- live loads v1: boardings, alightings, visits and the mean load on board by route, direction, stop and 5-minute window; sent every 5 minutes, within 2; counts of people only; read by the detector; kept 24 hours on the live lane
- What comes back
- Alerts on your own feed and vehicles, and neighbours' delays that break your connections
- Join without loads
- A feed-only party is watched and alerted too; it just gets no crowding alerts
Chapter 2
How it works: feeds in, alerts out.
Press Play, or tap a step below the picture. Highlighted arrows cross an account border: feeds and loads coming in, alerts going out. Each step names the general part and the recommended AWS service beside it.
Two ways to find one
Rules
- Feed gap: nothing from a feed or a vehicle.
- Frozen: a vehicle in service that does not move.
- Jump: a position too far from the last one.
- Dead counter: a stop whose counts read nobody while buses pass; the vehicle check runs at home.
Expected against seen
- Each vehicle matched to its timetable: how late.
- One value per route and direction every 5 minutes.
- A band per series: what is usual at this hour.
- Two windows outside it: an alert.
Who is affected
- Shared stops on the late route, from the registry.
- Last night's transfer totals: who changes there, when.
- Names the neighbour, not the rider.
- No transfer totals, no neighbour named.
What an alert says
| Field | Example | Note |
|---|---|---|
| kind | feed_gap · frozen_vehicle · position_jump · dead_counter · delay_anomaly · load_anomaly | rules the first four; the detector the last two |
| party | TTC | whose feed or vehicle |
| where | route, direction; vehicle or stop for a rule | as the party's own feed names them |
| since | 17:05 | the first window outside |
| expected / seen | 2 to 6 min late / 19 min late | the band and the value, for the detector's alerts |
| affects | MiWay, at the stops the routes share | from shared stops and transfer totals; empty when unknown |
| label | snow · event nearby | planned: weather and events are not sourced yet |
Chapter 3
An incident, town by town.
The region as a small world. One evening a TTC route runs late and MiWay riders are about to miss their connection. Follow it from the feeds to the red flags. Press ? for the legend, ⛶ for full screen.
Chapter 4
The architecture: what runs where.
Every part, with AWS's own icons, accounts as boxes. Blue arrows are the only crossings. The shared parts are drawn because every use case is costed with them.
Reading it, left to right
- Two things come in. Public feeds, which the region fetches itself every 10 seconds. And 5-minute loads, which the agency's adapter sends: counts of people, nothing about a rider.
- One live lane. Both land on one ordered stream, kept 24 hours under the region's key, and are archived as a TIDES table for replays.
- Two readers. The rules look at each vehicle against its own last state. The second reader matches each vehicle to its timetable and writes how late and how full each route is, every 5 minutes.
- A band per series. A built-in detector learns what is usual for each route at each hour. Nothing is trained by us; a pre-trained model is the costed upgrade.
- The alert is built once. Kind, party, where, since, expected and seen, and who is affected: neighbours that share a stop with the late route and exchange riders there.
- Three hear. The agency it happened at, the neighbours named, and the region's own map. Each agency receives alerts in its own account and routes them as it likes.
- When we fail, we say so. A heartbeat tells a dead feed from a dead poller. An alert nobody took is held and retried. Both page the region's on-call, never a control room.
- Planned, dashed. Weather and event calendars would label an alert (snow, a game). They are not sourced and not costed.
When something fails
| What fails | What happens | Who is told |
|---|---|---|
| A party's feed goes silent | The feed-gap rule fires; delay alerts for that party stop and show as unknown, never as normal | that party; neighbours see unknown |
| The region's poller stops | The heartbeat alarm fires within a minute; no feed-gap alerts are sent, since the feeds are fine | the region's on-call |
| Loads arrive late or in the wrong shape | A rule fires; crowding alerts pause for that party; delay alerts carry on | the sending agency |
| A receiver does not take an alert | Retried for an hour, then held 14 days and replayable; the live feed still shows it | the region's on-call |
| A new party, or a new route | Rules work from the first minute; a band needs two weeks of history before it may alarm | nobody; the series is marked learning |
Chapter 5
Who owns what.
| Data | Lives | Key | Who may read | On leaving |
|---|---|---|---|---|
| Passenger counter records | agency account | agency | the agency only | untouched |
| Public feeds, archived | region account | region | the party itself; anyone under a contract | that party's part deleted, old snapshots expired |
| 5-minute loads | the live lane, 24 hours | region, on arrival | the detector only | gone within 24 hours |
| Delay and load per route | region account, as metrics | region | the detector; the region's views | alarms and bands deleted at once; values age out in 63 days |
| Last state per vehicle | region account | region | the rules only | deleted |
| Alerts | the region's log, 13 months; a copy with each receiver | region; each receiver's own | the party it concerns, the region, neighbours named on it | copies already sent stay with receivers |
| Who-is-affected lookup | region account | built from transfer totals under each agency's key | the alert builder only | revoke the key: gone at the next nightly rebuild |
- No card, no rider
- Nothing in this use case reads a fare card. Loads are counts from door sensors. The only fare-derived input is last night's transfer totals, already small-cell protected at home.
- The trade-off we accepted
- Loads rest under the region's key, not the agency's, because they live 24 hours and name nobody. The price: CloudWatch keeps metric values until they age out and offers no delete, so "at once" is true of alarms, state and archive, not of the last 63 days of route averages.
- Decisions
- 3, 29 to 32, 41 to 43, 51 to 54
Chapter 6
What it costs: cloud only.
This use case on its own, on the seven-party scenario, at AWS list prices, with the shared parts included in full. Every box in the detailed picture has a line in the model; the planned weather input does not.
- Whole region, per year
- $9.3k low · $17.4k typical · $29.4k high
- Within 1 minute instead
- $18.5k a year, typical: about $1.1k more
- With Chronos
- $19.8k a year, typical: one always-on model endpoint
- What drives it
- The per-series price of metrics and anomaly alarms (1,680 series), then the live lane and its poller
- One full agency
- $29 a year for the adapter; a feed-only party pays nothing
- Against the earlier figure
- $17.3k in the first model; $103 a year more here for the second reader, timetables, lookup, alert log, retry queue, heartbeat, a key and the leaving job
- Source
- explorations/anomaly-cost/model.py, on top of explorations/dt-cost/model.py
Trade-offs
| Choice | Chosen | Instead of | Why |
|---|---|---|---|
| Alert speed | Within 5 minutes | Within 1 minute | At 1 minute only 61% of route-windows in the sample hold three stop visits to take a median over, against 96% at 5; the cloud saving is small, the false alarms are not |
| How long a miss must last | Two windows | One | In the sample one window gives about four times the alerts of two |
| Detector | CloudWatch's built-in anomaly detection | A pre-trained model (Chronos) on SageMaker | No model to run; inference only, as the instructors asked; Chronos costed as the upgrade |
| Inputs | Public feeds plus shared loads | Public feeds only | Loads show special events and dead counters; a party sharing none still gets the rest |
| Whose feeds are read | Registered parties only | Every public feed in the region | Public is not the same as agreed; leaving must be able to mean not watched |
| Who hears | Agency, region and affected neighbours | The agency only | A delay on TTC breaks MiWay connections; that is the federated value |
| Where loads rest | The region's key, 24 hours | The agency's key, like transfer totals | Counts that name nobody and expire in a day do not need a revocable key |
Chapter 7
An agency leaves.
The mirror of joining. Brampton switches its adapter off; the region stops reading its feeds and deletes what it can at once. What cannot be deleted at once is said plainly.
Decided
- Decisions 24, 29 to 35, 38 to 40, 51 to 53: see the decisions page
- Drawn around 5-minute alerts; 1 minute stays priced
Open
- Decision 54, proposed: registered parties only, loads under the region's key, the failure paths, two windows before an alert
- Whether a leaver's alerts are purged from the region's log before 13 months
- Weather and event data, named by the instructor, not yet sourced
- Private networking and threat detection are not drawn
Caveats
- Positions are estimated from the sample's blocks, not measured pings
- Series counts assume 70 routes per agency; TTC alone has more
- CloudWatch's detector is per series and knows nothing about the network
- A stale timetable makes every delay wrong; the check for it is not drawn
- Nothing deployed; costs are a design estimate, not a quote