Overview
FilBeam provides a pay-per-byte CDN layer on top of Filecoin storage, offering:- Fast data retrieval through global CDN nodes
- Cache-based delivery for frequently accessed content
- Usage-based billing (only pay for data egress)
- Trusted measurement layer for accurate billing
How It Works
FilBeam charges are usage-based:
- CDN Egress: Data served from cache (fast)
- Cache Miss Egress: Data retrieved from providers (triggers caching)
Enable CDN
import { Synapse } from '@filoz/synapse-sdk'
const synapse = await Synapse.create({ privateKey, rpcUrl })
// Enable CDN during upload
const result = await synapse.storage.upload(data, {
withCDN: true,
})
console.log(`Uploaded with CDN enabled: ${result.pieceCid}`)
// Download uses CDN automatically if enabled during upload
const data = await synapse.storage.download({
pieceCid: result.pieceCid
})
// Force CDN usage
const data = await synapse.storage.download({
pieceCid: result.pieceCid,
withCDN: true,
})
Monitor Usage
Check Data Set Quotas
Calculate Remaining Bandwidth
Pricing
Get CDN Pricing
CDN Cost Structure
CDN pricing has two components:
- Base Storage: Same as non-CDN (monthly rate per TiB)
- Egress Charges: Pay per byte retrieved
- CDN Egress: Data served from cache (cache hits)
- Cache Miss Egress: Data pulled from providers (cache misses)
Preflight with CDN
Estimate costs including CDN:Metadata Integration
CDN status is stored in metadata:FilBeam Service
Direct FilBeam service access:CDN URLs
Retrieve data via FilBeam URLs:Network-Specific Endpoints
Error Handling
Use Cases
Video Streaming
Serve videos with low latency to global audiences
Large Files
Fast downloads for frequently accessed files
Public Content
Distribute public datasets efficiently
Hot Storage
Cache frequently accessed data for performance
Best Practices
// Public content that's accessed often
const result = await synapse.storage.upload(publicVideo, {
withCDN: true,
pieceMetadata: {
category: 'public-content',
access: 'frequent',
},
})
setInterval(async () => {
const stats = await synapse.filbeam.getDataSetStats('12345')
if (stats.cdnEgressQuota < 1_000_000_000n) {
console.warn('Low CDN quota remaining')
// Add more credits or notify admin
}
}, 3600000) // Check hourly
Limitations
Next Steps
Storage Operations
Learn about upload and download operations
Payment Management
Manage payments for CDN usage