Course lesson 39 · Advanced Durable Objects
Overview of realtime link tracking
This section designs a live map of link clicks using one Durable Object per account. The redirect service keeps its existing queue path for background processing, while also sending geographic click data directly to the object so map updates avoid queue delay. Each object combines a small SQLite history with connected WebSocket clients, allowing one incoming click to be broadcast to several viewers.
Primary source: course video 39 · Supplied English subtitles · 00:06:21.
Understand the idea
- Account identity chooses the Durable Object instance, so each account has its own click state and connected viewers.
- SQLite provides stored click history; WebSockets provide live delivery. These solve different parts of the feature.
- The proposed design includes an initial history message for a newly connected viewer, followed by updates shared with all viewers.
- Offsets represent boundaries in retained click history and help prevent the object’s table growing indefinitely.
What the course does
- Locate the new tracker alongside the existing workflow scheduling object in the system diagram.
- Send click metadata to both the existing queue and the account’s tracker after redirect handling.
- Store geographic fields and click time in the tracker’s SQLite table.
- Plan history delivery for new viewers and broadcasts for existing viewers.
- Track history boundaries and active connections as separate forms of state.
Watch for
- The instructor explicitly describes this implementation as educational overkill and suggests database polling could be simpler for this feature.
- Initial history replay is proposed here; later demonstrations show new tabs empty until another click, so the outline should not be mistaken for fully implemented behavior.
- Added advice: the informal estimate of hundreds of clients is not a verified capacity guarantee.
Recall before revealing
Why retain both the queue and a direct Durable Object call?
Reveal the explanation
The queue supports existing background processing, while the direct call lets the live map receive updates without waiting for queue consumption.
Try it
Draw the path of one click and one newly connected viewer, labeling storage and live delivery separately.
Check your result
Your drawing includes the redirect, queue, account-scoped object, SQLite table, and all connected viewers.
Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.
Rewatch only what you need
Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.
- 00:00:05 — SQL and WebSocket learning goals
- 00:02:09 — Account-scoped tracker design
- 00:03:43 — Proposed startup history delivery
- 00:05:19 — Offsets and retained state
Companion primary documentation: Durable Objects WebSockets. For recorded API names, commands, limits, and prices, check the version you use.