15.2. Tuning Database Performance

15.2. Tuning Database Performance

This section is divided into the following parts which describe methods for tuning database performance:

15.2.1. Optimizing Search Performance

Improve server performance on searches by tuning database settings. The database attributes that affect performance mainly define the amount of memory available to the server. There are two kinds of database caches, one for the default database cache and the other for the entry cache. The server has one default database cache per server, and one entry cache per database.

To improve the cache hit ratio on search operations, increase the amount of data that the Directory Server maintains in the database cache. Do this by increasing the cache size. The maximum values that can be set for these attributes depends on the amount of real memory on the machine. Roughly, the amount of available memory on the machine should always be greater than sum total of the default database cache size and sum of each entry cache size.

Use caution when changing these two attributes. The ability to improve server performance with these attributes depends on the size of the database, the amount of physical memory available on the machine, and whether directory searches are random (that is, if the directory clients are searching for random and widely scattered directory data).

If the database does not fit into memory and if searches are random, attempting to increase the values set on these attributes does not help directory performance. In fact, changing these attributes may harm overall performance.

The following attributes can be tuned:

  • The attributes of the database that manages all other database instances. The Directory Server Console only shows the databases that contain the directory data and the NetscapeRoot database. However, the server uses another database to manage these. On this database, the following attributes can be changed to improve performance:

    • The amount of memory to make available for all databases (maximum cache size).

    • The maximum number of entries for the server to verify in response to a search request (look-through limit).

    • The amount of memory to make available for import (import cache size).

  • The attributes of each database used to store directory data, including the server configuration data in the NetscapeRoot database. On these databases, to improve performance, configure the amount of memory to make available for cached entries (memory available for cache).

To configure the default database attributes that apply to all other database instances:

  1. In the Directory Server Console, select the Configuration tab; then, in the navigation tree, expand the Data Icon, and highlight the Database Settings node.

This displays the Database tabs in the right pane.

  1. Select the LDBM Plug-in Settings tab in the right pane.

    This tab contains the database attributes for all databases stored on this server.

  2. In the Maximum Cache Size field, enter a value corresponding to the amount of memory to make available for all databases.

  3. In the Look-Through Limit field, enter the maximum number of entries for the server to check in response to a search request.

  4. In the Import Cache Size field, enter a value corresponding to the amount of memory in bytes to make available for import. By default, the value is auto, and 50% of the free memory is allocated for the import cache. For creating a very large database from LDIF, set this attribute as large as possible, depending on the memory available on the machine. The larger this parameter, the faster the database is created.

    To keep from setting a limit, type -1 in this text box. If a user binds to the directory as the Directory Manager, by default the look-through limit is unlimited and overrides any settings specified here.

    To configure the attributes of each database that stores the directory data:

  5. In the Directory Server Console, select the Configuration tab; then, in the navigation tree, expand the Data Icon. Expand the suffix of the database to tune, and highlight the database.

The tabs displayed in the right pane control parameter settings for this database.

  1. Select the Database Settings tab in the right pane.

  2. Enter the amount of memory to make available for cached entries in the Memory Available for Cache field.

15.2.2. Tuning Transaction Logging

Every Directory Server contains a transaction log which writes operations for all the databases it manages. Whenever a directory database operation such as a modify is performed, the server logs the operation to the transaction log. For best performance, the directory does not perform the operation immediately. Instead, the operation is stored in a temporary memory cache on the Directory Server until the operation is completed.

If the server experiences a failure, such as a power outage, and shuts down abnormally, the information about recent directory changes that were stored in the cache is lost. However, when the server restarts, the directory automatically detects the error condition and uses the database transaction log to recover the database.

Although database transaction logging and database recovery are automatic processes that require no intervention, it can be advisable to tune some of the database transaction logging attributes to optimize performance.

Caution

The transaction logging attributes are provided only for system modifications and diagnostics. These settings should be changed only with the guidance of Red Hat Professional Services or Red Hat Technical Support.Setting these attributes and other configuration attributes inconsistently may cause the directory to be unstable.

15.2.3. Changing the Location of the Database Transaction Log

By default, the database transaction log file is stored in the /var/lib/dirsrv/slapd-instance_name/db directory along with the database files themselves. Because the purpose of the transaction log is to aid in the recovery of a directory database that was shut down abnormally, it is a good idea to store the database transaction log on a different disk from the one containing the directory database. Storing the database transaction log on a separate physical disk may also improve directory performance.

