SurrealDB
SurrealDB Docs Logo

Enter a search query

Navigation
Table of Contents

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_STRICT=true surreal start, equivalent to surreal start --strict.
  • 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.

SurrealDB environment variables

Environment variableDefaultAllowed valuesNotes
SURREAL_BUCKET_FOLDER_ALLOWLISTnoneComma-separated pathsSpecifies a list of paths in which files can be accessed.
SURREAL_BUILD_METADATAAutomatically populatedA stringThe version identifier of this build. Defaults to the CARGO_PKG_VERSION environment variable if not specified.
SURREAL_CHANGEFEED_GC_INTERVAL30sA durationThe interval at which to perform changefeed garbage collection.
SURREAL_COUNT_BATCH_SIZE

Available since: v2.2.0

10,000A usizeThe maximum number of keys that should be scanned at once for count queries.
SURREAL_DATASTORE_CACHE_SIZE

Available since: v2.1.0

1,000A usizeThe number of definitions which can be cached across transactions.
SURREAL_DEFAULT_DATABASE

Available since: v3.0.0-beta

mainA stringThe default database to use when starting a SurrealDB instance.
SURREAL_DEFAULT_NAMESPACE

Available since: v3.0.0-beta

mainA stringThe default namespace to use when starting a SurrealDB instance.
SURREAL_ASYNC_EVENT_PROCESSING_INTERVAL

Available since: v3.0.0-beta

5sA durationThe interval at which to process async events.
SURREAL_EXPORT_BATCH_SIZE1000A usizeThe maximum number of keys that should be scanned at once for export queries.
SURREAL_EXTERNAL_SORTING_BUFFER_LIMIT50000A usizeThe number of result records which will trigger on-disk sorting.
SURREAL_FILE_ALLOWLIST

Available since: v2.1.5

noneComma-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_GENERATION_ALLOCATION_LIMIT20An integerLimits 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_GLOBAL_BUCKET_ENFORCEDfalsetrue, falseWhether to enforce a global bucket for file data.
SURREAL_HNSW_CACHE_SIZE268,435,456 (256 MiB)A usizeThe maximum size of the HNSW vector cache.
SURREAL_HTTP_CONNECT_TIMEOUT_SECS30A usizeThe timeout for connecting to HTTP endpoints.
SURREAL_HTTP_IDLE_TIMEOUT_SECS90A usizeThe timeout for idle HTTP connections before closing.
SURREAL_HTTP_MAX_API_BODY_SIZE4,194,304 (4 MiB)A usizeThe maximum HTTP body size of the HTTP /api 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_KEY_BODY_SIZE16,384 (16 KiB)A usizeMaximum HTTP body size of the HTTP /key endpoints
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_RPC_BODY_SIZE4,194,304 (4 MiB)A usizeMaximum HTTP body size of the HTTP /rpc endpoint.
SURREAL_HTTP_MAX_SQL_BODY_SIZE1,048,576 (1 MiB)A usizeMaximum HTTP body size of the HTTP /sql endpoint
SURREAL_HTTP_MAX_SIGNIN_BODY_SIZE1024 (1 KiB)A usizeThe maximum HTTP body size of the HTTP /signin endpoints
SURREAL_HTTP_MAX_SIGNUP_BODY_SIZE1024 (1 KiB)A usizeMaximum HTTP body size of the HTTP /signup endpoint.
SURREAL_IDIOM_RECURSION_LIMIT256A usizeThe maximum recursive idiom path depth allowed.
SURREAL_IMPORT_FILEnoneA file pathPath to a SurrealQL file that will be imported when starting the server.
SURREAL_INDEXING_BATCH_SIZE250A usizeThe maximum number of keys to scan at once per concurrent indexing batch.
SURREAL_INSECURE_FORWARD_ACCESS_ERRORSfalsetrue, falseForward all signup/signin/authenticate query errors to a client performing authentication. Do not use in production.
SURREAL_MAX_BATCH_SIZE5,000A usizeThe maximum batch size for Scanner adaptive fetching.
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_HTTP_IDLE_CONNECTIONS1000A usizeThe maximum number of idle HTTP connections to maintain.
SURREAL_MAX_HTTP_IDLE_CONNECTIONS_PER_HOST128A usizeThe maximum number of idle HTTP connections to maintain per host.
SURREAL_MAX_HTTP_REDIRECTS

