Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-20834

Get the correct CPU count when running in a cgroup (Docker or similar)

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 4.6.0
    • 4.5.1
    • couchbase-bucket, memcached
    • None
    • Release Note

    Description

      When running under Docker, even if the set of available CPUs a container can be scheduled on (see --cpuset-cpus, https://docs.docker.com/engine/reference/run/#/runtime-constraints-on-resources) KV-engine does not respect the setting.

      This is because the API we use to detect CPUs - sysconf(SC_NPROCESSORS_ONLN) - _always reports the total CPU count on the host machine. An alternative API - sched_getaffinity exists which can be used to interrogate how many CPUs the process is capable of running on. We can essentially treat that as the number of CPU cores available to us (as it would not be possible to run concurrently on more CPUs than the size of that set).

      This will improve our out-of-the-box Docker behaviour.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              drigby Dave Rigby (Inactive)
              drigby Dave Rigby (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty