Environment variables

Environment variables can be used to tailor the behaviour of a running SurrealDB instance.

Environment variables are divided into four types:

  • SurrealDB environment variables: environment variables that pertain to the overall running of a SurrealDB server. Example: SURREAL_DEFAULT_DATABASE.

  • Command environment variables: environment variables that can be used in lieu of a command flag. Example: SURREAL_CAPS_ALLOW_ALL=true surreal start, equivalent to surreal start --allow-all.

  • Storage backend environment variables: environment variables that pertain to a certain storage backend. Example: SURREAL_SURREALKV_MAX_SEGMENT_SIZE.

  • SurrealDB Cloud environment variables: environment variables that are set via the Configure instance sidebar for a SurrealDB Cloud instance.

Many environment variables have a maximum value equivalent to the greatest possible usize, which is an unsigned integer with a number of bytes depending on the target that the database runs on. For most systems this will be 64 bits, leading to a maximum size of 18_446_744_073_709_551_615 (264), while for 32 bits the maximum will be 4_294_967_296 (232).

SurrealDB environment variables

These environment variables can be used to configure a SurrealDB server to configure areas such as the HTTP server and client, limits, telemetry, and so on.

Batch config

Environment variableDefaultAllowed valuesNotes
SURREAL_NORMAL_FETCH_SIZE500A usizeThe maximum number of keys that should be scanned at once in general queries.
SURREAL_EXPORT_BATCH_SIZE1000A usizeThe maximum number of keys that should be scanned at once for export queries.
SURREAL_COUNT_BATCH_SIZE10,000A usizeThe maximum number of keys that should be scanned at once for count queries.
SURREAL_INDEXING_BATCH_SIZE250A usizeThe maximum number of keys to scan at once per concurrent indexing batch.

Cache config

Environment variableDefaultAllowed valuesNotes
SURREAL_TRANSACTION_CACHE_SIZE10,000A usizeSpecifies the number of items which can be cached within a single transaction.
SURREAL_DATASTORE_CACHE_SIZE1,000A usizeThe number of definitions which can be cached across transactions.
SURREAL_SURREALISM_CACHE_SIZE100A usizeThe number of surrealism modules which can be cached across transactions.
SURREAL_HNSW_CACHE_SIZE268,435,456 (256 MiB)A usizeThe maximum size of the HNSW vector cache.

File config

Environment variableDefaultAllowed valuesNotes
SURREAL_BUCKET_FOLDER_ALLOWLISTnoneComma-separated pathsSpecifies a list of paths in which files can be accessed.
SURREAL_FILE_ALLOWLISTnoneComma-separated pathsLimits file access for the mapper filter to only the specified allowed file paths. The paths must be provided as absolute paths, separated by a colon (:) on Unix-like systems or a semicolon (;) on Windows.
SURREAL_GLOBAL_BUCKETnoneA stringSpecifies the name of a global bucket for file data.
SURREAL_GLOBAL_BUCKET_ENFORCEDfalsetrue, falseWhether to enforce a global bucket for file data.

HTTP client config

Environment variableDefaultAllowed valuesNotes
SURREAL_MAX_HTTP_REDIRECTS10A usizeThe maximum number of HTTP redirects allowed within http functions.
SURREAL_MAX_HTTP_IDLE_CONNECTIONS_PER_HOST128A usizeThe maximum number of idle HTTP connections to maintain per host.
SURREAL_MAX_HTTP_IDLE_CONNECTIONS1000A usizeThe maximum number of idle HTTP connections to maintain.
SURREAL_HTTP_IDLE_TIMEOUT_SECS90A usizeThe timeout for idle HTTP connections before closing.
SURREAL_HTTP_CONNECT_TIMEOUT_SECS30A usizeThe timeout for connecting to HTTP endpoints.
SURREAL_USER_AGENTSurrealDBA stringThe USER-AGENT string used by HTTP requests.

HTTP server config

