ProjectsAudio
Podcast hosting with fair download counts
Episodes served from R2, with downloads counted once per listener per day
Example design
- 01Fetch the feedApps poll the RSS feed. The Worker serves it from cache, and new episodes appear when the feed is rebuilt.
- 02Episode requestThe app requests the episode MP3 from the URL in the feed, often with a byte range.
- 03Log itThe Worker writes a data point with the episode, a hash of the IP address and user agent, the range, and the country.
- 04Serve the rangeIt streams the file from R2, honouring the byte range so apps can seek and resume.
- 05Nightly countA scheduled Worker queries Analytics Engine with SQL, collapses repeat requests from the same listener in a day, drops known bots, and stores the daily totals in D1.
- ifAn episode goes viralR2 has no egress fees, so a spike costs Worker requests and R2 reads. The counting rules mean the spike is reported as listeners, not as requests.
The problem
Podcast apps request the same episode many times: to resume, to seek, and to download in pieces. Counting raw requests inflates the numbers, and sponsors know it. The usual standard, the IAB Tech Lab's podcast measurement guidelines, counts repeat requests from the same listener within a day as one download and excludes known bots. A Worker in front of R2 can log every request, and a nightly job can apply those rules.
What it uses
- R2
- Audio files and artwork
- Workers
- Feed, delivery and request logging
- Analytics Engine
- The raw request log, queried with SQL
- Cron Triggers and D1
- The nightly count and the long-term totals
The decisions, and why
- CountingOne per listener per day
- This follows the IAB Tech Lab guidelines that sponsors and ad networks expect.
- PrivacyIP address hashed before writing
- The count needs to tell listeners apart, and it does not need to know who they are.
- SamplingWeighted by the sample interval
- Analytics Engine samples data at very high volumes, so counts are weighted by the interval it records against each row.
- HistoryDaily totals in D1
- Analytics Engine keeps data for three months, and sponsors ask about last year.
Limits to plan around
- Analytics Engine keeps raw data for three months.
- At very high volumes Analytics Engine samples, so totals are estimates weighted by the sample interval.
- A data point holds up to 20 text fields and 20 numbers.
What you get
- Worker for feeds, delivery and logging
- Nightly counting job and D1 schema
- Download report by episode, country and app
- Feed migration from your current host, with redirects
- Tests for the counting rules
Other projects
More video work on Cloudflare.
- Serverless video platformUploads, encoding, captions and signed playback with no servers to run
- FFmpeg encoding on Cloudflare ContainersYour own ladder and packaging, started by an upload, served from R2
- Sub-second live with WHIP and WHEPLive auctions, Q&A and watch-alongs where a few seconds of delay is too much
- Searchable video archiveFind the moment in hours of recordings by what was said
- Thumbnails and previews by URLHover previews, thumbnails and storyboards for a clip library, with no batch jobs
- Instant clips from a live streamViewers clip the moment they just saw and share it while the event is still on
DRM solutions
Three corporate use cases, each with a Widevine demo that runs in your browser and checks what your device supports.
Talk about your video project
Tell us what you are building, or what is not working in the platform you have.
128 City Road, London, EC1V 2NX, United Kingdom
17420568
Registered in England and Wales