home shape

ArangoDB PHP Driver: Enhancements for Version 2.7

While preparing the release of ArangoDB 2.7, some improvements were made for the PHP driver for ArangoDB.

The 2.7 version of the PHP driver now supports the AQL query results cache. The cache can be turned on or off globally, or be set to demand mode. The demand mode will allow controlling caching on a per-AQL-query basis.

Additionally, the HTTP transport layer in the PHP driver was improved. Some internal string handling methods were optimized so that the transport part becomes cheaper. All driver operations that communicate with the ArangoDB server will benefit from this.

For a demonstration of the improvements, here is a script that creates 100,000 documents in a local ArangoDB database via the PHP driver. As we’re interested in assessing the HTTP layer improvements, the script intentionally issues 100,000 HTTP requests instead of using the specialized import method provided by the driver.

The script code can be found here.

The baseline for the improvements is the (non-optimized) 2.6 version of the PHP driver. Here are the results for issuing 100,000 requests with the 2.6 driver (script was run twice to see if there are variations in execution time):

plain execution times with 2.6 driver

creating 100000 documents 
creating documents took 55.144556999207 s

creating 100000 documents 
creating documents took 54.476955890656 s

Running it with the 2.7 version of the PHP driver now shows the improvements. Execution time for the same script goes down from 54 seconds to 42 seconds:

plain execution times with 2.7 driver

creating 100000 documents 
creating documents took 42.886090040207 s
    
creating 100000 documents 
creating documents took 42.578990936279 s

The PHP version used here was:

PHP version details

PHP 5.5.12-2ubuntu4.6 (cli) (built: Jul 2 2015 15:27:14) Copyright (c) 1997-2014 The PHP Group 
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies 
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies`

Following are the results from a different machine, this time using PHP 5.6:

execution times with 2.6 driver

creating 100000 documents 
creating documents took 48.394731044769 s

creating 100000 documents 
creating documents took 47.618598937988 s

plain execution times with 2.7 driver

creating 100000 documents 
creating documents took 40.535583972931 s

creating 100000 documents 
creating documents took 40.041265010834 s

The PHP version details for this machine were:

PHP 5.6.4-4ubuntu6.2 (cli) (built: Jul 2 2015 15:29:28) Copyright (c) 1997-2014 The PHP Group 
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies 
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies`

The actual improvements depend on many factors, so your exact mileage may vary. The improvements may not be noticable for applications that issue only a few requests with the driver, but they will be significant when performing lots of requests, as in the above examples.

Jan Steemann

Jan Steemann

After more than 30 years of playing around with 8 bit computers, assembler and scripting languages, Jan decided to move on to work in database engineering. Jan is now a senior C/C++ developer with the ArangoDB core team, being there from version 0.1. He is mostly working on performance optimization, storage engines and the querying functionality. He also wrote most of AQL (ArangoDB’s query language).

Leave a Comment





Get the latest tutorials, blog posts and news: