Influx DB and PHP implementation

06 Jan 2015 · One minute read · on Gianluca's blog

News! Tech related notes are NOW published to ShippingBytes. See you there! I always felt this was not the right place for me to write consistently about tech and tools. So if you want to read more about that see you at the other side

Influx DB is time series database written in Go.

It supports SQL like queries and it has different entry points, REST API (tcp protocol) and UDP.

We wrote a sdk to manage integration between Influx and PHP.

It supports Guzzle Adapter but if you use Zend\Client you can write your implementation.

<?php
$guzzle = new \GuzzleHttp\Client();

$options = new Options();
$adapter = new GuzzleAdapter($guzzle, $options);

$client = new Client();
$client->setAdapter($adapter);

In this case we are using a Guzzle Client, we communicate with Influx in TPC, but we can speak with it in UDP

<?php
$options = new Options();
$adapter = new UdpAdapter($options);

$client = new Client();
$client->setAdapter($adapter);

Both of them have the same usage

<?php
$client->mark("app.search", $points, "s");

The first different between udp and tcp is known, TPC after request expects a response, UDP does not expect anything and in this case does not exist any delivery guarantee. If you can accept this stuff this is the benchmark:

Corley\Benchmarks\Influx DB\AdapterEvent
    Method Name                Iterations    Average Time      Ops/second
    ------------------------  ------------  --------------    -------------
    sendDataUsingHttpAdapter: [1,000     ] [0.0026700308323] [374.52751]
    sendDataUsingUdpAdapter : [1,000     ] [0.0000436344147] [22,917.69026]
Something weird with this website? Let me know.