{"id":840,"date":"2020-07-02T01:36:32","date_gmt":"2020-07-01T17:36:32","guid":{"rendered":"https:\/\/www.zhuyanbin.com\/?p=840"},"modified":"2020-07-02T01:36:32","modified_gmt":"2020-07-01T17:36:32","slug":"nginx-bind-worker-processes-to-the-sets-of-cpus","status":"publish","type":"post","link":"https:\/\/www.yanbin888.com\/?p=840","title":{"rendered":"Nginx bind worker processes to the sets of CPUs"},"content":{"rendered":"\n<ul class=\"wp-block-list\"><li><strong>worker_cpu_affinity<\/strong>  <\/li><\/ul>\n\n\n\n<p>Binds worker processes to the sets of CPUs. Each CPU set is represented by a bitmask of allowed CPUs. There should be a separate set defined for each of the worker processes. By default, worker processes are not bound to any specific CPUs.<\/p>\n\n\n\n<p>For example,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">worker_processes    4;\nworker_cpu_affinity 0001 0010 0100 1000;\n<\/pre>\n\n\n\n<p>binds each worker process to a separate CPU, while<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">worker_processes    2;\nworker_cpu_affinity 0101 1010;\n<\/pre>\n\n\n\n<p>binds the first worker process to CPU0\/CPU2, and the second worker process to CPU1\/CPU3. The second example is suitable for hyper-threading.<\/p>\n\n\n\n<p>The special value&nbsp;<code>auto<\/code>&nbsp;(1.9.10) allows binding worker processes automatically to available CPUs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">worker_processes auto;\nworker_cpu_affinity auto;\n<\/pre>\n\n\n\n<p>The optional mask parameter can be used to limit the CPUs available for automatic binding:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">worker_cpu_affinity auto 01010101;\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The directive is only available on FreeBSD and Linux.<\/p><\/blockquote>\n\n\n\n<p>link: http:\/\/nginx.org\/en\/docs\/ngx_core_module.html#worker_cpu_affinity<\/p>\n","protected":false},"excerpt":{"rendered":"<p>worker_cpu_affinity Binds worker processes to the sets  <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.yanbin888.com\/?p=840\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-840","post","type-post","status-publish","format-standard","hentry","category-nginx"],"_links":{"self":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=840"}],"version-history":[{"count":1,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/840\/revisions"}],"predecessor-version":[{"id":841,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=\/wp\/v2\/posts\/840\/revisions\/841"}],"wp:attachment":[{"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yanbin888.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}