News for hackers. Stuff that matters.
Re:Using SQLite as storage for web server static content by Szpadel on Sunday October 27, 2024 @02:10PM (#41964396)
I don't get argumentation, swapping "current" symlink to point to another version worked for years as atomic way to swap 2 site versions

using sqlite for static content might have other benefits, but i don't think that this is the main one

Re:Using SQLite as storage for web server static content by ajayvk on Sunday October 27, 2024 @02:16PM (#41964456)
Swapping symlinks is possible. Using a database (sqlite specifically) has other benefits, like being able to do deduplication, backups are easier, compressed content can be stored, content hash can be stored etc.
Re:Using SQLite as storage for web server static content by webstrand on Sunday October 27, 2024 @02:37PM (#41964603)
Sqlite isn't necessarily easier to backup than a filesystem. I've got a fairly large (~60GB) sqlite that I'm somewhat eager to get off of. If I'd stuck with pure filesystem then backing up only the changeset would be trivial, but with sqlite I have to store a new copy of the database.

I've tried various solutions like litestream and even xdelta3 (which generates patches in excess of the actual changeset size), but I haven't found a solution I'm confident in other than backing up complete snapshots.

Re:Using SQLite as storage for web server static content by fanf2 on Sunday October 27, 2024 @02:41PM (#41964637)
You might like the new sqlite3_rsync command https://www.sqlite.org/rsync.html
Re:Using SQLite as storage for web server static content by simonw on Sunday October 27, 2024 @03:01PM (#41964760)
Yeah that looks ideal for this exact problem, because it lets you stream a snapshot backup of a SQLite over SSH without needing to first create a duplicate copy using .backup or vacuum. My notes here: https://til.simonwillison.net/sqlite/compile-sqlite3-rsync
Re:Using SQLite as storage for web server static content by webstrand on Sunday October 27, 2024 @03:22PM (#41964918)
Maybe that tool just doesn't fit my use-case, but I'm not sure how you'd use it to do incremental backups? I store all of my backups in S3 Glacier for the cheap storage, so there's nothing for me to rsync onto.

I can see how you'd use it for replication though.

Re:Using SQLite as storage for web server static content by simonw on Sunday October 27, 2024 @06:23PM (#41966174)
If you want incremental backups to S3 I recommend Litestream.
Re:Using SQLite as storage for web server static content by hedgehog on Sunday October 27, 2024 @07:34PM (#41966553)
What do you do about compaction?
Re:Using SQLite as storage for web server static content by webstrand on Monday October 28, 2024 @09:50AM (#41970988)
zstd, though that only shaves off a few GB total.
Re:Using SQLite as storage for web server static content by hedgehog on Monday October 28, 2024 @07:28PM (#41977687)
Oh, I mean like with the vacuum command. As the databases get larger it can become unwieldy.
Re:Using SQLite as storage for web server static content by webstrand on Tuesday October 29, 2024 @01:02PM (#41986619)
I just tried it, it only recovered a few MB
Re:Using SQLite as storage for web server static content by hedgehog on Tuesday October 29, 2024 @02:32PM (#41987864)
Aha, so not much need. I've always avoided SQLite for larger databases due to the extra space needed to allow compaction, maybe not a real problem in most applications though.
Re:Using SQLite as storage for web server static content by warble on Sunday October 27, 2024 @02:25PM (#41964531)
All of this is easily done on a filesystem too. I would assume this is a performance tradeoff rather than features?
Re:Using SQLite as storage for web server static content by borsecplata on Sunday October 27, 2024 @02:28PM (#41964548)
Deduplication can be achieved the same way as in sqlite, by keeping files indexed by sha256. There are also filesystems who provide transparent compression.

Seeing as you need some kind of layer between web and sqlite, you might as well keep a layer between web and FS who nets you most or all of the benefits.

Re:Using SQLite as storage for web server static content by theturtle32 on Sunday October 27, 2024 @04:34PM (#41965449)
You could also employ a different filesystem like ZFS or btrfs in tandem with the symlink-swapping strategy to achieve things like deduplication. Or, once you have deduplication at the filesystem level, just construct a new complete duplicate of the folder to represent the new version and use renaming to swap the old for the new, and poof -- atomic changes and versioning with de-duplication, all while continuing to be able to use standard filesystem paradigms and tools.