Operating

Data Store Configuration

Set up PostgreSQL, Redis, and Typesense for your Blnk deployment.

Blnk relies on PostgreSQL and Redis to run core ledger operations, and can optionally use TypeSense for search and indexing. This page explains the settings used to connect and tune each service.

Set them in a blnk.json file or with environment variables that use the BLNK_ prefix. PostgreSQL and Redis are the only connections Blnk needs to start.

Database settings

Use these settings to configure Blnk’s PostgreSQL connection and connection pool.

BLNK_DATA_SOURCE_DNS="postgres://user:pass@postgres:5432/blnk?sslmode=disable"
BLNK_DATABASE_MAX_OPEN_CONNS=50
BLNK_DATABASE_MAX_IDLE_CONNS=25
BLNK_DATABASE_CONN_MAX_LIFETIME=30m
BLNK_DATABASE_CONN_MAX_IDLE_TIME=5m
{
  "data_source": {
    "dns": "postgres://user:pass@postgres:5432/blnk?sslmode=disable",
    "max_open_conns": 50,
    "max_idle_conns": 25,
    "conn_max_lifetime": 1800,
    "conn_max_idle_time": 300
  }
}
BLNK_DATA_SOURCE_DNSrequired

PostgreSQL connection string used by Blnk.

BLNK_DATABASE_MAX_OPEN_CONNSdefault 50

Maximum number of open database connections in the pool.

BLNK_DATABASE_MAX_IDLE_CONNSdefault 25

Maximum number of idle database connections kept ready.

BLNK_DATABASE_CONN_MAX_LIFETIMEdefault 30m

Maximum amount of time a database connection can be reused before it is recycled.

BLNK_DATABASE_CONN_MAX_IDLE_TIMEdefault 5m

Maximum amount of time an idle database connection is kept before it is recycled.

BLNK_DATA_SOURCE_DNS

This is the PostgreSQL connection string Blnk uses to connect to its database. This setting is required. Blnk will not start without it.

From 0.15.4, Blnk retries the initial database connection instead of exiting on the first failure.

  1. Make sure the database is reachable from the environment where Blnk is running. This includes verifying the hostname, port, credentials, and network access rules before starting the server.

  2. You should also make sure the sslmode in the connection string matches what your database provider expects. If this is set incorrectly, Blnk may fail to connect even when the rest of the connection string is valid.

Best practices

  1. Always set BLNK_DATA_SOURCE_DNS explicitly.
  2. Start with the default pool settings unless you already know your database limits.
  3. Increase BLNK_DATABASE_MAX_OPEN_CONNS only if your PostgreSQL instance can handle more concurrent connections.
  4. Use the connection lifetime and idle time settings to recycle stale connections in long-running deployments.

Redis configuration

BLNK_REDIS_DNS=redis://:password@redis:6379/0
BLNK_REDIS_SKIP_TLS_VERIFY=false
BLNK_REDIS_POOL_SIZE=100
BLNK_REDIS_MIN_IDLE_CONNS=20
BLNK_REDIS_CONN_MAX_IDLE_TIME=2m
{
  "redis": {
    "dns": "redis://:password@redis:6379/0",
    "skip_tls_verify": false,
    "pool_size": 100,
    "min_idle_conns": 20,
    "conn_max_idle_time": 120000000000
  }
}
BLNK_REDIS_DNSrequired

Redis address or connection URL used by Blnk.

BLNK_REDIS_SKIP_TLS_VERIFYdefault false

Disables TLS certificate verification for Redis connections.

BLNK_REDIS_POOL_SIZEdefault 100

Maximum connections in the Redis pool.

BLNK_REDIS_MIN_IDLE_CONNSdefault 20

Idle connections kept ready in the pool.

BLNK_REDIS_CONN_MAX_IDLE_TIMEdefault 2m

How long a pooled connection may sit idle before Blnk discards it. Env: Go duration (2m). JSON: nanoseconds. From 0.15.5.

BLNK_REDIS_DNS

BLNK_REDIS_DNS is the Redis address or connection URL Blnk uses for queueing and coordination. This setting is required.

Why? Because Blnk uses Redis for distributed balance locks, transaction and webhook queues, hot-pair state, and other worker coordination. If Redis is unavailable, queue processing and lock coordination are affected even if PostgreSQL is healthy.

BLNK_REDIS_SKIP_TLS_VERIFY

This disables certificate verification for TLS Redis connections.

Only set to true when you are working in a controlled environment and understand the risk. Disabling certificate verification weakens transport security and should not be the default for production deployments.

BLNK_REDIS_CONN_MAX_IDLE_TIME

Available in version 0.15.5 and later.

How long a pooled Redis or Asynq connection may sit idle before Blnk discards it instead of reusing it. Applies to Redis cache clients and Asynq queue workers. The default is 2m. Leave it unset unless your Redis, Valkey, or proxy idle timeout is shorter than that.

Set this below the server or proxy idle timeout (managed services often use about 300 seconds). If a connection stays idle longer than the remote timeout, the next command can fail with write: broken pipe.

Typesense configuration

Use these settings to enable Blnk search and indexing via Typesense.

BLNK_TYPESENSE_DNS=http://typesense:8108
BLNK_TYPESENSE_KEY=blnk-api-key
BLNK_TYPESENSE_BACKPRESSURE_RETRY_INTERVAL=5s
{
  "typesense": {
    "dns": "http://typesense:8108",
    "backpressure_retry_interval": 5000000000
  },
  "type_sense_key": "blnk-api-key"
}
BLNK_TYPESENSE_DNS

TypeSense server address. If unset, Blnk disables search and indexing features via Typesense.

BLNK_TYPESENSE_KEYdefault blnk-api-key

API key used to connect to TypeSense.

BLNK_TYPESENSE_BACKPRESSURE_RETRY_INTERVALdefault 5s

How long Blnk waits before retrying indexing or reindex work after Typesense reports a memory limit error.

TYPESENSE_MEMORY_USED_MAX_PERCENTAGEdefault 85

Typesense container setting. Caps Typesense memory usage as a percentage of available memory before it rejects writes.

Set Typesense memory limits on the Typesense service itself, not in Blnk:

TYPESENSE_MEMORY_USED_MAX_PERCENTAGE=85

When to use Typesense

TypeSense is optional. If it is not configured, Blnk starts just fine, but search and indexing features via Typesense are disabled.

For most search use cases, start with the Direct DB filter API. It is a better fit when you need precise database-backed filtering, sorting, and pagination without running a separate search service.

Use Typesense when you need full-text search, faceted filtering, faster queries across very large datasets, or search-oriented workflows that benefit from a dedicated index.