So I have a Bitcoin Core full node running (bitcoind) and I’m using romanz/electrs through Docker to set up an Electrum server for checking address balances and wallet info. But man, I'm hitting some serious lag here. When I try to check the balance for any random address, it always takes about 600-900 ms using the btc-rpc-explorer RPC interface. If I query addresses with a huge number of transactions, it can seriously drag out and take a few seconds instead of just milliseconds.
Here’s my 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:833
The only detailed benchmark/measure about Electrum server (that i remember) is https://www.sparrowwallet.com/docs/server-performance.html. That benchmark also state Fulcrum have best performance (comapred with electrs and ElectrumX), so you may want to consider switch to Fulcrum.
For uncached queries or cold queries, this latency is within the normal range. But for hot queries with your SSD + 4 threads + 4GB DB cache, you could have achieved 60-150 ms. For your case, it could be RocksDB scans (especially with large address histories).
You could add this on your env for reducing RocksDB scan depth when querying addresses with long histories, it can speedup your queries.
Can you tell us which version of romanz/electrs you use for that environment variable? I just searched it on google, but there's no search result. Although searching other electrs env on google shows shows some result.
I appreciate you double checked that. My apologies for making the assumption that custom Electrs forks or internal builds might implement history truncation for performance, especially in Lightning-related setups.Where pruning long address history for faster queries.
I didnt actually use any specific version of romanz/electrs that supports ELECTRS_TRUNCATE_HISTORY. It was my misunderstanding , Ive corrected my understanding and wont pass that along without verifying in the future.
i got this on electrs logs Any clue how to get rid of it
"electrs [2025-05-28T21:16:53.327Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_balance called for unsubscribed scripthash"
It's pertaining to that electrum protocol used by btc-rpc-explorer to query an address' balance, "blockchain.scripthash.get_balance",
As the warning shows; your btc-rpc-explorer is not set or can't be set to call "blockchain.scripthash.subscribe" for it to be efficient.
Unfortunately, I can't find any reference of that electrum protocol method in their code or specifically in .../electrumAddressApi.js (I may have missed it though)
Since you already re-posted this to their GitHub repo as a new issue, you may as well mention this error there since it's better to ask the main developers themselves.