Sensys database multiple threads

To enhance the performance of logging data to database, Sensys allows users to specify the number of threads used to log the environmental and event data in parallel.

An MCA parameter, db_base_thread_counts, is provided to specify the number of threads for environmental and event data types when running the orcmd aggregator daemon. The MCA parameter is a comma separated list of integers and the order is fixed: the first integer represents the number of threads used to log the environmental data and the second integer represents the number of threads used to log the event data. By default, use one thread per data type to log data.

Examples:

 orcmd --omca db_base_thread_counts 4,2

means using 4 threads to log the environmental data and 2 threads to log the event data.

orcmd --omca db_base_thread_counts 4

means using 4 threads to log the environmental data and 1 thread to log the event data.

We limit the maximum number of threads per data type to 10 to avoid using too many database connections and computing cores of the aggregator node. The valid integer range is [1, 10]. Any invalid number (e.g. 0, -1, 1.5, 11, 13abc, 12328329832) will be rejected and the daemon will exit with a proper message.

If the total number of threads, i. e. the number of aggregators multiplied by the number of threads used per aggregator, is greater than the configured max_connections value (100 by default) of the postgres.conf file, a performance bottleneck may arise. The max_connections value needs to be edited accordignly.