[Feature] Use SQLite in WAL mode by default #730

Closed
opened 2025-12-29 02:23:01 +01:00 by adam · 2 comments
Owner

Originally created by @kradalby on GitHub (Jun 18, 2024).

Use case

SQLite is a very capable database that should easily be able to handle the use cases headscale aim to tackle. We support both SQLite and PostgreSQL and while we recommend SQLite, some users needed to switch to Postgres because 0.22.3 and older scaled poorly.

One of the reasons for this is that we do not run SQLite with the appropriate settings for making it scale better, like setting the journaling mode to write-ahead-log (WAL).

Description

We should investigate, and make headscale use "the best" defaults for SQLite for 0.23.0 and onwards, making it the database of choice.

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

Review the current SQLite default settings, and set better defaults.

We also need to investigate that using WAL is not breaking current setups, and there should be an opt out.

Originally created by @kradalby on GitHub (Jun 18, 2024). ### Use case SQLite is a very capable database that should easily be able to handle the use cases headscale aim to tackle. We support both SQLite and PostgreSQL and while we recommend SQLite, some users needed to switch to Postgres because 0.22.3 and older scaled poorly. One of the reasons for this is that we do not run SQLite with the appropriate settings for making it scale better, like setting the journaling mode to write-ahead-log (WAL). ### Description We should investigate, and make headscale use "the best" defaults for SQLite for 0.23.0 and onwards, making it the database of choice. ### Contribution - [ ] I can write the design doc for this feature - [X] I can contribute this feature ### How can it be implemented? Review the current SQLite default settings, and set better defaults. We also need to investigate that using WAL is not breaking current setups, and there should be an opt out.
adam added the enhancementgood first issuedocumentation labels 2025-12-29 02:23:01 +01:00
adam closed this issue 2025-12-29 02:23:01 +01:00
Author
Owner

@kradalby commented on GitHub (Jun 18, 2024):

#1966 is an issue that might be running into slowness in SQLite without WAL.

@kradalby commented on GitHub (Jun 18, 2024): #1966 is an issue that might be running into slowness in SQLite without WAL.
Author
Owner

@nadongjun commented on GitHub (Jun 20, 2024):

I am working on automation for connection load testing on headscale for a large number of nodes. In version v0.23.0-alpha12 of headscale, while using PostgreSQL, I encountered an same issue where connections were not being created. If the same issue arises during the same tests with the version of SQLite with the WAL option enabled, I will share the analysis using pprof. If necessary, I will also share the test environment setup scripts. Thank you.

@nadongjun commented on GitHub (Jun 20, 2024): I am working on automation for connection load testing on headscale for a large number of nodes. In version v0.23.0-alpha12 of headscale, while using PostgreSQL, I encountered an same issue where connections were not being created. If the same issue arises during the same tests with the version of SQLite with the WAL option enabled, I will share the analysis using pprof. If necessary, I will also share the test environment setup scripts. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#730