Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    S

    Stephen Margheim

    fractaledmind.github.io · Personal blog · on HN since 2023

    Stephen Margheim writes about running SQLite in production with Rails, including performance tuning, concurrency, backups and Litestream.

    Visit blogHN submissions
    DatabasesWeb DevelopmentSystems & Performance
    What HN says

    HN commenters recommend his SQLite on Rails series as where they learned most of what they know, though one finds it works around SQLite's write limits.

    Stats for nerds
    16HN people shared it
    13linked in comments
    477story points
    Feb 2025last shared
    2024people per year2025

    Top posts on HN

    1. 1
      SQLite on Rails: The how and why of optimal performance
      6 people · 279 points · first shared 2024 · 96 comments on HN
    2. 2
      How (and why) to run SQLite in production
      1 person · 155 points · first shared 2024 · 80 comments on HN
    3. 3
      Supercharge the One Person Framework with SQLite
      4 people · 30 points · first shared 2024 · 10 comments on HN
    4. 4
      Fine-tune your SQLite database for production web app usage
      1 person · 3 points · first shared 2023 · Discussion on HN
    5. 5
      Select Dropdown for Polymorphic Associations
      1 person · 2 points · first shared 2024 · Discussion on HN
    6. 6
      PlanetScale-style database branching for Rails and SQLite with 2-lines of code
      1 person · 2 points · first shared 2023 · 1 comments on HN
    7. 7
      Solid Errors
      1 person · 2 points · first shared 2024 · Discussion on HN
    8. 8
      Setting Up Litestream on Debian Linux with DigitalOcean Spaces
      2 people · 1 points · first shared 2023 · Discussion on HN
    9. 9
      Enhancing your Rails app with SQLite: Installing extensions
      1 person · 1 points · first shared 2023 · Discussion on HN
    10. 10
      Loading SQLite Extensions in Rails
      1 person · 1 points · first shared 2023 · Discussion on HN

    What HN people wrote when they linked it

    • simonwNov 2024

      Missing from this, but very important: you can connect to the same SQLite database file multiple times inside the same process (e.g. in different threads) but you can also connect to the same SQLite database file from multiple different processes on the same machine (with the same filesystem - NFS will lead to all kinds of nasty problems).

      Easy way to prove this to yourself: run two different terminals, run "sqlite3 data.db" in each one, run create table / insert / update queries in one and watch the results become visible to selects in the other.

      Changes only become visible to other connections after they have been committed.

      In default mode any writes will hold an exclusive lock and will cause any reads to be blocked waiting for that lock. In WAL mode reads can continue even while writes are taking place.

      Writes can only run one at a time, but can queue waiting for each other to finish - and since most writes take microseconds to run this is very rarely a problem.

      The most complicated thing to understand is the need to use BEGIN IMMEDIATE TRANSACTION in concurrent environments to avoid the occasional SQLITE_BUSY exception. The best explanation I've seen of this is here: https://fractaledmind.github.io/2024/04/15/sqlite-on-rails-the-how-and-why-of-optimal-performance/ - search for SQLITE_BUSY.

    • abbbiMar 2024

      another article praising sqlite in production and working around a known sqlite limitation: concurrent writes. As they link in the article:

      > But, my favorite feature of the gem is its improved concurrency support.

      > [..] https://fractaledmind.github.io/2023/12/11/sqlite-on-rails-improving-concurrency/

      Really. At the point you are experiencing database locked in your productive app that uses sqlite as backend, i would strongly suggest to use another database backend that was designed with concurrent writes in mind.

      Nothing against sqlite in production, its nice, as long as your workload meets its feature set.

    • ncrucesNov 2024

      There are benefits to having a single writer connection (and multiple readers).

      One is that you can get fairer and more efficient locking. The (interruptible) file lock APIs that SQLite uses lead to a lot of sleeping and retrying that wastes time, and is not very fair.

      https://fractaledmind.github.io/2024/07/19/sqlite-in-ruby-backoff-busy-handler-problems/

      Another some APIs, like the backup API, work better if they can track writes, and (e.g.) backing up from the single writer connection helps there.

    • skybrianMar 2024

      I went through this presentation looking for "how do you do backups" and it glosses over it. But the author blogged about that separately [1].

      It seems he uses Litestream with DigitalOcean Spaces for this. Looks like they start at $5 per month for 250 GB [2]. Would that be the best way for a hobbyist to get started?

      [1] https://fractaledmind.github.io/2023/09/09/enhancing-rails-sqlite-setting-up-litestream/ [2] https://www.digitalocean.com/pricing/spaces-object-storage

    • ozimOct 2024

      I don't know about 1TB data but I think it was used in some missile system so I would say yes for mission critical data, not sure if we think about mission critical in the same terms.

      Edit: by pure chance I hit that just a moment ago: https://fractaledmind.github.io/2024/10/16/sqlite-supercharges-rails/

    • anze3dbJun 2024

      Stephen has a whole series of blog posts on SQLite (in Rails) that I highly recommend. I've learned most of what I know about SQLite from him!

      https://fractaledmind.github.io/2024/04/15/sqlite-on-rails-the-how-and-why-of-optimal-performance/

      Also, hello Lee! I miss being in a Slack with you!

    Related

    Turso Blogturso.tech102 people

    Working on databases from prison

    Turso Blog
    Company · last shared 2026
    David Rothlisdavid.rothlis.net19 people

    Simple declarative schema migration for SQLite

    David Rothlis
    Personal · last shared 2026
    Feldera Blogfeldera.com21 people

    The Pain That Is GitHub Actions

    Feldera Blog
    Company · last shared 2026
    Simon Willison's TILstil.simonwillison.net111 people

    One-liner for running queries against CSV files with SQLite

    Simon Willison's TILs
    Personal · last shared 2026
    Anton Zhiyanovantonz.org96 people

    SQLite is not a toy database

    Anton Zhiyanov
    Personal · last shared 2026
    Charles Leifercharlesleifer.com74 people

    Nginx: a caching, thumbnailing, reverse proxying image server

    Charles Leifer
    Personal · last shared 2026
    Andrew Godwinaeracode.org68 people

    Hello, This Is London Rising: 3D Printing Maps from LIDAR Data

    Andrew Godwin
    Personal · last shared 2025
    Sylvain Kerkourkerkour.com85 people

    Backdooring Rust crates for fun and profit

    Sylvain Kerkour
    Personal · last shared 2026