All Products
Search
Document Center

Time Series Database:Write data

Last Updated:Aug 28, 2020

This topic describes how to optimize write policies to increase the write efficiency of TSDB.

  • Perform high concurrent write operations and write data in batches. We recommend that you write more than 400 data points for each batch in more than 256 concurrent tasks.

  • If you use an SDK to submit data points, comply with the following rules to optimize write performance:

    • Use the SDK to create and destroy an instance

      • You can use the TSDB SDK to create only one global instance in a process.
      • To write and query data, you can call the putXXX() and queryXXX() methods, respectively. You do not need to call the close() method to query or write data.
      • In most cases, you can call the close() method to disable the TSDB connection if you want to destroy an instance.
    • Submit data points in batches

      • You can reduce the network overheads and improve the overall throughput by submitting data points in batches instead of submitting a single data point each time.
      • By default, the SDK asynchronously submits 500 data points in each batch.
    • Set the number of threads

      • By default, the SDK uses one consumer thread for asynchronously submitting data points.
      • If the number of write transactions per second (TPS) is large, you can increase the number of consumer threads based on your business needs.
    • Asynchronous and synchronous write optimization

      • You can call the put() method to perform asynchronous write operations. The processing logic of the SDK is described as follows:
        • Data points are put into SDK queues.
        • Consumer threads obtain data points from the SDK queues, and send the data points to TSDB servers. The number of data points that the consumer threads obtain is smaller than or equal to the number of data points in each batch.
      • You can call the putSync() method to perform synchronous write operations. The processing logic of the SDK is described as follows:
        • The SDK sends the data points that are specified in the putSync() method to TSDB servers.
        • The performance of the putSync() method depends on the number of data points that are submitted each time.
        • You can call an SDK client application to use a queue to call the putSync() method.