1[[http-handler-config]] 2=== Configure the HTTP Handler 3 4Elasticsearch-PHP uses an interchangeable HTTP transport layer called 5https://github.com/guzzle/RingPHP/[RingPHP]. This allows the client to construct 6a generic HTTP request, then pass it to the transport layer to execute. The 7actual execution details are hidden from the client and modular, so that you can 8choose from several HTTP handlers depending on your needs. 9 10The default handler that the client uses is a combination handler. When 11executing in synchronous mode, the handler uses `CurlHandler`, which executes 12single curl calls. These are very fast for single requests. When asynchronous 13(future) mode is enabled, the handler switches to `CurlMultiHandler`, which uses 14the curl_multi interface. This involves a bit more overhead, but allows batches 15of HTTP requests to be processed in parallel. 16 17You can configure the HTTP handler with one of several helper functions, or 18provide your own custom handler: 19 20[source,php] 21---- 22$defaultHandler = ClientBuilder::defaultHandler(); 23$singleHandler = ClientBuilder::singleHandler(); 24$multiHandler = ClientBuilder::multiHandler(); 25$customHandler = new MyCustomHandler(); 26 27$client = ClientBuilder::create() 28 ->setHandler($defaultHandler) 29 ->build(); 30---- 31 32For details on creating your own custom Ring handler, please see the 33http://guzzle.readthedocs.org/en/latest/handlers.html[RingPHP Documentation]. 34 35The default handler is recommended in almost all cases. This allows fast 36synchronous execution, while retaining flexibility to invoke parallel batches 37with async future mode. You may consider using just the `singleHandler` if you 38know you will never need async capabilities, since it will save a small amount 39of overhead by reducing indirection.