---
title: "We rewrote large parts of our API in Go using AI: we are now ready to handle one billion databases"
description: "Turso's Go API proxy, which maps database URLs to physical servers, ran out of memory as customers created millions of databases programmatically."
url: "https://swe.quest/articles/we-rewrote-large-parts-of-our-api-in-go-using-ai-we-are-now-ready-to-handle-one-dae54753b5d31582"
canonical: "https://turso.tech/blog/we-rewrote-large-parts-of-our-api-in-go"
source: "Turso"
published: "2025-05-29"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["go","scalability","memory-management","sqlite","caching"]
---

# We rewrote large parts of our API in Go using AI: we are now ready to handle one billion databases

A post on [Turso](https://swe.quest/sources/turso.md), published 2025-05-29, 7 min read, Case study. Original: [https://turso.tech/blog/we-rewrote-large-parts-of-our-api-in-go](https://turso.tech/blog/we-rewrote-large-parts-of-our-api-in-go)

## Summary

Turso's Go API proxy, which maps database URLs to physical servers, ran out of memory as customers created millions of databases programmatically. Bootstrapping was fixed with streaming and pagination. Route memory was cut by interning repeated App and Address strings with Go's unique package and by dropping the region suffix from map keys. With memory still growing about 500MB per week, the in-memory hash map was replaced by a SQLite-backed store behind an LRU cache, so only active mappings stay in memory and restarts fetch only deltas. Planned next steps are Embedded Replicas sync and dictionary encoding of organization names.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)

## Prerequisites

- Go basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- hash maps and LRU caches ([easy posts on Maps & geospatial](https://swe.quest/tags/geospatial.md?difficulty=easy))
- reverse proxies ([easy posts on Load balancing](https://swe.quest/tags/load-balancing.md?difficulty=easy))

## Keywords

Turso, Go unique package, SQLite, string interning, LRU cache, Embedded Replicas

## Related posts

- [How Turso made connections to SQLite databases 575x faster](https://swe.quest/articles/how-turso-made-connections-to-sqlite-databases-575x-faster-271f1e3891c5cf67.md): Turso · 2025-07-29 · Medium · 4 min read · SQLite, Performance engineering, Rust, Concurrency
  SQLite re-reads and parses the sqlite\_schema table on every new connection, so opening a connection to a database with 10,000 tables takes about 23ms.
- [2 million databases and counting: the architecture behind Sauna's AI teammate](https://swe.quest/articles/2-million-databases-and-counting-the-architecture-behind-sauna-s-ai-teammate-ca635665d8781bf3.md): Turso · 2026-11-03 · Easy · 8 min read · SQLite, Multi-tenancy, Replication, AI agents, System design
  Sauna, a proactive AI work assistant, gives every session, agent and connected inbox or calendar its own Turso database, creating about 90,000 databases a day and over 2 million in total.
- [Bringing SQLite to Vercel Functions with Turso](https://swe.quest/articles/bringing-sqlite-to-vercel-functions-with-turso-afed2a49c7b44020.md): Turso · 2026-02-19 · Medium · 8 min read · SQLite, Serverless, Replication, Multi-tenancy, JavaScript
  Turso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency.
- [Skip the API, Ship Your Database](https://swe.quest/articles/skip-the-api-ship-your-database-848af5fd83020408.md): Fly.io · 2023-09-13 · Medium · 5 min read · SQLite, API design, Replication, Multi-tenancy, System design
  Instead of designing an API for internal services, Fly.io ships them a read-only SQLite replica via LiteFS, letting consumers query and join data with plain SQL.
- [How to Deploy Schema Changes to a Million Databases](https://swe.quest/articles/how-to-deploy-schema-changes-to-a-million-databases-356cdf3f01c11d17.md): Turso · 2025-06-02 · Medium · 4 min read · Schema migrations, Multi-tenancy, SQLite, Local-first & sync, Go
  Database-per-tenant schema migrations can scale to millions of databases by inverting control: a hosted schema registry stores a versioned catalog of SQL scripts, and each client periodically reports its schema version, pulls the missing migrations and applies them locally.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
