Future Mode

edit

The client offers a mode called "future" or "async" mode. This allows batch processing of requests (sent in parallel to the cluster), which can have a dramatic impact on performance and throughput.

PHP is fundamentally single-threaded, however libcurl provides functionality called the "multi interface". This allows languages like PHP to gain concurrency by providing a batch of requests to process. The batch is executed in a parallel fashion by the underlying multithreaded libcurl library, and the batch of responses is then returned to PHP.

In a single-threaded environment, the time to execute n requests is the sum of those n requests' latencies. With the multi interface, the time to execute n requests is the latency of the slowest request (assuming enough handles are available to execute all requests in parallel).

Furthermore, the multi-interface allows requests to different hosts simultaneously, which means the Elasticsearch-PHP client can more effectively utilize your full cluster.