Environment variableDefaultAllowed valuesNotes
SURREAL_NET_MAX_CONCURRENT_REQUESTS1,048,576A usizeHow many concurrent network requests can be handled at once
SURREAL_HTTP_MAX_ML_BODY_SIZE4,398,046,511,104 (4 GiB)A usizeMaximum HTTP body size of the HTTP /ml endpoints
SURREAL_HTTP_MAX_SQL_BODY_SIZE1,048,576 (1 MiB)A usizeMaximum HTTP body size of the HTTP /sql endpoint
SURREAL_HTTP_MAX_API_BODY_SIZE4,194,304 (4 MiB)A usizeThe maximum HTTP body size of the HTTP /api endpoint.
SURREAL_HTTP_MAX_RPC_BODY_SIZE4,194,304 (4 MiB)A usizeMaximum HTTP body size of the HTTP /rpc endpoint.
SURREAL_HTTP_MAX_KEY_BODY_SIZE16,384 (16 KiB)A usizeMaximum HTTP body size of the HTTP /key endpoints
SURREAL_HTTP_MAX_SIGNUP_BODY_SIZE1024 (1 KiB)A usizeMaximum HTTP body size of the HTTP /signup endpoint.
SURREAL_HTTP_MAX_IMPORT_BODY_SIZE4,398,046,511,104 (4 GiB)A usizeMaximum HTTP body size of the HTTP /import endpoints
SURREAL_HTTP_MAX_SIGNIN_BODY_SIZE1024 (1 KiB)A usizeThe maximum HTTP body size of the HTTP /signin endpoints

Limits config

Environment variableDefaultAllowed valuesNotes
SURREAL_EXTERNAL_SORTING_BUFFER_LIMIT50000A usizeThe number of result records which will trigger on-disk sorting.
SURREAL_STRING_SIMILARITY_LIMIT16384A usizeThe maximum input string length for similarity/distance functions
SURREAL_GENERATION_ALLOCATION_LIMIT1,048,576A usizeLimits memory allocation for certain built-in functions (e.g., string::replace) to avoid uncontrolled memory usage. Default is 1,048,576 bytes (computed as 220).
SURREAL_IDIOM_RECURSION_LIMIT256A usizeThe maximum recursive idiom path depth allowed.
SURREAL_MAX_COMPUTATION_DEPTH120A usizeSpecifies how deep recursive computation will go before erroring.
SURREAL_MAX_CONCURRENT_TASKS64A usizeSpecifies how many concurrent jobs can be buffered in the worker channel.
SURREAL_MAX_OBJECT_PARSING_DEPTH100A usizeSpecifies how deep the parser will parse nested objects and arrays in a query.
SURREAL_MAX_ORDER_LIMIT_PRIORITY_QUEUE_SIZE1000A usizeThe maximum size of the priority queue triggering usage of the priority queue for the result collector.
SURREAL_MAX_QUERY_PARSING_DEPTH20A usizeSpecifies how deep the parser will parse recursive queries (queries within queries).
SURREAL_OPERATOR_BUFFER_SIZE2A usizeThe number of batches each operator buffers ahead of downstream demand. Set to 0 to disable operator-level pipeline buffering.
SURREAL_REGEX_SIZE_LIMIT10,485,760 (10 MiB)A usizeLimits the maximum allowed size (in bytes) for regular expressions. This prevents excessive memory consumption when building complex or very large regex patterns.

Runtime config

Environment variableDefaultAllowed valuesNotes
SURREAL_RUNTIME_MAX_BLOCKING_THREADS512A usizeNumber of threads which can be started for blocking operations.
SURREAL_RUNTIME_STACK_SIZE10,485,760 (10 MiB)A usizeRuntime thread memory stack size. Default stack size is doubled if compiled from source in Debug mode.
SURREAL_RUNTIME_WORKER_THREADSNumber of CPU cores (minimum 4)A usizeNumber of runtime worker threads used to start.

Scripting config

Environment variableDefaultAllowed valuesNotes
SURREAL_SCRIPTING_MAX_STACK_SIZE262_144 (256 KiB)A usizeMaximum stack size of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_MEMORY_LIMIT2,097,152 (2 MiB)A usizeMaximum memory limit of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_TIME_LIMIT5000 (5000 milliseconds or 5 seconds)A usizeMaximum allowed time in milliseconds that a JavaScript function is allowed to run for.

Security config

Environment variableDefaultAllowed valuesNotes
SURREAL_INSECURE_FORWARD_ACCESS_ERRORSfalsetrue, falseForward all signup/signin/authenticate query errors to a client performing authentication. Do not use in production.

Telemetry config

