Configuration
Rust uses environment variables for a number of configuration options. Some of these include:
| variable | value | description |
|---|---|---|
| RUST_LOG | debug, info, warn, error | minimum Rust error logging level |
| RUST_TEST_THREADS | 1 | maximum number of concurrent threads for testing. |
In addition, Sync server configuration options can either be specified as environment variables (prefixed with SYNC_*) or in a configuration file using the --config option.
For example the following are equivalent:
$ SYNC_HOST=0.0.0.0 SYNC_MASTER_SECRET="SuperSikkr3t" SYNC_SYNCSTORAGE__DATABASE_URL=mysql://scott:tiger@localhost/syncstorage cargo run
$ cat syncstorage.local.toml
host = "0.0.0.0"
master_secret = "SuperSikkr3t"
[syncstorage]
database_url = "mysql://scott:tiger@localhost/syncstorage"
$ cargo run -- --config syncstorage.local.toml
Options can be mixed between environment variables and configuration. Environment variables have higher precedence.
Options
The following configuration options are available.
Server Settings
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_HOST | 127.0.0.1 | Host address to bind the server to |
| SYNC_PORT | 8000 | Server port to bind to |
| SYNC_MASTER_SECRET | None, required | Secret used to derive auth secrets |
| SYNC_ENVIRONMENT | dev | Environment name (“dev”, “stage”, “prod”) |
| SYNC_HUMAN_LOGS | false | Enable human-readable logs |
| SYNC_ACTIX_KEEP_ALIVE | None | HTTP keep-alive header value in seconds |
| SYNC_WORKER_MAX_BLOCKING_THREADS | 512 | The maximum number of blocking threads in the worker threadpool. This threadpool is used by Actix-web to handle blocking operations. |
CORS
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_CORS_ALLOWED_ORIGIN | * | Allowed origins for CORS requests |
| SYNC_CORS_MAX_AGE | 1728000 | CORS preflight cache seconds (20 days) |
| SYNC_CORS_ALLOWED_METHODS | [“DELETE”, “GET”, “POST”, “PUT”] | Allowed methods |
| SYNC_CORS_ALLOWED_HEADERS | See source | Allowed headers for CORS requests |
Syncstorage Database
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_SYNCSTORAGE__DATABASE_URL | mysql://root@127.0.0.1/syncstorage | Database connection URL. For a Unix socket, see MySQL and MariaDB Unix Socket |
| SYNC_SYNCSTORAGE__DATABASE_POOL_MAX_SIZE | 10 | Max database connections |
| SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_TIMEOUT | 30 | Pool timeout in seconds |
| SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_LIFESPAN | None | Max connection age in seconds |
| SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_MAX_IDLE | None | Max idle time in seconds |
| SYNC_SYNCSTORAGE__DATABASE_POOL_SWEEPER_TASK_INTERVAL | 30 | How often, in seconds, a background task runs to evict idle database connections (Spanner only) |
| SYNC_SYNCSTORAGE__DATABASE_SPANNER_ROUTE_TO_LEADER | false | Send leader-aware headers to Spanner |
| SYNC_SYNCSTORAGE__SPANNER_EMULATOR_HOST | None | Spanner emulator host (e.g., localhost:9010) |
Syncstorage Limits
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_SYNCSTORAGE__LIMITS__MAX_POST_BYTES | 2,621,440 | Max BSO payload size per request |
| SYNC_SYNCSTORAGE__LIMITS__MAX_POST_RECORDS | 100 | Max BSO count per request |
| SYNC_SYNCSTORAGE__LIMITS__MAX_RECORD_PAYLOAD_BYTES | 2,621,440 | Max individual BSO payload size |
| SYNC_SYNCSTORAGE__LIMITS__MAX_REQUEST_BYTES | 2,625,536 | Max Content-Length for requests |
| SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_BYTES | 262,144,000 | Max BSO payload size per batch |
| SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_RECORDS | 10,000 | Max BSO count per batch |
| SYNC_SYNCSTORAGE__LIMITS__MAX_QUOTA_LIMIT | 2,147,483,648 | Max storage quota per user (2 GB) |
| SYNC_SYNCSTORAGE__LIMITS__COLLECTIONS | unset | Optional per-collection limit overrides, as a JSON object mapping collection name -> limits object (e.g. {"newtab-images":{"max_record_payload_bytes":20971520,"max_post_bytes":26214400,"max_request_bytes":26218496}}). Supported override fields: max_record_payload_bytes, max_post_bytes, max_request_bytes. Any field left unset inherits the corresponding global limit. |
Syncstorage Features
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_SYNCSTORAGE__ENABLED | true | Enable syncstorage service |
| SYNC_SYNCSTORAGE__ENABLE_QUOTA | false | Enable quota tracking (Spanner only) |
| SYNC_SYNCSTORAGE__ENFORCE_QUOTA | false | Enforce quota limits (Spanner only) |
| SYNC_SYNCSTORAGE__REQUIRE_COLLECTION_DELETE_CONFIRMATION | false | Require X-Confirm-Delete: 1 header for collection deletion, except for tabs. Without the header, an HTTP 200 is returned without deletion. |
| SYNC_SYNCSTORAGE__GLEAN_ENABLED | true | Enable Glean telemetry |
| SYNC_SYNCSTORAGE__LBHEARTBEAT_TTL | None | Load balancer heartbeat period in seconds |
| SYNC_SYNCSTORAGE__LBHEARTBEAT_TTL_JITTER | 25 | Jitter percentage for the load balancer heartbeat period |
| SYNC_SYNCSTORAGE__STATSD_LABEL | syncstorage | StatsD metrics label prefix |
Syncstorage Payload Off-load
Off-loads large BSO payloads to a Google Cloud Storage bucket, storing the
object URL in the payload_link column instead of the inline payload
column. Supported on the Spanner backend only: setting
SYNC_SYNCSTORAGE__GCS_PAYLOAD_BUCKET or
SYNC_SYNCSTORAGE__GCS_PAYLOAD_OFFLOAD_COLLECTIONS on a mysql or postgres
backend fails startup, since those backends have no payload_link column and
would silently drop the payload.
For configuration changes and deployment order, see Onboarding an Offloaded Collection.
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_SYNCSTORAGE__GCS_PAYLOAD_BUCKET | unset | GCS bucket for off-loaded payloads. Unset disables off-load. |
| SYNC_SYNCSTORAGE__GCS_PAYLOAD_OFFLOAD_COLLECTIONS | unset | Comma-separated collection names whose payloads are off-loaded. Empty disables off-load for all collections. |
| SYNC_SYNCSTORAGE__GCS_PAYLOAD_PREFIX | v1 | The prefix for off-loaded GCS object names. The server formats each object name as {prefix}/{fxa_uid}/{uuid}. |
| SYNC_SYNCSTORAGE__GCS_PAYLOAD_MAX_CONCURRENCY | 4 | The maximum number of concurrent GCS payload uploads and downloads within one batch request. This value must be greater than zero. |
| SYNC_SYNCSTORAGE__GCS_ENDPOINT | unset | A test-only override for the GCS endpoint URL, for example a mock server or a fake-gcs-server instance. If set, the server uses anonymous credentials. Do not set this variable in production. |
Tokenserver Database
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_TOKENSERVER__DATABASE_URL | mysql://root@127.0.0.1/tokenserver | Tokenserver database URL. For a Unix socket, see MySQL and MariaDB Unix Socket |
| SYNC_TOKENSERVER__DATABASE_POOL_MAX_SIZE | 10 | Max tokenserver DB connections |
| SYNC_TOKENSERVER__DATABASE_POOL_CONNECTION_TIMEOUT | 30 | Pool timeout in seconds |
MySQL and MariaDB Unix Socket
The server connects to MySQL and MariaDB over TCP, also for a localhost host
(port 3306). It does not use the Unix socket. If your database listens only on
a Unix socket, the server fails with Connection refused (os error 111).
To use the socket, add the socket parameter with the socket path to
syncstorage.database_url and to tokenserver.database_url:
[syncstorage]
database_url = "mysql://user:password@localhost/syncstorage_rs?socket=/run/mysqld/mysqld.sock"
[tokenserver]
database_url = "mysql://user:password@localhost/tokenserver_rs?socket=/run/mysqld/mysqld.sock"
The same ?socket= parameter applies to SYNC_SYNCSTORAGE__DATABASE_URL and
SYNC_TOKENSERVER__DATABASE_URL.
The server does not recognize the ?unix_socket= parameter. With it, the
server does not start, and it logs
Unknown connection URL parameter `unix_socket'.
Tokenserver Features
Last-seen reporting requires the last_seen Cargo feature, independently of the
storage backend. Build it with cargo build -p syncserver --features last_seen.
Docker images include this feature only when built with
SYNCSTORAGE_DATABASE_BACKEND=spanner. Reporting still defaults to off at runtime.
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_TOKENSERVER__INIT_NODE_URL | None | The storage node URL, protocol + host, to insert into the nodes table on startup. This is the origin where the service is hosted, e.g. “http://localhost:8000”. |
| SYNC_TOKENSERVER__INIT_NODE_CAPACITY | 100000 | The storage node capacity of the server specified by SYNC_TOKENSERVER__INIT_NODE_URL. Only used if SYNC_TOKENSERVER__INIT_NODE_URL is set. |
| SYNC_TOKENSERVER__ENABLED | false | Enable tokenserver service |
| SYNC_TOKENSERVER__RUN_MIGRATIONS | false | Run DB migrations on startup |
| SYNC_TOKENSERVER__NODE_TYPE | spanner | Storage backend type reported in token response for telemetry. Valid values: “mysql”, “postgres”, “spanner” |
| SYNC_TOKENSERVER__STATSD_LABEL | syncstorage.tokenserver | StatsD metrics label prefix |
| SYNC_TOKENSERVER__TOKEN_DURATION | 3600 | Token TTL (1 hour) |
| SYNC_TOKENSERVER__FXA_WEBHOOK_ENABLED | false | Enable the FxA webhook endpoint. When disabled, the route is not registered. |
| SYNC_TOKENSERVER__FXA_WEBHOOK_METRICS_ONLY | false | Run the FxA webhook handler in metrics-only mode. Received events are counted but not processed. Only used if FXA_WEBHOOK_ENABLED is true. |
| SYNC_TOKENSERVER__FXA_WEBHOOK_SET_CLIENT_ID | None | Expected aud of FxA Security Event Tokens. Required for account event webhooks. |
| SYNC_TOKENSERVER__FXA_WEBHOOK_SET_ISSUER | None | Expected iss of FxA Security Event Tokens. Required for account event webhooks. |
| SYNC_TOKENSERVER__FXA_DELETE_DATA_ENABLED | false | Enable DELETE /1.0/users/{fxa_uid}/storage, the FxA-triggered syncstorage data deletion endpoint. When disabled, the route is not registered. |
| SYNC_TOKENSERVER__FXA_ADMIN_AUDIENCE | urn:mozilla:fxa:tokenserver | The aud required on delete assertions. Must differ from FXA_WEBHOOK_SET_CLIENT_ID and FXA_OAUTH_SERVER_URL — it is what keeps the three FxA-signed credential types non-interchangeable — and the server refuses to start if it does not. Defaulted because a URN was chosen to be identical in every environment, unlike the issuer; override only if FxA changes it. Must not be empty. |
| SYNC_TOKENSERVER__FXA_ADMIN_ISSUER | None | The iss required on delete assertions; normally the same value as FXA_WEBHOOK_SET_ISSUER. Matched byte-for-byte against the token’s iss, so it must be exactly what FxA emits. Required when FXA_DELETE_DATA_ENABLED is true. |
| SYNC_TOKENSERVER__FXA_DELETE_DATA_REQUEST_TIMEOUT | 30 | Timeout in seconds for the request asking a storage node to delete the user’s data. |
| SYNC_TOKENSERVER__ALLOW_NEW_USERS | true | Whether new users may be created. When disabled, only previously registered users can use the tokenserver service. |
| SYNC_TOKENSERVER__LAST_SEEN_ENABLED | false | Record the FxA UID, OAuth client ID, and timestamp of successful token exchanges, and upload them to a BigQuery staging table. Collection stays disabled in builds without the last_seen Cargo feature. Token responses do not wait for uploads. Rows that cannot be uploaded are logged and dropped. |
| SYNC_TOKENSERVER__LAST_SEEN_STAGING_TABLE | None | BigQuery staging table name in PROJECT_ID.DATASET_ID.TABLE_ID format, for example my-project.account_last_seen.last_seen_staging. Required when last-seen reporting is enabled. |
| SYNC_TOKENSERVER__LAST_SEEN_MAX_CONCURRENT_FLUSHES | 4 | Maximum number of concurrent last-seen uploads per server instance. Must be at least 1. |
Tokenserver+FxA Integration
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_TOKENSERVER__FXA_EMAIL_DOMAIN | api-accounts.stage.mozaws.net | FxA email domain |
| SYNC_TOKENSERVER__FXA_OAUTH_SERVER_URL | https://oauth.stage.mozaws.net | FxA OAuth server URL |
| SYNC_TOKENSERVER__FXA_OAUTH_REQUEST_TIMEOUT | 10 | OAuth request timeout in seconds |
| SYNC_TOKENSERVER__FXA_METRICS_HASH_SECRET | secret | Secret for hashing metrics to maintain anonymity |
| SYNC_TOKENSERVER__ADDITIONAL_BLOCKING_THREADS_FOR_FXA_REQUESTS | 1 | Number of additional blocking threads to add to the threadpool for OAuth verification requests to FxA |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KTY | None | Primary JWK key type (e.g., “RSA”) |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__ALG | None | Primary JWK algorithm (e.g., “RS256”) |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KID | None | Primary JWK key ID |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__FXA_CREATED_AT | None | Primary JWK creation timestamp |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__USE | None | Primary JWK use (e.g., “sig”) |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__N | None | Primary JWK modulus (RSA public key component) |
| SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__E | None | Primary JWK exponent (RSA public key component) |
| SYNC_TOKENSERVER__FXA_OAUTH_SECONDARY_JWK__* | None | Secondary JWK (same structure as primary) |
StatsD Metrics
| Env Var | Default Value | Description |
|---|---|---|
| SYNC_STATSD_HOST | localhost | StatsD server hostname |
| SYNC_STATSD_PORT | 8125 | StatsD server port |
| SYNC_INCLUDE_HOSTNAME_TAG | false | Include hostname in metrics tags |