3

Recently, I was looking at Solana's RPC code and I was surprised to see that the JSON RPC server seems to be single threaded? https://github.com/solana-labs/solana/blob/0d92254736936fc9ffa68ebe4867233625a1b415/rpc/src/rpc_service.rs#L529

Is this correct? And if so, why is this the case? I know RPCs are typically run on fairly powerful machines, but I still think that multiple threads would result in a faster RPC.

Perhaps there are other more important bottlenecks I am not considering like reading accounts from the Validator? Or maybe this was done so that RPC requests don't degrade Validator performance too much?

1 Answer 1

3

It's a bit confusing because it does look like 1 thread, but right before it's setting event_loop_executor and passing in a multi-threaded tokio runtime. This means that it's one thread running a multi-threaded executor.

The threads() function in the jsonrpc_http_service crate gives more info at https://docs.rs/jsonrpc-http-server/latest/jsonrpc_http_server/struct.ServerBuilder.html#method.threads:

Sets number of threads of the server to run.

Panics when set to 0. The first thread will use provided Executor instance and all other threads will use UninitializedExecutor to spawn a new runtime for futures. So it’s also possible to run a multi-threaded server by passing the default tokio::runtime executor to this builder and setting threads to 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.