influxdata/influxdb-client-php

$write_api->write is really slow

paolss opened this issue · 2 comments

Hi is there a way for batching writes ?

Currently i have like 5mins aggregated meteics with 180520 lines - json file.
Im parsing it with php file_file_get_contents and then triying to $write_api in foreach loop...

But without write and just echo values it takes ->
real 0m0.658s
user 0m0.413s
sys 0m0.245s

With write_api it takes forever :) like 15 to 30 minutes

Basically all looks like this
$array = explode("\n", file_get_contents($file));
foreach ( $array as $line)
{
$obj = json_decode($line);
echo $obj->vlan."\n";
//$write_api->write("traffic,vlan=$obj->vlan,src_as=$obj->as_src,dst_as=$obj->as_dst,peer_ip_src=$obj->peer_ip_src,iface_in=$obj->iface_in,iface_out=$obj->iface_out bytes=$obj->bytes");
}

Hi @paolss,

Thanks for using our client.

I have been update a document about how to use a batching write and also added an example.

  1. Docs: https://github.com/influxdata/influxdb-client-php#batching
  2. Example: https://github.com/influxdata/influxdb-client-php/blob/master/examples/WriteBatchingExample.php

Regards