Add configuration option influxdb.batch_size

The new configuration option is used to control the maximum size of
batches written to InfluxDB and optimizes performance for high loads.
The default value is set to 10 000 data points per batch.

Change-Id: I82c3e4e64984a996e41fe2657ce36b032b40d3fd
Story: 2007191
Task: 38319
This commit is contained in:
Witek Bedyk 2020-01-21 10:18:22 +01:00
parent 3ed12b9d2c
commit 0696cf54ee
3 changed files with 12 additions and 1 deletions

View File

@ -27,6 +27,9 @@ influxdb_opts = [
help='Default retention period in hours for new '
'databases automatically created by the persister',
default=0),
cfg.IntOpt('batch_size',
help='Maximum size of the batch to write to the database.',
default=10000),
cfg.HostAddressOpt('ip_address',
help='Valid IP address or hostname '
'to InfluxDB instance'),

View File

@ -52,9 +52,11 @@ class AbstractInfluxdbRepository(abstract_repository.AbstractRepository):
# NOTE (brtknr): Loop twice to ensure database is created if missing.
for retry in range(2):
try:
batch_size = self.conf.influxdb.batch_size
self._influxdb_client.write_points(data_points, 'ms',
protocol='line',
database=database)
database=database,
batch_size=batch_size)
break
except influxdb.exceptions.InfluxDBClientError as ex:
# When a databse is not found, the returned exception resolves

View File

@ -0,0 +1,6 @@
---
features:
- |
Configuration option `batch_size` for InfluxDB to control the maximum
size of batches written to the database. Default value set to 10 000 data
points.