Available since: v2.0.5

10A usizeThe maximum number of HTTP redirects allowed within http functions.
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_SIZE

Available since: v2.2.0

1000A 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_MEMORY_THRESHOLD

Available since: v2.1.5

0A 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_NET_MAX_CONCURRENT_REQUESTS1,048,576A usizeHow many concurrent network requests can be handled at once
SURREAL_NO_DEFAULTS

Available since: v3.0.0-beta

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_NODE_MEMBERSHIP_CHECK_INTERVAL15sA durationThe interval at which to process and archive inactive nodes.
SURREAL_NODE_MEMBERSHIP_CLEANUP_INTERVAL300sA durationThe interval at which to process and cleanup archived nodes.
SURREAL_NODE_MEMBERSHIP_REFRESH_INTERVAL3sA durationThe interval at which to refresh node registration information.
SURREAL_NORMAL_FETCH_SIZE500A durationThe maximum number of keys that should be scanned at once in general queries.
SURREAL_REGEX_CACHE_SIZE1000A durationThe number of computed regexes which can be cached in the engine.
SURREAL_REGEX_SIZE_LIMIT

Available since: v2.1.5

10,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.
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.
SURREAL_SCRIPTING_MAX_MEMORY_LIMIT2,097,152 (2 MiB)A usizeMaximum memory limit of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_STACK_SIZE262_144 (256 KiB)A usizeMaximum stack size of the JavaScript function runtime.
SURREAL_SCRIPTING_MAX_TIME_LIMIT

Available since: v2.0.5

5000 (5000 milliseconds or 5 secondsA usize)Maximum allowed time in milliseconds that a JavaScript function is allowed to run for.
SURREAL_SURREALISM_CACHE_SIZE

Available since: v3.0.0-beta

100A usizeThe number of surrealism modules which can be cached across transactions.
SURREAL_TELEMETRY_DISABLE_METRICS

Available since: v2.1.3

falsetrue, falseWhether to disable sending metrics to the GRPC OTEL collector.
SURREAL_TELEMETRY_DISABLE_TRACING

Available since: v2.1.3

falsetrue, 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_TEMPORARY_DIRECTORYnoneA string to a directorySets the directory for storing temporary database files.
SURREAL_TOKIO_CONSOLE_ENABLED

Available since: v3.0.0-beta

falsetrue, falseWhether to enable tokio console.
SURREAL_TOKIO_CONSOLE_RETENTION

Available since: v3.0.0-beta

60A usizeHow long, in seconds, to retain data for completed events.
SURREAL_TOKIO_CONSOLE_SOCKET_ADDR

Available since: v3.0.0-beta

falseA string to a socket addressThe socket address that Tokio Console will bind to.
SURREAL_TRANSACTION_CACHE_SIZE10,000A usizeSpecifies the number of items which can be cached within a single transaction.
SURREAL_WEBSOCKET_MAX_MESSAGE_SIZE134,217,728 (128 MiB)A usizeMaximum WebSocket message size.
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.

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

Boolean values in command environment variables

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_AUTH_LEVELauth-levelexport, import, sqlrootroot, namespace, ns, database, dbAuthentication level to use when connecting.
SURREAL_BINDbindstart127.0.0.1:8000A string 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-experimentalstartnonegraphql, define_api, files, 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_NET-allow-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_CLOSURES

Available since: v2.5.0

allow-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_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_HIDE_WELCOMEhide-welcomesqlfalsetrue, falseWhether to show the welcome message when starting the REPL.
SURREAL_INDEX_COMPACTION_INTERVAL

Available since: v3.0.0-beta

index-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-castartnoneA string to a pathPath to the CA file used when connecting to the remote KV store.
SURREAL_KVS_CRTkvs-crtstartnoneA string to a pathPath to the certificate file used when connecting to the remote KV store.
SURREAL_KVS_KEYkvs-keystartnoneA string 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_ENABLED

