Configuring MariaDB for performance

If you use the tpfrtmc offline utility and a MariaDB instance in high throughput environments, configure your MariaDB instance to ensure that MariaDB can run for long periods of time without being interrupted.

About this task

By default, MariaDB uses the system malloc libraries to allocate and release memory. When the tpfrtmc offline utility is running with high throughput, MariaDB retains memory over long periods of time, even though that memory is already freed. The result is that MariaDB memory usage grows over time and can use all memory on the server and cause various components to fail.

You can configure MariaDB to use a more performance sensitive malloc library to reduce the overall usage of memory over long periods of high throughput. If you use the Sample analytics pipeline, this configuration is already set.

Procedure

  1. Install the libjemalloc1 library on your system by taking one of the following actions:
    • Enter the following command:

      apt-get install libjemalloc1 -y

    • Add the following line to your Docker file:
      RUN apt-get install libjemalloc1 -y

    For more information about the libjemalloc1 library, see jemalloc and libjemalloc1.

  2. Take one of the following actions:
    • Set up the following environment variable for MariaDB on your system:

      LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.1"

    • Add the following line to your Docker compose file in the environment section:
      LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libjemalloc.so.1
  3. Start MariaDB.
  4. Ensure that the malloc library is set up correctly.
    1. If you use Docker, enter the following command:

      docker exec -it tpf-mariadb-container-name /bin/bash

    2. Enter the following commands to see which malloc library is used:

      mysql --host=127.0.0.1 --port=3306 --user=username --password=password

      SHOW VARIABLES LIKE 'version_malloc_library';

    In the result, ensure that the jemalloc library is shown instead of system.