Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dbnode] Add process limits validation (and docs) #1118

Merged
merged 7 commits into from
Nov 16, 2018

Conversation

prateek
Copy link
Collaborator

@prateek prateek commented Oct 19, 2018

No description provided.

@codecov
Copy link

codecov bot commented Oct 20, 2018

Codecov Report

Merging #1118 into master will increase coverage by <.1%.
The diff coverage is 75.6%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1118     +/-   ##
========================================
+ Coverage    71.1%   71.1%   +<.1%     
========================================
  Files         734     737      +3     
  Lines       61781   61855     +74     
========================================
+ Hits        43928   43997     +69     
+ Misses      15010   15006      -4     
- Partials     2843    2852      +9
Flag Coverage Δ
#aggregator 81.6% <ø> (-0.1%) ⬇️
#cluster 85.7% <ø> (ø) ⬆️
#collector 78.1% <ø> (ø) ⬆️
#dbnode 80.8% <85.3%> (ø) ⬆️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 75.2% <ø> (-0.1%) ⬇️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 18.3% <ø> (ø) ⬆️
#msg 74.9% <ø> (ø) ⬆️
#query 61.7% <ø> (ø) ⬆️
#x 74.4% <63.6%> (-0.8%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53c7f2b...84f708d. Read the comment docs.

return nil
}

return fmt.Errorf(`invalid configuration found [%v]. refer to https://m3db.github.io/m3/operational_guide/kernel_tuning/ for more information`, multiErr.FinalError())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, should we perhaps add like a meta doc package so that we can replace all the links at a later time?

e.g.

docs.Path("operational_guide/kernel_tuning")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also a log field for the doc link?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return 0, err
}

return int64(num), 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t this be ‘int64(num), nil’?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Alternatively, if you wish to have `m3dbnode` run under `systemd` you can use our [service example](https://github.com/m3db/m3/tree/master/integrations/systemd/m3dbnode.service) which will set sane defaults.

Before running the process make sure the limits are set, if running manually you can raise the limit for the current user with `ulimit -n 500000`.
[Recommended kernel configuration](../operational_guide/kernel_tuning.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a complete sentence that explains why its important that people follow this link. I.E something like: Make sure to review our recommended kernel configuration before running M3DB in production as M3DB may exceed the default limits for some default kernel values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also its called Kernel Configuration here and Kernel Tuning below. Lets pick one (configuration seems more consistent to me)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Kernel Tuning
=============

This document lists the Kernel tweaks `m3dbnode` needs to run well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that what we actually call the binary? I always refer to it as m3db or M3DB when I'm writing documentation. We should probably be consistent about that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'm onboard with being consistent. I'll change to M3DB for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

## vm.swappiness
`vm.swappiness` controls how much the virtual memory subsystem will try to swap to disk. By default, the kernel configures this value to `60`, and will try to swap out items in memory even when there is plenty of RAM available to the system.

For performance, we recommend sizing clusters such that `m3dbnode` is running on a substrate such that no-swapping is necessary. And therefore recommend setting the value of `vm.swappiness` to `1`. This tells the kernel to swap as little as possible, without altogether disabling swapping.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe leave out For performance here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"We recommend provisioning m3db clusters such that they use significantly less memory than the maximum on each host. As a result, we recommend setting the value of vm.swappiness to 1 to prevent the O.S from prematurely swapping pages to disk unless it is absolutely necessary."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, tweaked to be a little clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done



## rlimits
`m3dbnode` also can use a high number of files and we suggest setting a high max open number of files due to per partition fileset volumes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanations of why seem a little out of place. I understand the desire to include them but it really breaks the flow. If you want to keep them in could we add like a ### Rationale subheading to each of these? That way you can just scan through and it just lists variables and what our recommended value is and if you care you can read the rationale

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the vm.max_map_count section does the same thing - explain why we need to tweak a value and then what the value should be tweaked to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

maxSwappiness = 1
)

func validateProcessLimits() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were gonna emit these log messages at regular intervals as well if they were misconfigured? Seems like a long-lived struct with an internal goroutine that might be useful

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

func sysctl(key string) (string, error) {
path := sysctlDir + strings.Replace(name, ".", "/", -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume "name" is a typo here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

@richardartoul richardartoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than minor comments

sysctl -w vm.max_map_count=262144
```

To set this value permanently, update the `vm.max_map_count` setting in `/etc/sysctl.conf`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your_m3db_user soft nofile 500000
```

Alternatively, if you wish to have M3DB run under `systemd` you can use our [service example](https://github.com/m3db/m3/tree/master/integrations/systemd/m3dbnode.service) which will set sane defaults.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I see it is here. Can any of the other values go in there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naw the rest of it is specific to systemd

)

// Path returns the url to the
func Path(section string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol nice

@@ -630,6 +633,21 @@ func interrupt() <-chan os.Signal {
return c
}

func bgValidateProcessLimits(logger xlog.Logger) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is annoying, but should we add a signal to stop this goroutine at some point?

Just because if we start using this more in integration tests having a dangling goroutine may become annoying to deal with.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

talked offline: added max monitor duration to control this

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than minor comment

@robskillington robskillington force-pushed the prateek/dbnode/process-limits branch from 996be0e to 8b9be43 Compare November 16, 2018 18:53
@robskillington
Copy link
Collaborator

I rebased on master for you, hopefully CI passes.

@prateek prateek merged commit b11e2bf into master Nov 16, 2018
@prateek prateek deleted the prateek/dbnode/process-limits branch November 16, 2018 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants