The MongoDB server can be heavily loaded when using the MongoDB providers for both private and shared session states, if a collection is missing a required index.
For example, when the private and shared session state providers are configured as in the following:
<connectionStrings>
...
<add name="private.sessions" connectionString="mongodb://{user-name}:{password}@{host}/sitecore_private_sessions" />
<add name="shared.sessions" connectionString="mongodb://{user-name}:{password}@{host}/sitecore_shared_sessions" />
...
</connectionStrings>
<sessionState mode="Custom" customProvider="mongo" ... >
<providers>
...
<add name="mongo"
type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB"
sessionType="Private"
connectionStringName="private.sessions"
pollingInterval="5"
compression="true" />
...
</providers>
</sessionState>
<sharedSessionState defaultProvider="mongo">
<providers>
...
<add name="mongo"
type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB"
sessionType="Shared"
connectionStringName="shared.sessions"
pollingInterval="5"
compression="true" />
...
</providers>
...
</sharedSessionState>
Sitecore XP creates two instances of the Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider class, but only the first one will initialize the sessions collection in MongoDB with the e_1__id.s_1__id.a_1 index. As a result, querying the private session state database uses the index, and querying the shared session state database uses a full collection scan.
To resolve this issue: