Site administration
Serve LFS files and assets from Europe and Asia
Object storage is in AWS us-east-1, and every LFS download and asset passes through the web Worker there. From Singapore, a 16 MiB LFS file took 2.3 s through the forge, and 0.2 s straight from object storage in Singapore. From Nuremberg it took 1.1 s, and 0.2 s from Frankfurt (measured on 2026-12-03, the median of 5). This page sets up a copy of the LFS objects and assets in Europe and in Asia, next to the git servers, and turns on the downloads from them.
7 min read
You need:
neonctl, signed in to the TanStack organization on Neon.- Wrangler, signed in to the Cloudflare account of the forge, run from
apps/web. - psql access to the production database, as in Object storage on Neon.
1. Make the two storage projects
Each region has a Neon project of its own, with a bucket lfs on its branch main:
| Region | Project | Its AWS region | S3 endpoint |
|---|---|---|---|
eu | source-objects-eu (winter-violet-53550303) | eu-central-1 | https://br-odd-cake-bhnzwa16.storage.c-10.eu-central-1.aws.neon.tech |
asia | source-objects-asia (damp-king-61214317) | ap-southeast-1 | https://br-nameless-pond-bi4jhdsm.storage.c-5.ap-southeast-1.aws.neon.tech |
The endpoints and regions are vars of the keys Worker (NEON_STORAGE_EU_ENDPOINT, NEON_STORAGE_EU_REGION, NEON_STORAGE_ASIA_ENDPOINT and NEON_STORAGE_ASIA_REGION in apps/web/wrangler.keys.jsonc). Don't use neonctl env pull on these projects: it makes the default storage key again.
2. Give the keys Worker their keys
Only the keys Worker holds the keys. Make 8 keys for each project and put them straight into the secrets NEON_STORAGE_EU_KEYS and NEON_STORAGE_ASIA_KEYS, JSON arrays of { "id", "secret" }, as step 2 of Object storage on Neon does for NEON_STORAGE_KEYS. Nothing is printed and nothing is saved in a file. Then deploy the version that the second wrangler versions secret put printed:
pnpm exec wrangler versions deploy <version id>@100% -c wrangler.keys.jsonc
Then revoke each "Default object storage credential" of the two projects (neonctl credentials list --project-id <id> and neonctl credentials revoke <id>). Revoke it only after your own keys are made: while a project has no key that writes, Neon makes the default key again.
3. Make the queue of the copies
pnpm exec wrangler queues create gitflare-storage-copies
The web Worker sends to it and consumes it (wrangler.jsonc). Its var REGIONAL_STORAGE (eu,asia) names the regions it copies to.
4. Check the copies
Once the web Worker is deployed, each new LFS object and asset reaches both regions a few seconds after its upload. At minute 0 of each hour, the web cron runs the task storage regional reconcile, which sends what a region lacks to the queue, at most 5,000 keys an hour. Its first runs copy the files from before the copies. Workers Logs show a line with diag = "storage regional reconcile": the keys that it checked (checked) and sent (sent), and the keys that only a region had (onlyInRegion), which it deleted.
The copies are done when a run sends nothing.
5. Turn on the downloads from the regions
INSERT INTO site_settings (key, value, updated_at) VALUES ('storage.regional_reads', 'true', (extract(epoch from now()) * 1000)::bigint)
ON CONFLICT (key) DO UPDATE SET value = 'true', updated_at = excluded.updated_at;
Each Worker isolate reads the settings again within 60 s. To turn it off, set the value to false.
6. Answer the download batches next to the client
Git LFS asks the forge first, with a batch request, for the URL of each file. The web Worker answers it in us-east-1, and it reads the regional copy from there, so from Asia the batch alone takes about a second. With the setting lfs.edge_batch, the edge Worker answers the download batches of clients near a copy in the data center that takes the request.
The edge Worker needs the secret EDGE_SECRET, which Git reads at the edge sets, and its binding KEYS to the keys Worker (apps/web/wrangler.edge.jsonc). Turn it on:
INSERT INTO site_settings (key, value, updated_at) VALUES ('lfs.edge_batch', 'true', (extract(epoch from now()) * 1000)::bigint)
ON CONFLICT (key) DO UPDATE SET value = 'true', updated_at = excluded.updated_at;
It works only while storage.regional_reads is on. The edge Worker reads both settings again within 2 minutes (60 s in the web Worker, and 60 s more at the edge). To turn it off, set the value to false.
Done
A client in Europe, Africa or the Middle East downloads from eu, and a client in the rest of Asia or in Oceania downloads from asia. Clients in the Americas download from us-east-1, as before:
- An LFS download batch gives the client a presigned URL of its region's copy, good for 1 hour, in place of the forge's URL. Git LFS then downloads from Neon directly. A CI job always downloads from the forge.
- A public image, video, audio file or download (any file that does not open with a type of its own) answers with a redirect to its region's copy. An SVG, a script, a style, a PDF and every hidden or private asset are served by the forge, with its sandbox.
- A file whose copy is missing, or not yet the size of the file, comes from the forge. So does every file while the setting is off.
- With
lfs.edge_batchon, the edge Worker answers the download batch next to the client, and the answer is the same as the web Worker's. An upload, a verify, a transfer, locks, a CI job and a client in the Americas still go to the web Worker. - The edge Worker keeps a grant for 60 seconds, as for git reads at the edge. So a revoked token, a removed collaborator or a repository made private keeps its LFS downloads near the client for up to a minute. A refusal is never kept.
How it works
apps/web/src/server/storage/regions.tshas the copies. After a put of an LFS object (objects/) or an asset (assets/), or an upload in parts that completed, the LFS store sends the key to the queue. The consumer copies it to each region that lacks it at the same size (copyObjectinstorage/backup.ts, the copy of the R2 backup). A file over 100 MiB goes in parts of 64 MiB. A copy that fails is retried 5 times, then the hourly reconcile sends it again.- A delete in the LFS store deletes the copies in both regions before it answers. The purge of a deleted repository also deletes
objects/<repo id>/andassets/<repo id>/in both regions. - The runner Worker sends nothing to the queue: what it stores reaches the regions through the hourly reconcile.
- The region of a client comes from Cloudflare's edge data of the request (
request.cf.continentandcountry). - The keys Worker signs the presigned URLs (
presignStorageGet). It signs only a GET ofobjects/orassets/in the bucketslfs,lfs-euandlfs-asia, for at most 1 hour. - The edge Worker's download batch (
apps/web/src/server/edge-git/lfs.ts): the first batch of a client goes to the web Worker once (/_edge/lfs-batch), which answers it with the LFS code as it answers any batch (edgeLfsBatchinlfs-http.ts), but reads no regional copy. It names the files that it would send to one, and the edge Worker reads and signs those near the client. The edge Worker then keeps, for 60 seconds, the client's grant (by a hash of itsAuthorizationheader) with its role, and the size of each file that this role may download. A next batch of only kept files is answered at the edge, with no call to us-east-1: a HEAD of each file's regional copy, and its presigned GET. - The keys Worker signs for the edge Worker through its own entrypoint,
EdgeKeys, with one method,regionalLfs: a HEAD and a GET of LFS objects (objects/<repo id>/<oid>) oflfs-euorlfs-asia, at most 100 at a time. The edge Worker never gets a key.
Cost
Neon object storage costs $0.023 a GB-month, with no charge for requests. Each project includes 500 GB of egress a month (shared with its Postgres and Functions), then $0.09 a GB. The copies add two copies of the LFS objects and assets (about 4.3 GiB each on 2026-12-03, so about $0.20 a month), and their copy counts toward the egress of source-objects. Each download from a region counts toward the egress of that region's project.