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)