Install the SDK
Add the Archil packages to your Worker project:Worker example
This Worker reads and writes files on an Archil disk:Configuration
Set your Archil token as a secret in your Worker:wrangler.toml, enable the Node.js compatibility flag since the SDK uses native bindings:
Archil with R2
If you’re already using Cloudflare R2 for object storage, you can use R2 as Archil’s data source. This means Archil caches your R2 data on fast SSD storage close to your compute, giving you a filesystem interface on top of R2 with automatic cache management. Create a disk backed by your R2 bucket and your Workers get fast, cached access to the same data that’s stored in R2.Performance tips
- Reuse connections where possible. Each
connect()call establishes a new session. For Workers that handle many requests, consider connection reuse patterns. - Choose the right region. Pick an Archil region close to the Cloudflare data centers serving your traffic to minimize round-trip latency.
- Keep payloads reasonable. Workers have CPU time limits. For large file transfers, stream data or process it in chunks rather than reading entire files into memory.