Aller au contenu
#0742
SqliteCronContainers

Invoice morning moves the heavy query into RAM

First of the month, 6:00 AM. A cron entry starts the billing rollup: one heavy query that aggregates a month of usage rows into invoice lines. It builds large temporary b-trees, and for two months those temp files hammered the same disk your app serves from: customers could feel invoice morning.

The fix is one line in the rollup script: SQLITE_TMPDIR=/ramdisk/tmp. The temporary structures now build in /ramdisk, the RAM-backed scratch space every container carries: an order of magnitude faster than the disk, and nothing there needs to survive, because temp trees are regenerated on every run.

The rollup finishes before 6:04. The app never notices. The invoices go out on the same cron that computed them.

Scratch work belongs in RAM; the disk is for things you keep.