I'm using the self-hosted version of InfluxDB 2.7 to write sensor readings into the database. If would like to visualize the sensor readings in real time (via InfluxDB UI or my own web app).
Unfortunately the data does not show up in real-time. The delay between writing a data point and being able to read it (via influx cli or gui) is a at least aminute but sometimes a lot more.
According to my research, this might be related to batch writing, which is a mechanism to improve write performance in InfluxDB. I would like to turn batch writing off (as the number and frequency of data points is only a couple per second, so performance should not be an issue) but the docs just say:
The optimal batch size is 5000 lines of line protocol.
Which is very useless information without knowing how to set that batch size :-|
How can I configure the batch size? Is this something I have to configure in the InfluxDB's config.yml
or something I have to set in the NodeJS api when writing? Do I need to write through Telegraf to get better performance?
With the help of the thing that can't be named, I figured out, that turning off batch writing completely is not possible, neither on client side with the NodeJS api nor on server side via config.yml
, as this is one of the key mechanics of InfluxDB. All config options I have tried did not have noticeable effect in my scenario.
However, it is possible to write in realtime via the REST api endpoint /write
and the line protocol. It worked well for 10 writes per second, which is the maximum I need.
As pasting answers from the thing that can't be named is strictly forbidden, you have to figure this out yourself. Sorry guys. I did not make up the stupid rules, I'm just playing the game.