Environment variableDefaultAllowed valuesNotes
SURREAL_TELEMETRY_DISABLE_METRICSfalsetrue, falseWhether to disable sending metrics to the GRPC OTEL collector.
SURREAL_TELEMETRY_DISABLE_TRACINGfalsetrue, falseWhether to disable sending traces to the GRPC OTEL collector.
SURREAL_TELEMETRY_NAMESPACEnoneA stringIf set then use this as value for the namespace label when sending telemetry
SURREAL_TELEMETRY_PROVIDERnoneotlpIf set to "otlp" then telemetry is sent to the GRPC OTEL collector.
SURREAL_TOKIO_CONSOLE_ENABLEDfalsetrue, falseWhether to enable tokio console.
SURREAL_TOKIO_CONSOLE_RETENTION60A usizeHow long, in seconds, to retain data for completed events.
SURREAL_TOKIO_CONSOLE_SOCKET_ADDRnoneString to a socket addressThe socket address that Tokio Console will bind to.

Websocket config

Environment variableDefaultAllowed valuesNotes
SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE134,217,728 (128 MiB)A usizeThe maximum WebSocket message size.
SURREAL_WEBSOCKET_MAX_WRITE_BUFFER_SIZEGreatest possible usize valueA usizeThe maximum write buffer size before backpressure is applied.
SURREAL_WEBSOCKET_READ_BUFFER_SIZE131,072 (128 KiB)A usizeThe size of the read buffer for WebSocket connections. This controls how much data can be buffered when reading from WebSocket connections. Larger values can improve performance for high-throughput connections but consume more memory per connection.
SURREAL_WEBSOCKET_WRITE_BUFFER_SIZE131,072 (128 KiB)A usizeThe size of the write buffer for WebSocket connections. This controls how much data can be buffered when writing to WebSocket connections. Larger values can improve performance for high-throughput connections but consume more memory per connection.
SURREAL_WEBSOCKET_RESPONSE_BUFFER_SIZE0A usizeHow many responses can be buffered when delivering to the client.
SURREAL_WEBSOCKET_RESPONSE_CHANNEL_SIZE100A usizeNumber of messages that can be queued for sending via WebSocket.
SURREAL_WEBSOCKET_RESPONSE_FLUSH_PERIOD3A usizeHow often (in milliseconds) any buffered responses are flushed to the WebSocket client.

Other environment variables

Environment variableDefaultAllowed valuesNotes
SURREAL_BUILD_METADATAAutomatically populatedA stringThe version identifier of this build. Defaults to the CARGO_PKG_VERSION environment variable if not specified.
SURREAL_DATASTORE_AOLnevernever|sync|asyncAppend-only log mode. Only used by the memory engine.
SURREAL_DATASTORE_PERSISTnoneString to a file pathFilesystem path for persistence. Only used by the memory engine.
SURREAL_DATASTORE_RETENTION0 (unlimited)A durationVersion retention period as a duration string. Used by memory and surrealkv engines.
SURREAL_DATASTORE_SNAPSHOTnevernever|durationSnapshot interval. Only used by the memory engine.
SURREAL_DATASTORE_SYNC_DATAeverynever|every|durationThe sync mode for the database. Used by memory, rocksdb, and surrealkv engines.
SURREAL_DATASTORE_VERSIONEDfalsetrue|false|0|1Whether MVCC versioning is enabled. Used by memory and surrealkv engines.
SURREAL_MEMORY_THRESHOLD0A usize or suffixed integerConfiguring the memory threshold which can be used across the programme to check if the amount of memory available to the programme is lower than required. The value can be specified as bytes (b, or without any suffix), kibibytes (k, kb, or kib), mebibytes (m, mb, or mib), or gibibytes (g, gb, or gib). If the environment variable is not specified, then the threshold is not used, and no memory limit is enabled.
SURREAL_REGEX_CACHE_SIZE1000A usizeThe number of computed regexes which can be cached in the engine.

Command environment variables

Many of the arguments passed into the CLI can be set using the above environment variables instead.

As each of these environment variables correspond to a flag or a required argument passed into a command, it is good practice to put together a command that matches the environment variables you wish to set. Once the database server conforms to your expected behaviour, you can then pull out the values passed into each flag for your environment variables.

For example, take the following command to start the database.

surreal start --user root --pass root --allow-net --deny-funcs "crypto::md5, http::post, http::delete"

If we now wanted to use environment variables instead of the --allow-net and --deny-funcs flags, we would use the SURREAL_CAPS_ALLOW_NET and SURREAL_CAPS_DENY_FUNC environment variables.

