Happy to answer any questions. Although SQLite is so dead-simple-but-awesome that you probably don't have any. :D
Anyway, hope you enjoy it and learn a thing or two.
Markus
Happy to answer any questions. Although SQLite is so dead-simple-but-awesome that you probably don't have any. :D
Anyway, hope you enjoy it and learn a thing or two.
Markus
The APIs can even support authentication and authorization with the help of JWT tokens. SQLite may not have row-level security, but even a convention (eg: if a row has user_id column, the JWT must have the same user_id value to get access to a row) would go a long way.
[0]: https://docs.datasette.io/en/latest/json_api.html#the-json-w...
[1]: https://simonwillison.net/2022/Dec/2/datasette-write-api/
https://github.com/subzerocloud/showcase/tree/main/flyio-sql...
Although I definitely would like to use SQLite just for the cost savings for something. Litefs/litestream looks great.
You would have trouble scaling up to fives of authors, though, which would be a deal breaker for any serious production app.
Expensify got 4 million request _per second_ out of a custom SQLite-based setup (on a huge machine, but still): https://blog.expensify.com/2018/01/08/scaling-sqlite-to-4m-q...
I would call those serious production apps.
Nothing fancy, just a small table that holds some blog posts with an ID, a title, some content, and a creation timestamp.
I ran the benchmark with and without WAL enabled on my Macbook Air (2020, M1) with some SSD drive inside. Results:
$ make benchmark
go test -bench=.
goos: darwin
goarch: arm64
pkg: sqlite
BenchmarkWriteBlogPost/write_blog_post_without_WAL-8 6441 191735 ns/op
BenchmarkWriteBlogPost/write_blog_post_with_WAL-8 102559 11205 ns/op
PASS
ok sqlite 3.725s
That's around 89k writes per second in parallel on all available cores with WAL enabled. I know this is a trivial setup, but adjust to your liking. You'll find that SQLite probably doesn't crash and burn with dozens of writes.Yes, I was incorrect when I said SQLite couldn't handle lots of writes quickly; what I should have said is that it can't handle lots of writes from multiple threads quickly.
Here's one for 64 parallel writes: https://gist.github.com/markuswustenberg/f35ab7e191137dca5f7...
$ make benchmark
go test -bench=.
goos: darwin
goarch: arm64
pkg: sqlite
BenchmarkWriteBlogPost/write_blog_post_without_WAL-8 100 16317415 ns/op
BenchmarkWriteBlogPost/write_blog_post_with_WAL-8 1196 1198679 ns/op
BenchmarkWriteBlogPost/write_blog_post_with_WAL_and_Go_mutex-8 58455 17461 ns/op
PASS
ok sqlite 4.557s
1e9/1198679 = 834 writes per second is still far from crash and burn territory when using just WAL mode.Of course, it gets more interesting when there are also concurrent readers, as people are trying out elsewhere in the discussion. But the point still stands: it can handle way, waaaay better than "fives of authors" in a not-at-all scary way.
Without the WAL enabled, I get a around 400req/sec.
edit: clarity
I don't know how it's done in PHP, I would think it's similar.