Which connection pool to choose? PHP and connection poolingedit

At first glance, the sniffingConnectionPool implementation seems superior. For many languages, it is. In PHP, the conversation is a bit more nuanced.

Because PHP is a share-nothing architecture, there is no way to maintain a connection pool across script instances. This means that every script is responsible for creating, maintaining, and destroying connections everytime the script is re-run.

Sniffing is a relatively lightweight operation (one API call to /_cluster/state, followed by pings to each node) but it may be a non-negligible overhead for certain PHP applications. The average PHP script will likely load the client, execute a few queries and then close. Imagine this script being called 1000 times per second: the sniffing connection pool will perform the sniffing and pinging process 1000 times per second. The sniffing process will add a large amount of overhead

In reality, if your script only executes a few queries, the sniffing concept is too robust. It tends to be more useful in long-lived processes which potentially "out-live" a static list.

For this reason the default connection pool is currently the staticNoPingConnectionPool. You can, of course, change this default - but we strongly recommend you load test and verify that it does not negatively impact your performance.