Skip to content

Quota and throttling

Traffic routed through FKN’s proxy and WebVPN relays is metered per connected account when one is available, otherwise per IP. Free-tier usage gets a daily volume; past it, transfers are throttled to a slower rate until the daily window resets. An active subscription lifts that throttle. cloud.quota() lets an app read the current state.

import {
(alias) namespace cloud
import cloud
cloud
} from '@fkn/lib'
const
const status: cloud.QuotaStatus
status
= await
(alias) namespace cloud
import cloud
cloud
.
cloud_d_exports.quota(): Promise<cloud.QuotaStatus>
export cloud_d_exports.quota
quota
()
if (
const status: cloud.QuotaStatus
status
.
throttled: boolean
throttled
) {
const
const mbps: number
mbps
=
var Math: Math

An intrinsic object that provides basic mathematics functionality and constants.

Math
.
Math.round(x: number): number

Returns a supplied numeric expression rounded to the nearest integer.

@paramx The value to be rounded to the nearest integer.

round
(
const status: cloud.QuotaStatus
status
.
bitsPerSecond: number
bitsPerSecond
/ 1_000_000)
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Throttled to ${
const mbps: number
mbps
} Mbps. Subscribe for full speed.`)
} else {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`${
const status: cloud.QuotaStatus
status
.
remainingBytes: number
remainingBytes
} bytes left of free quota today`)
}
const
const status: cloud.QuotaStatus
status
= await
(alias) namespace cloud
import cloud
cloud
.
cloud_d_exports.quota(): Promise<cloud.QuotaStatus>
export cloud_d_exports.quota
quota
()
const status: cloud.QuotaStatus
status
.
premium: boolean

the user has a paid subscription, throttle never applies

premium
// has an active subscription
const status: cloud.QuotaStatus
status
.
overQuota: boolean
overQuota
// today's free-tier volume is spent
const status: cloud.QuotaStatus
status
.
throttled: boolean
throttled
// transfers are rate-limited right now (over quota, not premium)
const status: cloud.QuotaStatus
status
.
usedBytes: number

bytes egressed through FKN relays today (per connected account or anonymized IP), saturates at limitBytes: consumption past the free-tier volume is private and never reported

usedBytes
// bytes egressed through FKN relays today, saturates at limitBytes
const status: cloud.QuotaStatus
status
.
limitBytes: number
limitBytes
// free-tier daily volume before throttling
const status: cloud.QuotaStatus
status
.
remainingBytes: number
remainingBytes
// free-tier volume left today
const status: cloud.QuotaStatus
status
.
bytesPerSecond: number
bytesPerSecond
// current effective egress rate cap
const status: cloud.QuotaStatus
status
.
bitsPerSecond: number
bitsPerSecond
// the same cap in bits per second, for display

bytesPerSecond is the rate the relays are actually clamping this user to right now: the free rate under quota, the throttled rate once over it, or the premium rate for subscribers. Reading it means you never have to hard-code the platform’s rate constants.

usedBytes saturates at limitBytes: consumption past the free-tier volume is private and is never reported, so once a user is over quota the field reads exactly limitBytes. Your app gets everything it needs for a quota meter without FKN exposing anyone’s real transfer volume, in particular a premium user’s.

Quota reflects only traffic that goes through FKN relays. Extension requests use the browser’s connection and are not included. The desktop backend is planned and does not currently handle traffic. This is why quota lives under cloud.* and has no root alias.

cloud.quota() by execution backend

All APIs below are called from browser code. The columns show which backend performs the work.

API / featureExtensionCloudDesktop
quotaCloud egress onlyNot availableSupportedNot available

The value updates on the order of seconds; polling every 10 to 15 seconds while a transfer is running is plenty, and the platform caches the result so frequent polls are cheap.

import {
(alias) namespace cloud
import cloud
cloud
} from '@fkn/lib'
// Poll while a transfer is active and surface a throttle warning
const
const id: NodeJS.Timeout
id
=
function setInterval<[]>(callback: () => void, delay?: number): NodeJS.Timeout (+1 overload)
setInterval
(async () => {
const
const status: cloud.QuotaStatus
status
= await
(alias) namespace cloud
import cloud
cloud
.
cloud_d_exports.quota(): Promise<cloud.QuotaStatus>
export cloud_d_exports.quota
quota
()
if (
const status: cloud.QuotaStatus
status
.
throttled: boolean
throttled
) {
// show "Throttled to N Mbps - subscribe for full speed"
}
}, 15_000)
// later
function clearInterval(timeout: NodeJS.Timeout | string | number | undefined): void (+1 overload)
clearInterval
(
const id: NodeJS.Timeout
id
)