Jellyfin Database SQLite vs PostgreSQL & Valkey #17211
Replies: 5 comments 19 replies
|
Couple of basic overview questions : 1- With 12.0 Release, does jellyfin now support PostgreSQL as a replacement for sqlite and thus offer improvements in performance with large libraries and large cocurrent users. 2- Has there been any shift in the sentiment to support postgreSQL now as a replacement for sqlite? My understanding is that sqlite is a major bottleneck in this scenario and a full DB like PostgreSQL will eliminate the bottlenecks caused by sqlite |
|
This sounds overly complex for the vast majority of Jellyfin deployments (has jf ever stated a goal of regularly supporting 100+ concurrent users!?). In the reality where basic features like LiveTV are breaking in new ways every release, prioritizing complexity for the sake of edge case scaling use cases seems misguided. An "ORM and choose" approach would prob get everyone close to what they want but from previous discussions that sounded like a significant effort as well. |
|
I think there is a sensible middle ground here. On one hand, I completely agree with the collaborator (@Shadowghost) that designing Jellyfin to support 5k to 10k concurrent users is out of scope. Jellyfin is first and foremost a private, home media server. Bundling a heavy database like PostgreSQL by default, or rewriting core structures just to support commercial-scale traffic, doesn't align with the project's focus of being easy and lightweight to deploy. SQLite is the perfect default for 95% of users. On the other hand, the filesystem conflicts (like SQLite WAL on ZFS/Btrfs) and database locks can be a real friction point, even for small family deployments. Providing the optional capability to hook up an external database seems like the ideal compromise. It gives power-users the freedom to use PostgreSQL or Valkey if their hardware or library demands it, without cluttering the simple out-of-the-box setup for everyone else. |
|
I tend to agree with your point. I have a library that mixes images and videos, containing about 60,000 media files. |
|
This might be a nice middle ground when it hits a stable version https://github.com/tursodatabase/turso. I agree though supporting postgres would be nice. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Rethinking Jellyfin's Database: SQLite, Copy-on-Write Filesystems, & Performance at Scale
Summary
After several years of testing Jellyfin, I've found a class of problems that I believe are causing downstream pain for users and server administrators without getting much attention. The most significant one, in my view, is the database choice - specifically the way SQLite's write-ahead log interacts with copy-on-write filesystems. This post lays out what I've observed, the testing I've done, and a proposal for how Jellyfin might address it.
The Core Issue: SQLite on Copy-on-Write Filesystems
To be clear up front: I'm a big fan of SQLite. I think it's a smart and effective database for Jellyfin, especially given the project's ethos of allowing quick and easy installation. The problem isn't SQLite itself - it's an interaction that has largely gone unnoticed.
From what I can see, the majority of people installing Jellyfin are doing so on Linux-based operating systems, and a significant portion of them are using copy-on-write (CoW) filesystems. SQLite's write-ahead log (WAL) conflicts with the copy-on-write nature of these filesystems. For smaller installations, this overhead is tolerable. For larger libraries, it changes drastically.
Many of you have probably seen the complaints from people with libraries holding over 2,000 unique items, reporting that search query latencies have climbed above five seconds. Part of this is due to under-the-hood changes after version 10.7, but the filesystem interaction is a major and under-discussed contributor.
Testing and Results
I've seen significant performance gains simply by moving my config directory from a ZFS-backed NVMe SSD to an ext4 NVMe SSD.
To isolate the database specifically, I took the exact path containing the Jellyfin database and moved it onto a small 16 GB Intel Optane drive. On that drive, I tested three filesystems: Btrfs, ZFS (with suggested changes for SQLite), and ext4.
The results were stark:
The pattern is consistent: the copy-on-write filesystems impose a large latency penalty on database operations, while ext4 does not.
Proposal
Based on all of this, I think now may be a good time to reconsider how Jellyfin handles its database. A couple of options:
-1. Putting the current Jellyfin database in its own subfolder so in order to put it on faster storage the entirety of plug-ins need not be remapped.
Either approach would let administrators with larger libraries - or those running on copy-on-write filesystems - avoid the WAL/CoW conflict without abandoning the simplicity that makes Jellyfin easy to install in the first place.
All reactions