GoLang + SQLite on Fly.io with LiteFS: a Quick Benchmark

Graham Jenson
Maori Geek
Published in
2 min readJul 17, 2023

--

I am thinking about using GoLang and SQLite for a project. Looking around I found a presentation by Ben Johnson from Fly.io about LiteFS which is working towards a more scalable and reliable SQLite. This post is just about me getting something working with these technologies and stressing them a little.

Benchmark

I have a simple GoLang app with one route to inserts a row into a SQLite database. I want to test calling this endpoint when:

  1. Locally hosted on my 2021 MacBook Pro. This will be so fast!
  2. Default Fly.io machine with ephemeral storage. When the machine restarts, all data is wiped.
  3. Fly.io machine with mounted volume persistent storage. This is where fly.io machine is attached to a single drive that survives restarts, but is not redundant in any other way(!)
  4. Fly.io machine with mounted volume and LiteFS storage. This is a single server with volume, so not redundant, and it uses the LiteFS proxy.

I am testing with ApacheBenchmark making 1000 calls with 50 concurrent, i.e. ab -n 1000 -c 50.

Results

  1. Locally hosted: 18,709 requests per second
  2. Ephemeral storage: 241 requests per second
  3. Persistent storage: 244 requests per second
  4. LiteFS storage: 62 requests per second

Discussion

What can we see:

  1. Locally hosted is fast. Great for testing.
  2. Ephemeral and Persistent storage are basically the same speed. Under the assumption that ephemeral should be faster; there must be another bottleneck somewhere else.
  3. Distributed storage(ish) is 4 times slower than persistent storage. This could be the LiteFS proxy taking time, but I bet it is the slow FUSE file system and time to read and broadcast SQLite WAL file. That being said, 60 requests per second is still awesome.

Conclusion

This is not a great benchmark. It took me a few hours to go from never using fly.io or SQLite to running this benchmark. That in itself is a pretty positive review of both these technologies. On that line, fly.io is awesome and I will be using them for my future projects!

I think that LiteFS is a cool idea, but I just wish it was a little less complicated to setup. For example, maybe we could create a LiteFS volume that could be mounted to many machines. Either way I am prioritising simplicity and performance for my upcoming project, so I will probably leave LiteFS out of the mix, for the time being.

Other things

  1. Litestream another useful SQLite app
  2. Examples of a lite-fs app [1][2]

--

--