When should I move my game from SQLite to PostgreSQL?
Asked by
suitcase_wheel
I built a small game at cluebolt.com as a learning project. It currently uses Flask for the API, SQLite for the backend database, and a lot of JavaScript for the game logic. Everything works, but I'm unsure when it's worth refactoring or replacing SQLite with a more traditional production database such as PostgreSQL. My initial thought was to wait until the current setup causes a real problem, then upgrade. Is that generally the right approach, and what warning signs or technical limitations should I watch for?
Answers
I usually start projects with PostgreSQL in a Docker container because it keeps local development closer to the eventual production environment. Thatโs mostly a workflow preference, thoughโnot proof that SQLite is unsuitable. For a small game, SQLite may be perfectly adequate.
Reply to this answer
SQLite can absolutely be used in production, especially for a small application. If the app is handling your current traffic comfortably, thereโs no need to migrate just because PostgreSQL is more commonly associated with production. Waiting until you have a concrete need is reasonable.
Reply to this answer
Set up observability before making a major infrastructure change. Track response times, error rates, database-lock errors, query duration, disk usage, and request volume. If a metric stays above a threshold, investigate and profile the actual bottleneck before changing the stack. Refactor when the expected benefit justifies the implementation and maintenance cost, not simply because the project has grown.
Reply to this answer
A useful middle ground is to add a data-access layer now. Keep database queries and persistence logic in one part of the application instead of scattering SQL throughout the code. Then your game code works with normal objects or service methods, making it much easier to switch database engines later. PostgreSQL would be a sensible destination if you eventually need one.
Reply to this answer
The main reasons to move away from SQLite usually arenโt raw request counts. Consider migrating when you need multiple application servers writing to the same database, when concurrent writes become a bottleneck, or when your hosting setup uses temporary storage that could erase the database during a redeploy. Enabling WAL mode can also improve SQLiteโs behavior for many workloads. Using SQLAlchemy and a proper migration tool now will make a future move to PostgreSQL much easier.
Reply to this answer
Add your answer
Answers are reviewed before publication.
suitcase_wheel: I tested it at roughly 420 requests per second, and my highest number of concurrent users so far has been around 12. I donโt expect the request volume to become a problem anytime soon.