To change the location of the database transaction logfile, use the following procedure:

  1. Stop the Directory Server[17].

    service dirsrv stop instance_name
    
  2. Use the ldapmodify[18] command-line utility to add the nsslapd-db-logdirectory attribute to the cn=config,cn=ldbm database,cn=plugins,cn=config entry. Provide the full path to the log directory in the attribute.

    For information on the nsslapd-db-logdirectory attribute syntax, see the Directory Server Configuration, Command, and File Reference. For instructions on using ldapmodify, see Section 2.2.4, “Adding and Modifying Entries Using ldapmodify”.

  3. Restart Directory Server.

    service dirsrv start instance_name
    

15.2.4. Changing the Database Checkpoint Interval

At regular intervals, the Directory Server writes operations logged in the transaction log to the disk and logs a checkpoint entry in the database transaction log. By indicating which changes have already been written to the directory, checkpoint entries indicate where to begin recovery from the transaction log, thus speeding up the recovery process.

By default, the Directory Server is set up to send a checkpoint entry to the database transaction log every 60 seconds. Increasing the checkpoint interval may increase the performance of directory write operations. However, increasing the checkpoint interval may also increase the amount of time required to recover directory databases after a disorderly shutdown and require more disk space due to large database transaction log files. Therefore, only modify this attribute if you are familiar with database optimization and can fully assess the effect of the change.

To modify the checkpoint interval while the server is running, use the ldapmodify[18] command-line utility to add the nsslapd-db-checkpoint-interval attribute to the cn=config,cn=ldbm database,cn=plugins,cn=config entry.

For more information on the syntax of the nsslapd-db-checkpoint-interval attribute, refer to the Directory Server Configuration, Command, and File Reference. For instructions on using ldapmodify, see Section 2.2.4, “Adding and Modifying Entries Using ldapmodify”.

15.2.5. Disabling Durable Transactions

Durable transaction logging means that the temporary database transaction log is, in fact, physically written to disk.

When durable transaction logging is disabled, every directory database operation is written to the database transaction log file but may not be physically written to disk immediately. If a directory change was written to the logical database transaction log file but not physically written to disk at the time of a system crash, the change cannot be recovered. When durable transactions are disabled, the recovered database is consistent but does not reflect the results of any LDAP write operations that completed just before the system crash.

By default, durable database transaction logging is enabled. To disable durable transaction logging, use the following procedure:

  1. Stop the Directory Server[17].

  2. Use the ldapmodify[18] command-line utility to add the nsslapd-db-durable-transactions attribute to the cn=config,cn=ldbm database,cn=plugins,cn=config entry, and set the value of this attribute to off.

    For information on the syntax of the nsslapd-db-durable-transactions attribute, see the Directory Server Configuration, Command, and File Reference. For instructions on using ldapmodify, see Section 2.2.4, “Adding and Modifying Entries Using ldapmodify”.

  3. Restart the Directory Server.

15.2.6. Specifying Transaction Batching

To improve update performance when full transaction durability is not required, use the nsslapd-db-transaction-batch-val attribute to specify how many transactions will be batched before being committed to the transaction log. Setting this attribute to a value of greater than 0 causes the server to delay committing transactions until the number of queued transactions is equal to the attribute value. For transaction batching to be valid, the nsslapd-db-durable-transaction attribute must be set to on.

To specify or modify transaction batching while the server is running, use the ldapmodify[18] command-line utility to add the nsslapd-db-transaction-batch-val attribute to the cn=config,cn=ldbm database,cn=plugins,cn=config entry.

For more information on the syntax and values of the nsslapd-db-transaction-batch-val attribute, refer to the Directory Server Configuration, Command, and File Reference. For instructions on using ldapmodify, see Section 2.2.4, “Adding and Modifying Entries Using ldapmodify”.



[17] For information on stopping the server on platforms other than Red Hat Enterprise Linux, see Section 1.3, “Starting and Stopping Servers”.

[18] The LDAP tools referenced in this guide are Mozilla LDAP, installed with Directory Server in the /usr/lib/mozldap directory on Red Hat Enterprise Linux 5 i386; directories for other platforms are listed in Section 1.2, “LDAP Tool Locations”. However, Red Hat Enterprise Linux systems also include LDAP tools from OpenLDAP. It is possible to use the OpenLDAP commands as shown in the examples, but you must use the -x argument to disable SASL and allow simple authentication.


Note: This documentation is provided {and copyrighted} by Red Hat®, Inc. and is released via the Open Publication License. The copyright holder has added the further requirement that Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. The CentOS project redistributes these original works (in their unmodified form) as a reference for CentOS-5 because CentOS-5 is built from publicly available, open source SRPMS. The documentation is unmodified to be compliant with upstream distribution policy. Neither CentOS-5 nor the CentOS Project are in any way affiliated with or sponsored by Red Hat®, Inc.