As the --allow-net flag was passed in without a following value, the same will be the case with the SURREAL_CAPS_ALLOW_NET environment variable, becoming SURREAL_CAPS_ALLOW_NET=. The --deny-funcs flag can also be used on its own to deny execution of all functions, but in this case is followed by a string to indicate which exact functions are not allowed to be executed. As such, the SURREAL_CAPS_DENY_FUNC environment variable must also be followed by a string, becoming SURREAL_CAPS_DENY_FUNC="crypto::md5, http::post, http::delete".

The command would then look like the following:

SURREAL_CAPS_ALLOW_NET
SURREAL_CAPS_DENY_FUNC="crypto::md5, http::post, http::delete"
surreal start --user root --pass root

A command environment variable that takes a boolean will be set to true if the flag is present, and following it with true will cause an error.

For example, the SURREAL_CAPS_ALLOW_ALL environment variable is used to set whether to allow all capabilities such as scripting and allowing network access. The flag --allow-all is all that is needed to set to true. But as an environment variable, the value true must be included to override its default false value.

SURREAL_CAPS_ALLOW_ALL example

# set to default false
surreal start

# Same, but implicitly shown
SURREAL_CAPS_ALLOW_ALL=false surreal start

# Set to true
SURREAL_CAPS_ALLOW_ALL=true surreal start

# Set to true
surreal start --allow-all

# Error: only --allow-all needed to set to true
surreal start --allow-all true
Environment variableCommand argFor command(s)DefaultAllowed valuesDetails
SURREAL_ASYNC_EVENT_PROCESSING_INTERVAL async-event-processing-intervalstart5sA durationThe interval at which to process async events.
SURREAL_AUTH_LEVELauth-levelexport, import, sqlrootroot, namespace, ns, database, dbAuthentication level to use when connecting.
SURREAL_BINDbindstart127.0.0.1:8000String to an addressThe hostname or IP address(es) to listen for connections on.
SURREAL_CAPS_ALLOW_ALLallow-allstartfalsetrue, falseAllow all capabilities.
SURREAL_CAPS_ALLOW_ARBITRARY_QUERYallow-arbitrary-querystartnoneguest, record, system (comma-separated)Allows arbitrary queries to be used by user groups except when specifically denied. Alternatively, you can provide a comma-separated list of user groups to allow specifically denied user groups to prevail over any other allowed user group.
SURREAL_CAPS_ALLOW_EXPERIMENTALallow-experimentalstartnonefiles, surrealism (comma-separated)Allow execution of experimental features.
SURREAL_CAPS_ALLOW_FUNCallow-funcsstartfalsetrue, false, comma-separated strings to function pathsAllow execution of all functions except for functions that are specifically denied.
SURREAL_CAPS_ALLOW_GUESTSallow-guestsstarttruetrue, falseAllow guest users to execute queries.
SURREAL_CAPS_ALLOW_NETallow-netstartnoneComma-separated list of pathsAllow all or certain outbound network access.
SURREAL_CAPS_ALLOW_SCRIPTallow-scriptingstarttruetrue, falseAllow execution of embedded scripting functions.
SURREAL_CAPS_ALLOW_INSECURE_STORABLE_CLOSURESallow-insecure-storable-closuresstartfalsetrue, falseTakes a boolean. Prevents closures from being stored, which eliminates a potential attack surface. For version 2.5.0, this can still be allowed by using this capability.
SURREAL_CAPS_DENY_ALLdeny-allstartfalsetrue, falseDeny all capabilities.
SURREAL_CAPS_DENY_FUNCdeny-funcsstartfalsetrue, false, comma-separated listDeny execution of all or certain functions.
SURREAL_CAPS_DENY_GUESTSdeny-guestsstarttruetrue, falseDeny guest users from executing queries.
SURREAL_CAPS_DENY_NETdeny-netstarttruetrue, false, comma-separated listDeny all or certain outbound access paths.
SURREAL_CAPS_DENY_SCRIPTdeny-scriptingstarttruetrue, falseDeny execution of embedded scripting functions.
SURREAL_CHANGEFEED_GC_INTERVALchangefeed-gc-intervalstart30sA durationThe interval at which to perform changefeed garbage collection.
SURREAL_CLIENT_IPclient-ipstartnonenone, socket, CF-Connecting-IP, Fly-Client-IP, True-Client-IP, X-Real-IP, X-Forwarded-ForThe method of detecting the client's IP address.
SURREAL_DATABASEdatabasesqlmainA stringThe database selected when starting the REPL.
SURREAL_DATABASEdatabaseexport, importnoneA stringThe database selected for the import or export.
SURREAL_DEFAULT_DATABASEdefault-databasestartmainA stringThe default database to use when starting a SurrealDB instance.
SURREAL_DEFAULT_NAMESPACEdefault-namespacestartmainA stringThe default namespace to use when starting a SurrealDB instance.
SURREAL_HIDE_WELCOMEhide-welcomesqlfalsetrue, falseWhether to show the welcome message when starting the REPL.
SURREAL_IMPORT_FILEimport-filestartnoneA file pathPath to a SurrealQL file that will be imported when starting the server.
SURREAL_INDEX_COMPACTION_INTERVALindex-compaction-intervalstart5sA durationThe interval at which to perform changefeed garbage collection.
SURREAL_KEYkeystartnoneA string 16, 24, or 32 bytes longEncryption key to use for on-disk encryption. Not currently in use.
SURREAL_KVS_CAkvs-castartnoneString to a pathPath to the CA file used when connecting to the remote KV store.
SURREAL_KVS_CRTkvs-crtstartnoneString to a pathPath to the certificate file used when connecting to the remote KV store.
SURREAL_KVS_KEYkvs-keystartnoneString to a pathPath to the private key file used when connecting to the remote KV store.
SURREAL_LOGlogstart, fixinfonone, full, error, warn, info, debug, traceThe logging level for the database server.
SURREAL_LOG_FILE_ENABLEDlog-file-enabledstartfalsetrue, falseToggles file output.
SURREAL_LOG_FILE_FORMATlog-file-formatstartnonetext, jsonThe format for log file output.
SURREAL_LOG_FILE_LEVELlog-file-levelstartnonenone, full, error, warn, info, debug, traceOverride the logging level for file output
SURREAL_LOG_FILE_NAMElog-file-namestartsurrealdb.logString to a fileFilename for logs (default: surrealdb.log)
SURREAL_LOG_FILE_PATHlog-file-pathstartlogsString to a pathSets the directory for logs
SURREAL_LOG_FILE_ROTATIONlog-file-rotationstartdailydaily, hourly, neverSets the rotation duration for logs.
SURREAL_LOG_FORMATlog-formatstarttexttext, jsonSets the format for logs.
SURREAL_LOG_OTEL_LEVELlog-otel-levelstartSURREAL_LOG logging levelnone, full, error, warn, info, debug, traceOverride the logging level for OpenTelemetry
SURREAL_LOG_SOCKETlog-socketstartnoneString to a host:portSend logs to the specified host:port
SURREAL_LOG_SOCKET_FORMATlog-socket-formatstarttexttext, json Set the format of the logs to the socket.
SURREAL_LOG_SOCKET_LEVELlog-socket-levelstartSURREAL_LOG logging levelnone, full, error, warn, info, debug, trace Override the logging level for socket logs. Possible values: none, full, error, warn, info, debug, trace
SURREAL_NAMEnameml exportnoneA stringThe name of the model.
SURREAL_NAMESPACEnamespacesqlmainA stringThe namespace to connect to via the REPL.
SURREAL_NAMESPACEnamespaceexport, importnoneA stringThe namespace selected for the import/export operation.
SURREAL_NO_BANNERno-bannerstartfalsetrue, falseWhether to hide the startup banner.
SURREAL_NO_DEFAULTSno-defaults`start`falsetrue, falseWhether to disable default namespace and database creation. Conflicts with SURREAL_DEFAULT_DATABASE and SURREAL_DEFAULT_NAMESPACE, which set a default value for namespace and database for a new instance.
SURREAL_NO_IDENTIFICATION_HEADERSno-identification-headersstartfalsetrue, falseWhether to suppress the server name and version headers.
SURREAL_NODE_MEMBERSHIP_CHECK_INTERVALnode-membership-check-intervalstart15sA durationThe interval at which to process and archive inactive nodes.
SURREAL_NODE_MEMBERSHIP_CLEANUP_INTERVALnode-membership-cleanup-intervalstart300sA durationThe interval at which to process and cleanup archived nodes.
SURREAL_NODE_MEMBERSHIP_REFRESH_INTERVALnode-membership-refresh-intervalstart3sA durationThe interval at which to refresh node registration information.
SURREAL_PASSpassexport, import, sql, startnoneA stringDatabase authentication password to use when connecting.
SURREAL_PATHpathfix, startmemoryA stringDatabase path used for storing data. As a required argument (albeit with a default), it is not passed in via --path.
SURREAL_PLANNER_STRATEGYplanner-strategystartbest-effortbest-effort|compute-only|all-read-onlyWhich strategy to use with the new query planner introduced in SurrealDB 3.0. The default setting uses the new planner for read-only statements, falling back to the previous compute planner on unimplemented paths. The new planner can be skipped entirely by using compute-only.
SURREAL_QUERY_TIMEOUTquery-timeoutstartnoneA durationThe maximum duration that a set of statements can run for.
SURREAL_SLOW_QUERY_LOG_THRESHOLDslow-log-thresholdstartnoneA durationA duration specifying the minimum execution time after which a log is made to indicate a slow query
SURREAL_SLOW_QUERY_LOG_PARAM_ALLOWslow-log-param-allow slow-log-param-allowstartnoneComma-separated stringsA comma-separated list of parameter names to include in slow query logs.
SURREAL_SLOW_QUERY_LOG_PARAM_DENYslow-log-param-denystartnoneComma-separated stringsA comma-separated list of parameter names to omit from slow query logs.
SURREAL_STRICTstrictstartfalsetrue, falseWhether strict mode is enabled on this database instance. Ignored since SurrealDB 3.0 after which strictness is defined per database instead of instance.
SURREAL_TEMPORARY_DIRECTORYtemporary-directorystartnoneString to a directorySets the directory for storing temporary database files
SURREAL_TOKENtokenexport, import, sqlnoneA stringAuthentication token in JWT format to use when connecting.
SURREAL_TRANSACTION_TIMEOUTtransaction-timeoutstartnoneA durationThe maximum duration that any single transaction can run for.
SURREAL_UNAUTHENTICATEDunauthenticatedstartfalsetrue, falseWhether to allow unauthenticated access.
SURREAL_USERuserexport, import, sql, startnoneA stringDatabase authentication username to use when connecting.
SURREAL_VERSIONversionml exportnoneA stringThe version of the ML model.
SURREAL_WEB_CRTweb-crtstartnoneString to a pathPath to the certificate file for encrypted client connections.
SURREAL_WEB_KEYweb-keystartnoneString to a pathPath to the private key file for encrypted client connections.

