Benchmarking ElasticSearch vendors for PHP

Benchmarking ElasticSearch vendors for PHP

Introduction

Vladimir Kovpak
Jul 24, 2017 · 2 min read

This article focuses on benchmarking open-source tools which help receive data from ElasticSearch into PHP.
We will check composer packages:

  • ruflin/elastica
  • elasticsearch/elasticsearch
  • plain PHP implementation with curl.

Prerequisites

The infrastructure which we will use during this tutorial is pretty simple and based on using official Docker images:

  • ElasticSearch — elasticsearch:5.3.0
  • PHP-Cli — php:7.1-cli
  • Composer — composer:php7

In this test, we have simple type inside ElasticSearch index which contains 1K records. Also, we will use all default setting for PHP and ElasticSearch.

Prepare infrastructure

With purpose perform this benchmark you need have installed Docker and curl on your machine. Run in terminal next commands:

Create folder for benchmark:

Download code:

All code related to benchmarking available in file index.php you can check it out, or look it on github gist page.

Install composer packages:

Run ElasticSearch:

IMPORTANT: please wait few seconds till request curl localhost:9200 return valid response.

Import data into ElasticSearch:

As result you must receive message like this:

Run benchmark

This command will perform benchmarking and will print result into console output.

Result

For me on ubuntu 16.04 with PHP 7.1.3 and ES 5.3.0 result was:

Conclusion

You can take into account this information with purpose to receive data from ElasticSearch into PHP as fast as possible. In this case, plain PHP with curl is the best option!

PS

All code available here: index.php, composer.json, import.sh.

You can find my success story of implementing fastest elasticsearch vendor on real project here.

Vladimir Kovpak

Written by

@cn007b https://www.linkedin.com/in/cn007b

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade