Chaima Gharbiai · data
← projects

Paris Transit Reliability

python · duckdb · parquet · oracle cloud · source on GitHub

I wanted to know how reliable public transport in Paris really is. Not the timetable, what actually happens: how late each line is, at what hour, and how often trips get cancelled.

Île-de-France Mobilités publishes it, in real time, through their PRIM API: for every bus, metro, tram and train, when it’s expected at its next stops. But it’s only the present. Nobody keeps the history, so if you want to measure reliability, you have to record it yourself. So that’s what I do, every 2 minutes, since October 2026, on one free server.

It’s also how I’m learning data engineering properly: every important decision is written down with what I measured, and I build it in levels, from collecting the data up to predicting delays.

How it runs

PRIM APIthe whole networkPollerevery 2 mingzip snapshot,as receivedBronzeraw fileskept 7 days~5 GB a daySilverevery hour1 row per stop callParquetGoldevery hourline × Paris hourdelays, cancellationsArchiveevery night, older than7 days: zstd, checkedDuckDB, one free VM, cron

Four small jobs, started by cron. Each one finds by itself what is left to do, so a missed run just catches up at the next one.

The layers have names that are common in data engineering: bronze is the data exactly as it came, silver is cleaned and one row per thing, and gold is the numbers people actually read. This way of stacking them is called a medallion architecture. Everything is rebuilt from bronze if I find a bug later, I just replay it (that idea is called Kappa).

Everything runs on an Oracle Cloud free VM: 2 cores, 12 GB of RAM, no budget at all. The processing is done with DuckDB, SQL directly on files, because the data fits on one machine and something like Spark would only be slower here.

Part 1: collecting without losing anything

One snapshot is the whole network at that moment: about 15,000 journeys and 180,000 stop calls, up to 88 MB of JSON. I’m allowed 1,000 requests a day, and polling every 2 minutes is 720, so there’s room for retries but not a lot.

The first version lost 14 snapshots in 8 days, mostly connections dropped in the middle of a download. So the poller got rules:

Attempt 1timeout 5 s / 15 swait 5 sAttempt 2wait 10 sAttempt 3Always writes a recordok: the snapshot + its metadatafailed: metadata + the error bodyso every gap is visibleretry only on drops, timeouts, 5xx and 429 · max 90 s per run · max 230 retries a day, under the 1,000-request quota

A dropped download is retried, a mistake on my side is not. And a failed run still leaves a record, so a gap is never silent.

Since then: 99.2% of 13,014 runs captured and 0 crashes. Almost all the failures came from two outages on the provider’s side:

00h03h06h09h12h15h18h21h0102030Dec 1Dec 2failed runs per hour (out of 30), UTC

On Dec 2 at 6h, 28 runs out of 30 failed even with retries.

That outage taught me something: retries saved 50 runs, but 90 runs failed after 3 attempts anyway. Retrying while the server is down just spends the budget. So the next change is to stop retrying while it’s down and only check if it’s back, which is called a circuit breaker.

Part 2: keeping it, at 11.5% of the size

Raw, it’s about 2.8 GB a day (5 GB since the provider added more data in December), and the disk is 193 GB. So after 7 days the raw has to go somewhere smaller.

My first plan was to only store what changed between two snapshots. Before building it, I measured: between two snapshots 2 minutes apart, 32% of the data changes, because every active bus gets a new prediction. Too much to be worth the extra code. So instead, each hour is packed as one stream with zstd and a long window, which sees the repetition between snapshots. Result: 11.5% of the original size, and no diff code that could lose data.

Raw hour30 snapshots7+ days oldPacktar + zstdone streamRead it backunpack every fileCompareSHA-256 ofevery fileDelete rawKeep rawall matchone differs

Deleting is the only step that can't be undone, so it only happens after every file is checked.

867 hours were checked and deleted this way, with 0 failures.

Part 3: cleaning, one row per stop call

The same bus at the same stop shows up in about 16 snapshots, with its prediction moving a bit each time. For reliability I only need how late it really was, so silver keeps the last known state of each stop call.

the same bus, the same stop, seen in every snapshot (2 min apart)expected 19:24 · 19:24 · 19:24 · … · 19:25 · 19:27← the one silver keepsone hour of snapshots3.2 million observationssilver: last known state205,000 rows, about 16 times less

One stop call, followed through the snapshots. An hour before, the prediction is just the timetable; the real delay only shows close to departure.

Then each call gets one category: measured, cancelled, no report, no planned time, or implausible. Implausible is when a whole journey is more than an hour late or 10 minutes early on average, because I found a few operators sending series of broken times. Only the measured calls get a delay, and cancelled calls are kept for the cancellation rate.

Part 4: the numbers people read

Gold is one row per line and per hour, in Paris time, with the number of calls, the cancellations, and the median and p90 delay. p90 means 1 call in 10 is later than that. A day is only written when all its hours are there, so nobody reads half a day thinking it’s a whole one.

C0182133.4 minC0225731.1 minC0085029.1 minC0231728.7 minC0242226.7 minC0018923.2 minC0086522.1 minC0132722.1 minC0135320.4 minC0183719.2 minC0283518.9 minC0148218.7 minC0021617.7 minC0067017.5 minC0154317.1 min0102030p90 delay (minutes), Nov 24 to 26, Paris time

The worst lines over three weekdays. Line names come next, from the timetable data.

Before putting this chart here I checked the worst line, because 33 minutes looked too big to be true. The late calls come from a lot of different buses, there’s no jump at exactly 60 minutes (that would be a time zone bug), and the predictions were fresh. So the delays are real. One thing to know about percentiles: they don’t add up, so a p90 over three days is computed again from silver, never averaged from the hourly ones.

Things that surprised me

  • The provider changed its format and didn’t tell anyone. My disk grew 4 GB in 2 days, and that’s how I found out. I wrote about it: My data source changed its format and didn’t tell anyone.
  • Every bus changes every 2 minutes. I expected snapshots to be mostly the same. They’re not, and that changed how I store them.
  • Old raw files had error pages saved as data. The archive job found them, refused to delete anything, and I fixed them by hand.

Decisions

Every important choice is a short decision record in the repo: the options, what I measured, and what would make me change my mind.

# Decision
1 Kappa: one processing path, history by replaying bronze
2 Store only the changes between snapshots (replaced by 6, after measuring 32%)
3 Plain files on the VM through fsspec, so moving to S3 later is a config change
4 Retries, timeouts, a daily retry budget and a record for every run
5 DuckDB, not Spark, for one machine and about 50 MB of silver a day
6 Hourly zstd archives, checked file by file before deleting anything
7 Silver keeps the last known state of each stop call

All the records are in the repo.

Next

Real line names from the timetable data (GTFS), a small live dashboard, automatic checks on the data quality, and an orchestrator instead of cron. After that, delay prediction, trained on the actual departure times the provider started sending in December, and then streaming, so the predictions happen as each snapshot arrives.