Storage backend environment variables

These environment variables are used to configure the storage backend for SurrealDB.

RocksDB environment variables

Many RocksDB environment variables pertain to memory use. The default configuration results in the following rough estimates of RocksDB memory use on different instances:

Instance memory sizeEstimate
512 MiB~ 80MiB
1 GiB~ 80MiB
2 GiB~ 640MiB
4 GiB~ 1.25GiB
8 GiB~ 3.25GiB
24 GiB~ 12GiB
128 GiB~ 67GiB

The available environment variables for configuring a RocksDB instance are:

Environment variableDefaultAllowed valuesNotes
SURREAL_ROCKSDB_BACKGROUND_FLUSHtruefalse, trueWhether to enable background WAL file flushing.
SURREAL_ROCKSDB_BACKGROUND_FLUSH_INTERVAL200 (milliseconds)A usizeThe interval in milliseconds between background flushes.
SURREAL_ROCKSDB_BLOB_COMPRESSION_TYPEsnappynone, snappy, lz4, zstdCompression type used for blob files.
SURREAL_ROCKSDB_BLOB_FILE_SIZE268,435,456 (256 MiB)A usizeThe target blob file size for RocksDB.
SURREAL_ROCKSDB_ENABLE_BLOB_GCtruetrue, falseWhether to enable blob garbage collection for RocksDB.
SURREAL_ROCKSDB_BLOB_GC_AGE_CUTOFF0.5Float between 0 and 1Fractional age cutoff for blob GC.
SURREAL_ROCKSDB_BLOB_GC_FORCE_THRESHOLD0.5Float between 0 and 1Discardable ratio threshold to force GC.
SURREAL_ROCKSDB_BLOB_COMPACTION_READAHEAD_SIZE0A usizeReadahead size for blob compaction/GC.
SURREAL_ROCKSDB_BLOCK_CACHE_SIZEDynamically calculated via greater of ((system memory / 2) - 1 GiB) and 16MiBA usizeRocksDB block cache size in bytes
SURREAL_ROCKSDB_BLOCK_SIZE65,536 (64 KiB)A usizeThe size of each uncompressed data block in bytes.
SURREAL_ROCKSDB_COMPACTION_READAHEAD_SIZE4 MiB (systems under 4 GiB), 8 MiB (up to 16 GiB), 16 MiB (others)A usizeThe readahead buffer size used during compaction.
SURREAL_ROCKSDB_COMPACTION_STYLE levellevel, universalUse to specify the database compaction style.
SURREAL_ROCKSDB_DELETION_FACTORY_DELETE_COUNT50A usizeThe number of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_RATIO0.5A floatThe ratio of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_WINDOW_SIZE1000A usizeThe size of the window used to track deletions.
SURREAL_ROCKSDB_ENABLE_BLOB_FILEStruetrue, falseWhether to enable separate key and value file storage.
SURREAL_ROCKSDB_ENABLE_PIPELINED_WRITEStruetrue, falseWhether to use separate queues for WAL writes and memtable writes.
SURREAL_ROCKSDB_GROUPED_COMMITtruetrue, falseWhether to enable grouped commit when sync is enabled. When enabled, multiple transaction commits are batched together and flushed to disk with a single fsync operation, improving throughput. When disabled, each transaction is committed and synced individually, which may provide lower latency for single transactions at the cost of reduced throughput under high load. Only used when SURREAL_SYNC_DATA is enabled and SURREAL_ROCKSDB_BACKGROUND_FLUSH is disabled.
SURREAL_ROCKSDB_GROUPED_COMMIT_MAX_BATCH_SIZE4096A usizeThe maximum number of transactions in a single grouped commit batch. Used to prevent unbounded memory growth while still allowing large batches for efficiency. Larger batches improve throughput but increase memory usage and commit latency.
SURREAL_ROCKSDB_GROUPED_COMMIT_TIMEOUT5msA durationThe maximum wait time in nanosecond before forcing a grouped commit. Used to ensure that transactions do not wait indefinitely when concurrency is low, and to balance between transaction latency and write throughput.
SURREAL_ROCKSDB_GROUPED_COMMIT_WAIT_THRESHOLD12A usizeThreshold for deciding whether to wait for more transactions. If the current batch size is greater or equal to this threshold (and below ROCKSDB_GROUPED_COMMIT_MAX_BATCH_SIZE), then the coordinator will wait up to ROCKSDB_GROUPED_COMMIT_TIMEOUT to collect more transactions. Smaller batches are flushed immediately to preserve low latency.
SURREAL_ROCKSDB_FILE_COMPACTION_TRIGGER4A usizeThe number of files needed to trigger level 0 compaction.
SURREAL_ROCKSDB_JOBS_COUNT Number of CPUs * 2A usizeThe maximum number of threads to use for flushing and compaction.
SURREAL_ROCKSDB_KEEP_LOG_FILE_NUM10A usizeThe maximum number of information log files to keep.
SURREAL_ROCKSDB_MAX_CONCURRENT_SUBCOMPACTIONS4A usizeThe maximum number threads which will perform compactions.
SURREAL_ROCKSDB_MAX_OPEN_FILES1024A usizeThe maximum number of open files which can be opened by RocksDB.
SURREAL_ROCKSDB_MAX_WRITE_BUFFER_NUMBER2 (systems under 4 GiB), 4 (up to 16 GiB), 8 (up to 64 GiB), 32 (others)A usizeThe maximum number of write buffers which can be used.
SURREAL_ROCKSDB_MIN_BLOB_SIZE4096A usizeThe minimum size in bytes of a value for it to be stored in blob files.
SURREAL_ROCKSDB_MIN_WRITE_BUFFER_NUMBER_TO_MERGE2A usizeThe minimum number of write buffers to merge before writing to disk.
SURREAL_ROCKSDB_SST_MAX_ALLOWED_SPACE_USAGE0A usizeThe maximum allowed space usage for SST files in bytes. The default of 0 means unlimited and disables space monitoring. When this limit is reached, the datastore enters read-and-deletion-only mode, where only read and delete operations are allowed. This allows gradual space recovery through data deletion.
SURREAL_ROCKSDB_STORAGE_LOG_LEVELwarnnone, full, error, warn, info, debug, traceThe information log level of the RocksDB library.
SURREAL_ROCKSDB_TARGET_FILE_SIZE_BASE67,108,864 (64 MiB)The target file size for compaction in bytes.
SURREAL_ROCKSDB_TARGET_FILE_SIZE_MULTIPLIER2A usizeThe target file size multiplier for each compaction level.
SURREAL_ROCKSDB_THREAD_COUNTNumber of CPUs on machineA usizeThe number of threads to start for flushing and compaction.
SURREAL_ROCKSDB_WAL_SIZE_LIMIT0A usizeThe write-ahead-log size limit in MiB.
SURREAL_ROCKSDB_WRITE_BUFFER_SIZE32 MiB (systems under 1 GiB), 64 MiB (up to 16 GiB), 128 MiB (others)A usizeThe amount of data each write buffer can build up in memory.
SURREAL_SYNC_DATAtruetrue, falseWhether to sync writes to disk before acknowledgement.

SurrealKV environment variables

Environment variableDefaultAllowed valuesNotes
SURREAL_SURREALKV_ENABLE_VLOGtruetrue, falseWhether to enable value log separation.
SURREAL_SURREALKV_VERSIONED_INDEXfalsetrue, falseWhether to enable versioned index. Only applies when versioning is enabled.
SURREAL_SURREALKV_BLOCK_SIZE65_536 (64 KiB)A usizeThe block size in bytes.
SURREAL_SURREALKV_VLOG_MAX_FILE_SIZE64 MiB (systems under 4 GiB), 128 MiB (up to 16 GiB), 256 MiB (up to 64 GiB), 512 MiB (others)A usizeThe readahead buffer size used during compaction.
SURREAL_SURREALKV_VLOG_THRESHOLD4096 (4 KiB)A usizeThe value log threshold in bytes. Values larger than this are stored in the value log.
SURREAL_SURREALKV_BLOCK_CACHE_CAPACITYDynamically calculated via greater of ((system memory / 2) - 1 GiB) and 16MiBA usizeThe maximum log file size in bytes.
SURREAL_SURREALKV_GROUPED_COMMIT_TIMEOUT5msA duration in nanosecondsThe maximum wait time in nanoseconds before forcing a grouped commit. Ensures that transactions do not wait indefinitely under low concurrency and balances commit latency against write throughput.
SURREAL_SURREALKV_GROUPED_COMMIT_WAIT_THRESHOLD12A usizeThreshold for deciding whether to wait for more transactions. If the current batch size is greater or equal to this threshold (and below SURREAL_SURREALKV_GROUPED_COMMIT_MAX_BATCH_SIZE), then the coordinator will wait up to SURREAL_SURREALKV_GROUPED_COMMIT_TIMEOUT to collect more transactions. Smaller batches are flushed immediately to preserve low latency.
SURREAL_SURREALKV_GROUPED_COMMIT_MAX_BATCH_SIZE4096A usizeThe maximum number of transactions in a single grouped commit batch. This prevents unbounded memory growth while still allowing large batches for efficiency. Larger batches improve throughput but increase memory usage and commit latency.

