Skip to content

Why Are Electrs Address Balance Queries Slow (~900ms) on My Dockerized Bitcoin Full Node? #743

@PanagiotisDrakatos

Description

@PanagiotisDrakatos

I’m running a Bitcoin Core full node (bitcoind) and using romanz/electrs (via Docker) to provide btc explorer server functionality for querying address balances and related wallet info. However, I’m experiencing unexpectedly high latency: querying the balance for a random address consistently takes around 600-900 ms via btc-rpc-explorer RPC interface. For addresses with an enormous number of transactions, the query can take some seconds instead of ms

This is the Docker Compose yml file:

services:
  bitcoin_service:
    build:
      context: .
      dockerfile: Bitcoin.Dockerfile
      args:
        BITCOIN_VERSION: ${BTC_VERSION}
    image: bitcoin_full_node
    ports:
      - 8333:8333
      - 8332:8332
    volumes:
      - bitcoin_volume:/home/btc-user/.bitcoin
    networks:
      network:
        ipv4_address: 192.168.1.219
    healthcheck:
      test: [
        "CMD",
        "bitcoin-cli",
        "-rpccookiefile=/home/btc-user/.bitcoin/btc.cookie",
        "-rpcport=8332",
        "-rpcconnect=192.168.1.219",
        "getblockchaininfo"
      ]
      interval: 40s
      timeout: 60s
      retries: 45

  electrs:
    image: electrs:latest
    build:
      context: ./electrs/.
    container_name: electrs
    restart: always
    ports:
      - "50001:50001"    # Electrum TCP port exposed on host and container
    environment:
      - ELECTRS_NETWORK=bitcoin
      - ELECTRS_DAEMON_RPC_ADDR=192.168.1.219:8332
      - ELECTRS_DAEMON_P2P_ADDR=192.168.1.219:8333
      - ELECTRS_ELECTRUM_RPC_ADDR=192.168.1.223:50001
      - ELECTRS_LOG_FILTERS=INFO
      - ELECTRS_DB_DIR=/home/electrs/db
      - ELECTRS_VERBOSE_RPC_LOGS=true
      - ELECTRS_IGNORE_MEMPOOL=true
      - ELECTRS_TIMESTAMP_CACHE_CAPACITY=1000000  # Higher cache for faster lookups
      - ELECTRS_INDEX_LOOKUP_LIMIT=10000
      - ELECTRS_COOKIE_FILE=/home/btc-user/.bitcoin/btc.cookie
      - ELECTRS_THREADS=4
      - ELECTRS_DB_CACHE_SIZE=4096
    volumes:
      - electrs_db:/home/electrs/db
      - bitcoin_volume:/home/btc-user/.bitcoin:ro    # Mount same bitcoin data volume (read-only)
    networks:
      network:
        ipv4_address: 192.168.1.223 # new IP in the same subnet
    healthcheck:
      test: ["CMD-SHELL", "timeout 5 bash -c 'echo > /dev/tcp/192.168.1.223/50001'"]
      interval: 40s
      timeout: 60s
      retries: 45
    depends_on:
      bitcoin_service:
        condition: service_healthy
  explorer:
    container_name: btc-rpc-explorer
    environment:
      BTCEXP_HOST: $BTCEXP_HOST
      BTCEXP_PORT: $BTCEXP_PORT
      BTCEXP_ADDRESS_API: $BTCEXP_ADDRESS_API
      BTCEXP_ELECTRUM_SERVERS: $BTCEXP_ELECTRUM_SERVERS
      BTCEXP_ELECTRUM_TXINDEX: $BTCEXP_ELECTRUM_TXINDEX
      BTCEXP_BITCOIND_URI: $BTCEXP_BITCOIND_URI
      BTCEXP_BITCOIND_USER: $BTCEXP_BITCOIND_USER
      BTCEXP_BITCOIND_PASS: $BTCEXP_BITCOIND_PASS
      BTCEXP_BITCOIND_RPC_TIMEOUT: $BTCEXP_BITCOIND_RPC_TIMEOUT
      BTCEXP_SECURE_SITE: $BTCEXP_SECURE_SITE
      BTCEXP_COIN: $BTCEXP_COIN
      BTCEXP_RPC_CONCURRENCY: $BTCEXP_RPC_CONCURRENCY
      BTCEXP_SLOW_DEVICE_MODE: $BTCEXP_SLOW_DEVICE_MODE
      BTCEXP_NO_RATES: $BTCEXP_NO_RATES
      BTCEXP_RPC_ALLOWALL: $BTCEXP_RPC_ALLOWALL
      BTCEXP_UI_TIMEZONE: $BTCEXP_UI_TIMEZONE
      BTCEXP_UI_THEME: $BTCEXP_UI_THEME
    build:
      context: ./btc-rpc-explorer/.
    image: btc-rpc-explorer:latest
    volumes:
      - bitcoin_volume:/home/btc-user/.bitcoin:ro    # Mount same bitcoin data volume (read-only)
    networks:
      network:
        ipv4_address: 192.168.1.222
    ports:
      - "3002:3002"
    depends_on:
      electrs:
        condition: service_healthy

My Setup:

Bitcoin Core runs as a full node with default (non-pruned) settings.
Electrs runs in Docker with the following environment:
ELECTRS_NETWORK=bitcoin
ELECTRS_DAEMON_RPC_ADDR=192.168.1.219:8332
ELECTRS_DAEMON_P2P_ADDR=192.168.1.219:8333
ELECTRS_ELECTRUM_RPC_ADDR=192.168.1.223:50001
ELECTRS_DB_DIR=/home/electrs/db
ELECTRS_TIMESTAMP_CACHE_CAPACITY=1000000
ELECTRS_INDEX_LOOKUP_LIMIT=10000
ELECTRS_THREADS=4
ELECTRS_DB_CACHE_SIZE=4096
Volumes: bitcoin data (read-only) and electrs DB (persistent)
Docker container has 4 threads and 4GB cache configured

Electrs and bitcoind are on the same local network.
Problem:
Despite this setup, querying a single, random address balance via Electrs takes about 900ms. This seems slow compared to other Electrum servers and my expectations for local, SSD-backed infrastructure.

Hardware Specs:

  • CPU: AMD Ryzen 5 5600 3.5 GHz 6-Core Processor
  • RAM: 16 GB (2 x 8GB) DDR4-3200
  • Storage: Western Digital Blue SN580 2TB NVMe M.2 SSD (PCIe 4.0 x4)
  • Motherboard: Gigabyte A520M K V2 Micro ATX AM4
  • Network: 1GPS Download speed

Questions:

  • Is this latency typical for Electrs on a Dockerized full node?
  • Are there further optimizations I can make in my Docker or Electrs
    configuration to reduce balance query times?
  • Is there any known bottleneck, either in RocksDB, disk I/O, or Docker networking, that
    might cause this?
  • What are the typical response times others see for
    similar setups?

Any insights or tuning suggestions from the community
would be greatly appreciated!

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions