Star
Run it

Configuration

Every setting is an environment variable. Pass them in the environment, or to FeaturekitServer by name in env. The defaults are for a laptop; production refuses to start on the ones that matter.

new FeaturekitServer({
        databaseUrl: process.env.DATABASE_URL,
        env: { RATE_LIMIT_ADMIN_PER_MIN: "600", SNAPSHOT_DEBOUNCE_MS: "500" },
      });

Required in production

With NODE_ENV=production, a missing DATABASE_URL stops the start. So does a missing SECURE_MODE_SECRET when you declare client keys exist (clientKeysExist, or FEATUREKIT_CLIENT_KEYS_EXIST=1); without that, production client requests are refused until it's set. Every missing variable is listed in one error: three restarts to discover three missing variables would be three outages.

Server and database

VariableDefaultWhat it does
NODE_ENVdevelopmentdevelopment, test or production.
PORT, HOST3000, 127.0.0.1Where to listen. Use 0.0.0.0 in a container.
DATABASE_URLa local PostgresPostgres connection string.
DATABASE_SCHEMApublicThe one schema featurekit owns. Lowercase letters, digits and underscores, not starting with pg_. Created by migrations.
DATABASE_LISTEN_URLDATABASE_URLA direct Postgres address for LISTEN, when queries go through pgbouncer.
DB_MAX_CONNECTIONS10Pool size per node.
LOG_LEVELinfofatal, error, warn, info, debug, trace or silent.
SHUTDOWN_GRACE_MS10000How long in-flight requests get on shutdown.

Security

VariableDefaultWhat it does
SECURE_MODE_SECRETVerifies signed client contexts. At least 32 characters. Comma-separated to rotate: signs with the first, verifies with all.
SECURE_MODE_MAX_TTL_SECONDS86400Longest signature lifetime accepted, whatever was signed.
UNSIGNED_CONTEXT_ENVIRONMENT_IDSProduction environment ids allowed to skip signing. Comma-separated.
CORS_ALLOWED_ORIGINSsame origin onlyExact origins allowed to call the client tier. Comma-separated. Never *.
SDK_KEY_CACHE_TTL_MS30000How long a key lookup is cached, which bounds how long a revoked key keeps working on other nodes.

Dashboard and first account

VariableDefaultWhat it does
DASHBOARDthe bundled oneA directory to serve instead, or off to serve no UI at all.
DASHBOARD_PATH/adminWhere it's served.
FEATUREKIT_ADMIN_EMAIL, FEATUREKIT_ADMIN_PASSWORDCreate this owner account on start if it doesn't exist. The password needs 12+ characters.

Rate limits

Per caller, per minute, per node: behind a load balancer over N nodes, a caller can reach N times these.

VariableDefaultApplies to
RATE_LIMIT_CLIENT_STATE_PER_MIN600POST /v1/client/state
RATE_LIMIT_SNAPSHOT_PER_MIN240GET /v1/snapshot
RATE_LIMIT_STREAM_PER_MIN60Opening either stream
RATE_LIMIT_EVENTS_PER_MIN120POST /v1/events
RATE_LIMIT_ADMIN_PER_MIN300The busier admin routes
RATE_LIMIT_LOGIN_PER_MIN10Dashboard sign-in
RATE_LIMIT_OVERRIDESPer-environment overrides as env:route:limit, comma-separated, like production:/v1/snapshot/:envKey:2000.

Propagation and streaming

VariableDefaultWhat it does
SNAPSHOT_DEBOUNCE_MS200How long to batch changes before compiling. Raise it for environments with tens of thousands of flags.
PATCH_HISTORY_DEPTH200Patches kept for SDKs that reconnect.
MAX_STREAM_CONNECTIONS10000Server streams per node, after which SDKs poll.
MAX_CLIENT_CONNECTIONS50000Client streams per node.
STREAM_HEARTBEAT_MS30000Keep-alive interval on every stream.
CLIENT_CONNECTION_TTL_SECONDS900How long a client connection can be resumed on another node.

Segments

VariableDefaultWhat it does
SEGMENT_INLINE_MAX50000Up to this many members, a segment is an exact list in the snapshot. Beyond it, a compact filter.
SEGMENT_MEMBER_CEILING2000000Most members one compile reads per segment. Past it the compile fails and the last snapshot keeps serving.
SEGMENT_MEMBER_PAGE_SIZE25000Rows per read while compiling.

Analytics and the scheduler

VariableDefaultWhat it does
EVENT_BUFFER_MAX100000Evaluation summaries buffered before the oldest are dropped.
EVENT_FLUSH_INTERVAL_MS5000How often the buffer is written.
ROLLUP_BUCKET_SECONDS60Time bucket for metrics.
ROLLUP_RETENTION_DAYS90Kept this long, when pg_partman is installed. Applied at migration.
ROLLUP_PARTITION_PREMAKE_DAYS7Partitions created ahead. At least 2.
PARTITION_RUNWAY_MIN_DAYS2Below this many days of partitions, /ready fails.
SCHEDULER_INTERVAL_MS15000How often each node looks for due scheduled changes.
SCHEDULER_GRACE_MS3600000How late a scheduled change may still run. Later than this, it's marked failed instead.

Sharing a database

Each install owns one schema: its tables, types, functions, partitions and migration history. Several installs can share a database in different schemas. Connections use only that schema on their search_path, so a missing table is an error, never a silent read from public.