Available since: v2.4.0

log-file-enabledstarttruetrue, falseToggles file output (default: false)
SURREAL_LOG_FILE_FORMAT

Available since: v2.4.0

log-file-formatstartnonetext, jsonThe format for log file output.
SURREAL_LOG_FILE_LEVEL

Available since: v2.4.0

log-file-levelstartnonenone, full, error, warn, info, debug, traceOverride the logging level for file output
SURREAL_LOG_FILE_NAME

Available since: v2.4.0

log-file-namestartsurrealdb.logString to a fileFilename for logs (default: surrealdb.log)
SURREAL_LOG_FILE_PATH

Available since: v2.4.0

log-file-pathstartlogsString to a pathSets the directory for logs
SURREAL_LOG_FILE_ROTATION

Available since: v2.4.0

log-file-rotationstartdailydaily, hourly, neverSets the rotation duration for logs.
SURREAL_LOG_FORMAT

Available since: v2.4.0

log-formatstarttexttext, jsonSets the format for logs.
SURREAL_LOG_OTEL_LEVEL
log-otel-level

Available since: v2.4.0

startSURREAL_LOG logging levelnone, full, error, warn, info, debug, traceOverride the logging level for OpenTelemetry
SURREAL_LOG_SOCKET

Available since: v3.0.0-beta

log-socketstartnoneString to a host:portSend logs to the specified host:port
SURREAL_LOG_SOCKET_FORMAT

Available since: v3.0.0-beta

log-socket-formatstarttexttext, jsonSet the format of the logs to the socket.
SURREAL_LOG_SOCKET_LEVEL

Available since: v3.0.0-beta

log-socket-levelstartSURREAL_LOG logging levelnone, full, error, warn, info, debug, traceOverride 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_IDENTIFICATION_HEADERSno-identification-headersstartfalsetrue, falseWhether to suppress the server name and version headers.
SURREAL_PASSpassexport, import, sql, startnoneA stringDatabase authentication password to use when connecting.
SURREAL_PATHfix, startmemoryA stringDatabase path used for storing data. As a required argument (albeit with a default), it is not passed in via --path.
SURREAL_QUERY_TIMEOUTquery-timeoutstartnoneA durationThe maximum duration that a set of statements can run for.
SURREAL_SLOW_QUERY_LOG_THRESHOLD
slow-log-threshold

Available since: v2.3.8

startnoneA durationA duration specifying the minimum execution time after which a log is made to indicate a slow query
SURREAL_SLOW_QUERY_LOG_PARAM_ALLOW
slow-log-param-allow

Available since: v2.3.9

startnoneComma-separated stringsA comma-separated list of parameter names to include in slow query logs.
SURREAL_SLOW_QUERY_LOG_PARAM_DENY

Available since: v2.3.9

slow-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.
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.

Environment variables by storage backend

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

FoundationDB environment variables

Warning

FoundationDB support is deprecated in SurrealDB 3.0. Please plan to migrate to a supported storage backend.

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.

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

Available since: v2.0.3

levellevel, universalUse to specify the database compaction style.
SURREAL_ROCKSDB_DELETION_FACTORY_DELETE_COUNT

Available since: v2.0.3

50A usizeThe number of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_RATIO

Available since: v2.0.3

0.5A floatThe ratio of deletions to track in the window.
SURREAL_ROCKSDB_DELETION_FACTORY_WINDOW_SIZE

Available since: v2.0.3

1000A 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 usizeThe maximum wait time in microseconds 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

Available since: v2.0.3

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_ENABLE_VLOGtruetrue, falseWhether to enable value log separation.
SURREAL_BLOCK_SIZE65_536 (64 KiB)A usizeThe block size in bytes.
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.
SURREALKV_BLOCK_CACHE_CAPACITYDynamically calculated via greater of ((system memory / 2) - 1 GiB) and 16MiBA usizeThe maximum log file size in bytes.
SURREAL_SYNC_DATAtruetrue, falseThe block cache capacity in bytes.

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_SIZE

Available since: v2.1.8

4,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.

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.