Setting the WiredTiger cache size only limits the memory used for reading and updating documents and indexes in memory (aka the "active working set").
MongoDB server processes will temporarily allocate additional memory as needed for client connections (up to 1 MB per connection) and other server-side processing such as aggregation queries, in-memory sorts, or JavaScript evaluation.
However we see the memory usage go up well into 10GB when we have a lot of traffic. Is that normal behavior?
Yes, more memory usage when you have a lot of traffic should be expected.
You may be able to optimise some of that memory usage with strategies like reducing or removing in-memory sorts, replacing server-side JavaScript with aggregation functions, limiting driver connection pool sizes, or improving your schema to take advantage of schema design patterns and avoid performance anti-patterns. You could also consider reducing your WiredTiger cache size or values like maxIncomingConnections
.
Is there another variable that needs to be limited?
The upper limit on resource usage should be determined by your Kubernetes pod or container configuration. Suitable limits to set will depend on your workload, deployment resources, and performance goals.