[DPE-6124] optimise max map for VM deployments #522
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Solves issue #518 which reports
2024-11-28T21:05:16.089+00:00: vm.max_map_count is too low
This message comes from the fact that each network connection requires 2 mapped virtual memory areas. So mongodb is pointing out that if the server accepts all of the connections allowed, it will not have enough maps and possibly cause the mongod to crash.
MongoDB defines this value to be 2x the possible of soft ulimit. We could automatically set
vm.max_map
to 2x of soft ulimit. But I believe this is not advisable since each memory-mapped area consumes resources, and having too many can lead to increased memory usage and slower performance. Question - is there a programmatic way to determine at what point the number of memory mapped areas is detrimental? If so we could always consider decreasing the ulimt.With that said I believe setting it to
262144
is a good spot to start and we could come back to these questions later in the futureSolution
We adopted an approach similar to Kafka here which is to set vm_max when possible. If it is not possible we log a warning and do not attempt to set it again
Testing
tested by hand in OpenStack deployment to verify that the following warning does not appear when connecting to Mongodb. But it was necessary to restart
mongod
to have the message go away.know issue
is present until
charmed-mongodb.mongod
is restarted (despite the value being set before the installation of thecharmed-mongodb
snap.)