tobiasschuerg / InfluxDB-Client-for-Arduino

Simple library for sending measurements to an InfluxDB with a single network request. Supports ESP8266 and ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

double time to publish

homonto opened this issue · comments

so I have a code:

Point sensorReadings("measurements");
Point box_status("box_status");   

and I post 2 types of data:
sensorReadings.addField("temperature", myData.md_temp);
and
box_status.addField("version", md_version_value);

then I post to influxdb:

if ((client_influxdb.writePoint(sensorReadings)) and (client_influxdb.writePoint(box_status)))
{
}

but then I realised, it takes DOUBLE TIME to write to influxdb (if I use one only, it is around 0.8s, if I use both, 1.6s)
how can I write both writePoints at the same time to save the time?

thx

nobody? ;-(

@homonto, this is exactly the case when batching should be used.
Set the batch size:

client.setWriteOptions(WriteOptions().batchSize(2));

Then simply write data:

client.writePoint(point);

Data will be sent when the batch is full or when client.flushBuffer() is explicitly called.

Read more about this in Writin in batches

There is also an example of this: SecureBatchWrite.

tested - working like a charm!!!!!
THANK YOU
(I was afraid, when it writes the batch, it will keep ... 1 time only - stupid me (of course) all is OK)