<p>This is expected. Most of the RPC handling is single-threaded due to access to internal data structures that aren't designed for multi-threaded access.</p>

CC BY-SA 4.0
2020-12-07T20:12:54.687Z
2020-12-07T20:12:54.687Z
Pieter Wuille
<p>I would assume the issue is not Bitcoin Core, even with default RPC settings I do see noticeable increase in client performance when using async/await (C# library). My suggestion is to investigate how the client code handles the RPC request/response + block parsing.</p>

CC BY-SA 4.0
2020-03-12T11:44:35.600Z
2020-03-12T11:44:35.600Z
TGollowitsch
<p>I am trying to call getBlock for 100k blocks, but it is too slow to call them sequentially. This is what I am trying. I have a full node of bitcoin core running. I set the -rpcthreads=100 and -rpcworkqueue=100, and I use js to make Promise.all([multiple rpc calls]). To my understanding, rpcthreads allows concurrent calls, but maybe I misunderstood it. I expected the time it takes to run 2 getblock to be similar of running 1. However, I am not seeing a huge performance increase (running 2 roughly takes double the time). What is the correct way to make bitcoin core accept concurrent rpc requests? Thanks!</p>

<p>my bitcoin core config: <code>-server -rpcuser=un -rpcpassword=pw -txindex=1 -rpcthreads=100 -rpcworkqueue=100</code></p>

<p>my attempt to make it concurrent (client being a wrapper class around the rpc api.):</p>

<pre><code>const before = Date.now();
await Promise.all([
  client.getBlock('0000000000000000000119e179a3169afe7e1dbd867cb9070a6f75a583b98fb3'),
  client.getBlock('0000000000000000000119e179a3169afe7e1dbd867cb9070a6f75a583b98fb3')
]);
const afterAll = Date.now();

console.log('time for all');
console.log(afterAll - before); 
</code></pre>

<bitcoin-core><bitcoind>
How to make concurrent calls to bitcoin core rpc?
Isaac Chen
# How to make concurrent calls to bitcoin core rpc?

(Asked by: username_0 on 2020-03-10)

I am trying to call getBlock for 100k blocks, but it is too slow to call them sequentially. This is what I am trying. I have a full node of bitcoin core running. I set the -rpcthreads=100 and -rpcworkqueue=100, and I use js to make Promise.all([multiple rpc calls]). To my understanding, rpcthreads allows concurrent calls, but maybe I misunderstood it. I expected the time it takes to run 2 getblock to be similar of running 1. However, I am not seeing a huge performance increase (running 2 roughly takes double the time). What is the correct way to make bitcoin core accept concurrent rpc requests? Thanks!

my bitcoin core config: `-server -rpcuser=un -rpcpassword=pw -txindex=1 -rpcthreads=100 -rpcworkqueue=100`

my attempt to make it concurrent (client being a wrapper class around the rpc api.):

```
const before = Date.now();
await Promise.all([
  client.getBlock('0000000000000000000119e179a3169afe7e1dbd867cb9070a6f75a583b98fb3'),
  client.getBlock('0000000000000000000119e179a3169afe7e1dbd867cb9070a6f75a583b98fb3')
]);
const afterAll = Date.now();

console.log('time for all');
console.log(afterAll - before); 

```

**Tags:** bitcoin-core, bitcoind


---

## 2 answers

### Answer by username_1 on 2020-12-07. Score: 1 | Accepted answer

This is expected. Most of the RPC handling is single-threaded due to access to internal data structures that aren't designed for multi-threaded access.


---

### Answer by username_2 on 2020-03-12. Score: 0

I would assume the issue is not Bitcoin Core, even with default RPC settings I do see noticeable increase in client performance when using async/await (C# library). My suggestion is to investigate how the client code handles the RPC request/response + block parsing.


---

