Hypothetical case study: month-end billing job charged 300 customers for the wrong month
The article describes a hypothetical case study about an API company that bills customers monthly for usage plus a base fee. Its month-end job, scheduled via cron on a UTC worker server, selected the wrong billing period because the query for "last month" depended on the server's time zone and current time. As a result, roughly 300 customers were charged for the wrong month. The author outlines fixes: pinning session time zones to UTC, enforcing one invoice per customer per period with database constraints and idempotency keys, processing each customer as a separate job, and running a pre-flight check that pauses billing if totals swing more than 50%. The core lesson is that billing periods should be explicit data rather than values derived from the current time.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in