Crowd levels for a gym chain's member app
Your task
Your gym chain has 250 gyms and 1.2 million members. Members tap their card at the entrance turnstile, about 300,000 times a day. Nobody taps on the way out. A study at a few gyms with exit gates found that a visit lasts 70 minutes on average.
For each gym, the members' app shows how many people are inside right now, no more than 5 minutes out of date. It also shows how many people are usually inside at each hour, with one chart for each day of the week. Each turnstile sends its taps to your servers within a few seconds. When a gym's internet is down, its turnstiles keep letting members in and send the taps later.
What do you store for each tap, and how do you compute the number for right now and the usual-day charts?
It covers
- Occupancy
- Event counting
- Usual day charts