You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ncps does not handle NAR streaming in a multi-instance HA setup #660
From my conversation with Claude, I can either fix this short-term and target 0.7+ or fix it long-term and just get #322 done for 0.9 instead of what I had planned for 0.10. I'm inclined to solve this by implement CDC earlier than planned. LMK @dhess if this is breaking your side of things, it will probably take a week give or take to implement, test and release especially considering that I have yet to release 0.8.
Fix Issue #660 - Multi-Instance HA Timeout During Downloads
Problem Statement
In a multi-instance HA setup with Redis locks:
Instance A starts downloading a large NAR file from upstream
Instance B receives a client request for the same NAR file
Instance B sees the download locked in Redis
Instance B cannot access instance A's in-memory downloadState
Instance B must wait for instance A to complete the download
For large files, this exceeds client timeouts → "HTTP 200 (curl error: Timeout was reached)"
Root Cause
The downloadState used for streaming is stored in instance-local memory (c.upstreamJobs map[string]*downloadState). When instance B tries to serve the same file, it cannot access instance A's download progress.
With CDC (as planned in #322), NARs would be broken into content-addressed chunks stored independently in S3. This would completely solve the multi-instance streaming problem:
How CDC Solves It:
Instance A downloads NAR from upstream and chunks it using FastCDC
Instance A stores each chunk in S3 as it's produced (e.g., chunks/{sha256})
Instance A records chunk sequence in database table nar_file_chunks
Instance B can independently query the database for chunk list
Instance B streams chunks from S3 directly (no dependency on instance A)
Pros:
Solves multi-instance streaming elegantly
Provides deduplication benefits across similar NARs
Enables true distributed caching
Cons:
Major architectural change (new storage layer, database schema, GC updates)
Moderate-High complexity to implement correctly
Read latency overhead for chunk reassembly
Timeline: Estimated several weeks of development + testing
Verdict: CDC is the ideal long-term solution but too complex for immediate fix.
Option 2: Stream from Shared Temp File (Intermediate Solution) ⭐
Use the existing S3 backend to enable concurrent streaming from temp files:
How It Works:
Instance A writes download to S3 using a predictable temp key pattern
Example: tmp-nars/{hash}-{uuid}.nar.xz
Instance A stores the temp S3 key in Redis alongside the download lock
Instance B detects ongoing download via Redis lock
Instance B reads the temp S3 key from Redis
Instance B opens the same S3 object and starts streaming (S3 supports concurrent reads during writes)
Both instances coordinate completion via Redis
Pros:
Works with existing S3 infrastructure (already required for HA)
Activity
kalbasit commentedon Jan 27, 2026
From my conversation with Claude, I can either fix this short-term and target 0.7+ or fix it long-term and just get #322 done for 0.9 instead of what I had planned for 0.10. I'm inclined to solve this by implement CDC earlier than planned. LMK @dhess if this is breaking your side of things, it will probably take a week give or take to implement, test and release especially considering that I have yet to release 0.8.
Fix Issue #660 - Multi-Instance HA Timeout During Downloads
Problem Statement
In a multi-instance HA setup with Redis locks:
Root Cause
The downloadState used for streaming is stored in instance-local memory (
c.upstreamJobs map[string]*downloadState). When instance B tries to serve the same file, it cannot access instance A's download progress.Evaluation of Solutions
Option 1: Content-Defined Chunking (CDC) - Long-term Solution
With CDC (as planned in #322), NARs would be broken into content-addressed chunks stored independently in S3. This would completely solve the multi-instance streaming problem:
How CDC Solves It:
chunks/{sha256})nar_file_chunksPros:
Cons:
Verdict: CDC is the ideal long-term solution but too complex for immediate fix.
Option 2: Stream from Shared Temp File (Intermediate Solution) ⭐
Use the existing S3 backend to enable concurrent streaming from temp files:
How It Works:
Example:
tmp-nars/{hash}-{uuid}.nar.xzPros:
Cons:
Verdict: Best immediate fix that's practical to implement now.
Option 3: Fallback to Direct Upstream Download
Instance B directly downloads from upstream when instance A is already downloading:
Pros:
Cons:
Verdict: Not recommended.
dhess commentedon Jan 27, 2026
Thanks. I think we'll drop back to
v0.4.0for the time being, which worked great.kalbasit commentedon Jan 27, 2026
Single instance 0.7 will also work. This issue comes up from running multiple instances.
kalbasit commentedon Feb 1, 2026
I'm working on this right now and will release a fix along with CDC support in v0.9.0.
feat: Enforce CDC requirement for High Availability deployments
feat: Enforce CDC requirement for High Availability deployments (#693)
fix: resolve concurrent NAR streaming failures in distributed setup (#…
feat: add a ttfb.py dev-script for testing HA deployments
feat: add a ttfb.py dev-script for testing HA deployments (#794)
feat: add a ttfb.py dev-script for testing HA deployments [backport #794
feat: add a ttfb.py dev-script for testing HA deployments [backport #794
kalbasit commentedon Feb 22, 2026
This is now delivered in v0.9.0. Closing...
16 remaining items
feat(cache): serve cross-pod NAR from staging
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
feat(cache): serve cross-pod NAR from staging
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
feat(cache): stage in-flight NAR on contention (#1353)
feat(cache): serve cross-pod NAR from staging
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
feat(cache): serve cross-pod NAR from staging (#1354)
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal
docs(changelog): in-flight NAR staging + iLoveTimeouts removal (#1360)