Configuring the PHP client thread pool

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

Configuring the PHP client thread pool

Detail

How can I configure the thread pool in the PHP client, and what are the benefits of various configurations?

Answer

The PHP client is built on top of the C client. Refer to the C-Client documentation and specifically the thread_pool_size configuration for details.

To summarize:

  • 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];`

Notes

The thread pool should not be confused with connection pools (conn_pools_per_node) and the related maximum connections per node (max_conns_per_node, async_max_conns_per_node).

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 true or 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.

Keywords

PHP CLIENT THREAD POOL API

Timestamp

11 June 2019