Exercise 3: Why Multiple Workers Introduce a New SQLite Concern — Possible Solution ==================================================================== WHY THE EXPRESS SIBLING NEVER FACED THIS ------------------------------ Food Tracker (React + Express) runs as a single Node process, even in production - there's only ever one process holding a connection to the SQLite database file at any given time, so there's no possibility of two separate processes both trying to write to that same file simultaneously. WHY MULTIPLE GUNICORN WORKERS CHANGE THIS ------------------------------ -w 4 launches four genuinely separate operating-system processes, each with its own independent database connection to the same foodtracker.db file. Under real concurrent write activity, more than one of these processes could attempt to write to the file at close to the same moment, and SQLite can respond to that kind of contention with a "database is locked" error - a real possibility this single-process Express deployment structurally cannot encounter. HOW THIS CONNECTS BACK TO CHAPTER 10 ------------------------------ Chapter 10 already explained that SQLite has no real connection pool the way a networked database like PostgreSQL does, since it's a local file rather than a server accepting many managed connections. This chapter's multiple-worker lock-contention risk is the concrete, production-scale consequence of that same underlying limitation - SQLite was never designed around many independent processes writing to it concurrently at real scale, which is exactly why a busier deployment would eventually be a genuine reason to move to PostgreSQL instead. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains why the single-process Express deployment never faces this risk, correctly explains why multiple gunicorn worker processes introduce real write contention that a single process cannot have, and correctly connects this concrete production risk back to Chapter 10's own more general point about SQLite lacking a real connection pool.