Every millisecond of license validation latency adds up. If your validation takes 200ms, your customer's application feels slower — and they'll blame you, not their own code. Edge-based validation solves this by running your validation logic within 50ms of every user on Earth.
Why the Edge?
Traditional license validation follows a simple path: client → your API server → database → response. If your server is in US-East and your customer is in Singapore, that round trip adds 250-400ms of network latency alone. Edge computing eliminates this.
| Architecture | Latency (Singapore user) | Reliability |
|---|---|---|
| Single-region API | 250-400ms | Single point of failure |
| Multi-region API | 50-150ms | Regional failover |
| Edge Functions | 1-10ms | 300+ PoPs, auto-failover |
Architecture Overview
Edge-based validation uses a three-tier architecture:
- Edge Function — Receives the validation request, checks the cache, returns immediately if cached
- Edge Cache — Distributed key-value store replicated across all edge locations
- Origin Database — Source of truth for license data, accessed only on cache misses
// Edge function validation flow
export default {
async fetch(request, env) {
const { key, domain } = await request.json()
// 1. Check edge cache (sub-1ms)
const cached = await env.LICENSE_CACHE.get(`license:${key}`)
if (cached) {
const license = JSON.parse(cached)
return Response.json(validateDomain(license, domain))
}
// 2. Cache miss — query origin (50-200ms, happens ~5% of requests)
const license = await fetchFromOrigin(env.DB, key)
if (!license) return Response.json({ valid: false, error: 'invalid_key' })
// 3. Cache for next request (TTL: 5 minutes)
await env.LICENSE_CACHE.put(`license:${key}`, JSON.stringify(license), {
expirationTtl: 300
})
return Response.json(validateDomain(license, domain))
}
}
Caching Strategy
What to Cache
- License metadata — Key, plan tier, authorized domains, expiry date, feature flags
- Validation results — Cache the full response for identical requests
- Rate limit counters — Per-key request counts (use atomic operations)
Cache TTLs
- Valid licenses — 5-15 minutes (balance freshness vs. origin load)
- Invalid keys — 1 minute (allow quick recovery if a key is activated)
- Revoked licenses — 0 seconds (never cache, always check origin)
- Rate limit counters — Window duration + 1 minute buffer
Cache Invalidation
The hardest problem in computer science. Use a push-based invalidation strategy:
- When a license is created, updated, or revoked, purge the cache entry
- Use key-based purging (purge
license:TO-XXXX) not URL-based - Accept eventual consistency — a 5-minute TTL means changes take up to 5 minutes to propagate
- For urgent revocations, use a "revocation list" that's checked on every request
Global Consistency
Distributed systems face the CAP theorem. For license validation, availability and partition tolerance are more important than strict consistency. A license that's valid should never be blocked; a license that's revoked can tolerate a few minutes of delay.
Eventually Consistent
- License creation — new keys available within 1 second globally
- Domain changes — propagated within the cache TTL (5 minutes)
- Plan upgrades — reflected within 5 minutes
- Hard revocations — immediate via revocation list
Failover: What Happens When Things Break
Origin Down
If the origin database is unreachable, the edge should continue serving cached responses. Extend cache TTLs during outages and switch to stale-while-revalidate mode.
Edge Cache Miss During Outage
When both the cache and origin are unavailable for a specific key, you have two options:
- Fail open — Allow the request (risky but customer-friendly)
- Fail closed — Block the request (safe but may break customer applications)
The right choice depends on your business: for paid software, fail open with a warning. For security-critical applications, fail closed with a clear error message.
Measuring Performance
Track these metrics at every edge location:
- P50 latency — Should be under 5ms for cached requests
- P95 latency — Should be under 15ms including cache misses
- P99 latency — Should be under 50ms even in worst case
- Cache hit rate — Target 95%+ for active licenses
- Origin requests/sec — Monitor for unexpected spikes
Traffic Orchestrator's Edge Architecture
Traffic Orchestrator validates licenses from 300+ edge locations worldwide, with sub-10ms P95 latency and 99.99% availability. Our edge functions cache license data with intelligent invalidation, and our distributed database ensures global consistency with local speed.
Ship licensing in your next release
5 licenses, 500 validations/month, full API access. Set up in under 5 minutes — no credit card required.