TiKV environment variables

Environment variableDefaultAllowed valuesNotes
SURREAL_TIKV_API_VERSION1A u8Which TiKV cluster API version to use.
SURREAL_TIKV_ASYNC_COMMITtruetrue, falseWhether to use asynchronous transactions.
SURREAL_TIKV_KEYSPACEnoneA stringA string specifying the keyspace identifier for data isolation.
SURREAL_TIKV_GRPC_MAX_DECODING_MESSAGE_SIZE4,194,304 (4 MiB)A usizeSets the maximum decoding size of a gRPC message.
SURREAL_TIKV_ONE_PHASE_COMMITtruetrue, falseWhether to use one-phase transaction commit.
SURREAL_TIKV_REQUEST_TIMEOUT10A usizeThe duration in seconds for requests before they time out.

FoundationDB environment variables

Environment variableDefault valueNotes
SURREAL_FOUNDATIONDB_TRANSACTION_MAX_RETRY_DELAY500The maximum delay between transaction retries in milliseconds.
SURREAL_FOUNDATIONDB_TRANSACTION_RETRY_LIMIT5The maximum number of times a transaction can be retried.
SURREAL_FOUNDATIONDB_TRANSACTION_TIMEOUT5000The maximum transaction timeout in milliseconds.

SurrealDB Cloud environment variables

Instances on SurrealDB Cloud are not started with a CLI command or environment variables. Instead, they can be set on the Configure Instance panel.