Skip to content

For help, click the link below to get free database assistance or contact our experts for personalized support.

Check the maxSessions value

Description

This advisor warms if the maximum number of sessions set in the maxSessions parameter exceeds the default value of 1000000. You can set the maxSessions only on database startup.

This is relevant because setting a too high number of sessions can negatively impact the performance.

The parameter also needs to be set at the configuration file.

To avoid performance issues, see The (In)famous MongoDB Message blogpost to check and set the right value for your environment.

Rule

# to fetch the value
db.adminCommand( { getCmdLineOpts: 1  } )

Resolution

Instead of increasing maxSessions, reduce the setting of the logicalSessionRefreshMillis parameter from the default interval of 5 minutes to 2 minutes, for example. You can tweak the time suitable for your environment by setting and checking the performance of open sessions.

Make sure to remove the idle sessions from cache to make room for the new ones and keep the number of sessions reaching its maximum setting mostly.

See logicalSessionRefreshMillis in the MongoDB documentation.

To avoid performance issues, see The (In)famous MongoDB Message blogpost to check and set the right values for your environment. You can adjust the max number of sessions and the cache refreshment interval for both your mongod and mongos nodes.

Need more support from Percona?

Percona experts bring years of experience in tackling tough database performance issues and design challenges.