-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Performance
-
Fully Compatible
-
Query 2017-02-13
Add a new sampleRate parameter to the profile command. This parameter can take values on the interval [0, 1], and is set to 1 by default on startup. The behavior of sampleRate is as follows for logging:
- If the logLevel is 0, then we log a slow command that exceeds the slowms with probability given by sampleRate. Commands whose latency is less than slowms, as before, are not logged.
- If the logLevel is 1 or higher, then all commands are logged. The sampleRate has no affect in this case.
For creating system.profile entries, the behavior of sampleRate is as follows:
- If the profiling level is 0, then no profile entries are created and sampleRate takes no affect.
- If the profiling level is 1, then an operation exceeding slowms is profiled with probability given by sampleRate.
- If the profiling level is 2, then all operations are profiled with probability given by sampleRate, regardless of latency.
There are three ways to set the profiler sampleRate. The first is by running the profile command. For example, the following command indicates that the server should profile 10% of operations slower than 30ms:
db.runCommand({profile: 2, slowms: 30, sampleRate: 0.1});
This command will return the previous settings of profile, slowms, and sampleRate on success. Like slowms, the sampleRate setting is unchanged when it is omitted from the command. The sampleRate can also be set from the shell using the db.setProfilingLevel() helper:
db.setProfilingLevel(2, {slowms: 30, sampleRate: 0.1});
The second argument to this helper is now either the slowms value, or an options object.
The second way to set sampleRate is the new slowOpSampleRate command line option:
./mongod --profile 2 --slowms 30 --slowOpSampleRate 0.1
Third, it can be set in a configuration file using operationProfiling.slowOpSampleRate.
- fixes
-
SERVER-1740 Add rate limiting to creation of system.profile entries
- Closed
- is duplicated by
-
SERVER-1740 Add rate limiting to creation of system.profile entries
- Closed
- is related to
-
SERVER-4785 slowms should be per database for profiler
- Backlog
- links to