~learn.
0:00 / 1:37
Side quest 24 · Airbnb

One homestay, three sites, and a file read every 3 hours

transcript

Meera sells her Goa homestay on three different sites. The only link between their calendars? A file each site reads every few hours.

At 9:50, Airbnb reads her calendar file. Its import cycle is 3 hours. At 10:05, another site sells one of her nights. Airbnb is blind to it until 12:50. That night still looks free. On average, a change waits an hour and a half to be seen.

Is polling expensive? Four million feeds. Every 3 hours. That's only 370 fetches a second. The problem isn't load. It's the window.

So poll by risk. Free nights soon, on dates people search? Fetch often. Ask only if it changed. Most answers are 304, not modified. Almost free. Diff by source. A block from one feed is replaced only by that feed. And when a guest presses Reserve? Fetch that file right then. About a one second timeout.

But here's the catch. The other site breaks, and serves an empty file. Trust it, and months of taken nights look free. Double bookings. So keep the last good snapshot. Mark the feed unhealthy. Alert the host. A big drop must be seen twice before nights are freed.

Polling's cost isn't the load. It's the blind window. So poll by risk. Refresh at Reserve. And never trust a sudden empty file.

Full breakdown in the lecture.