Optimize writes to InfluxDB
The following tools write to InfluxDB and employ most write optimizations by default:
Write data in batches to minimize network overhead when writing data to InfluxDB.
The optimal batch size is 5000 lines of line protocol.
Sort tags by key
Before writing data points to InfluxDB, sort tags by key in lexicographic order. Verify sort results match results from the .
Specify timestamp precision when writing to InfluxDB.
Use gzip compression
Use gzip compression to speed up writes to InfluxDB and reduce network bandwidth. Benchmarks have shown up to a 5x speed improvement when data is compressed.
In the output plugin configuration in your telegraf.conf
, set the content_encoding
option to gzip
:
When using the InfluxDB API /write
endpoint to write data, compress the data with gzip
and set the Content-Encoding
header to .
Use the Network Time Protocol (NTP) to synchronize time between hosts. If a timestamp isn’t included in line protocol, InfluxDB uses its host’s local time (in UTC) to assign timestamps to each point. If a host’s clocks isn’t synchronized with NTP, timestamps may be inaccurate.
Write multiple data points in one request
To write multiple lines in one request, each line of line protocol must be delimited by a new line (\n
).
Use the influx write --rate-limit
flag to control the rate of writes. Use one of the following string formats to specify the rate limit:
COUNT(B|kB|MB)
, or
By default, the free tier rate limit in InfluxDB Cloud is .