From 0e67380b4f57b9943f5ca3d1ee043c5343791565 Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sun, 10 Nov 2024 09:37:18 -0500 Subject: [PATCH] sqlite notes --- go-sql-database/SQLITE_SCALING_NOTES.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 go-sql-database/SQLITE_SCALING_NOTES.md diff --git a/go-sql-database/SQLITE_SCALING_NOTES.md b/go-sql-database/SQLITE_SCALING_NOTES.md new file mode 100644 index 0000000..e00f52b --- /dev/null +++ b/go-sql-database/SQLITE_SCALING_NOTES.md @@ -0,0 +1,7 @@ +# SQLite Scaling Notes + +If you are chosing to implement a SQLite database for each user in a multitenat environment you will want to minimize the number of open database/sql handles (`sql.Open`) that you have at any one time. A strategy you could use is an LRU cache of open handles. This way you will be able to maintain some control over number of resources you are instantiating. + +Migrations may be a tough thing to do with a per user sqlite setup. Consider snapshoting the user's current DB, and creating a copy and applying the migration change. Also, you could apply the migrations when a new DB handle is created on the server side. + +Sqlited hosts a SQLite file behind an HTTP API, this could help reduce the contention of a Single writer to a DB. But also having a DB per user will achieve the same thing.