Configuring the PHP client thread pool
How can I configure the thread pool in the PHP client, and what are the benefits of various configurations?
- The thread pool is only used for synchronous batch, scan, or query commands. If you aren’t using any such commands, you can set its size to 0.
- 0 is not a special value in this case, it just means that no threads will be reused, which is probably not a good option for performance. Although, the client library will always create a new thread for this if it needs one.
- If you do use one or more of the above mentioned features, we recommend setting the thread pool size to the maximum number of such commands you plan to run concurrently multiplied by the number of nodes in the cluster. Lower values will require more threads to be created and destroyed for each command, which may adversely affect performance. Thus, it is certainly recommended to benchmark performance based on your use-case.
- In order to configure the thread pool size, you can set the value in php.ini. To set the value through code, configure the thread pool size in the config hash e.g.
$config = ["hosts"=>[...], "thread_pool_size"=>16];`
It is also distinct from the cluster connection persistence, which applies to the connection used by the client to get information about the cluster and is configured by passing
false as the second argument to the
Aerospike constructor. If connection persistence is true, the connection won’t be closed until PHP itself exits, even if you call close() on it. Refer to the API documentation for further details.
PHP CLIENT THREAD POOL API
11 June 2019