How Do I Improve Write Efficiency of GeminiDB Influx Instances?
This section uses influxdb-java as an example to describe how to set the write policy to improve write efficiency of GeminiDB Influx instances.
Core strategy: Write data concurrently in batches. More than 256 concurrent connections in more than 400 batches are recommended.
1. SDK Lifecycle Management
- Create: In one process, you only need to create a single global instance using the InfluxDB client.
- Use: Call the write or query method without close() after each operation.
- Destroy: Call close() only once when the process is shut down to release resources.
2. Submitting Data Points In Batches
- Advantage: Compared with submission of a single data point, batch submission can significantly minimize network overhead and greatly improve the overall throughput.
- Default SDK configuration: The default batch size of influxdb-java in asynchronous submission mode is 1,000 data points/batch.
3. Optimizing Asynchronous Writes
- Enable asynchronous writes: Enable enableBatch and call the write method.
- After enableBatch is enabled, one client can asynchronously write data to GeminiDB using only one thread. If the write load is too heavy for a single client, you can initialize multiple clients to write data.
InfluxDB influxDB = InfluxDBFactory.connect(serverURL, "username", "password", client); BatchOptions batchOptions = BatchOptions.DEFAULTS. //Number of points submitted in each batch .actions(1000) //Length of the write error buffer queue .bufferLimit(20000) //Asynchronous submission interval .flushDuration(100) //Handles a write exception. .exceptionHandler((points, throwable) -> {}); influxDB.enableBatch(batchOptions); influxDB.write(point)
4. Optimizing Synchronous Writes
- Enable synchronous writes: Enable disableBatch and call the write method.
- The performance depends on the number of data points submitted each time. You are advised to submit data points in batches each time.
- To improve the throughput, you can maintain a queue outside the SDK. An external program can control the queue to obtain data in batches and call write() to submit the request.
InfluxDB influxDB = InfluxDBFactory.connect(serverURL, "username", "password", client); influxDB.disableBatch(); influxDB.write(point)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot