Skip to content

Commit e184960

Browse files
DOCSP-40332 Increase thread count of Operator for large number of MongoDB Deployments (#1740)
* DOCSP-40332 -- WIP * DOCSP-40332 -- WIP * DOCSP-40332 -- update plan-k8s-op-considerations.txt * DOCSP-40332 -- copy review revisions * DOCSP-40332 -- helm template reference * DOCSP-40332 -- add helm reference link * DOCSP-40332 -- copy review revision * DOCSP-40332 -- add Helm example * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- fix build error * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- fix Helm operator field definitions * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- add link to Helm resources example * DOCSP-40332 -- copy edit * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- tech review revisions * DOCSP-40332 -- change headers to h2 * DOCSP-40332 -- copy edit * DOCSP-40332 -- address feedback * DOCSP-40332 -- update FAQ * DOCSP-40332 -- add link to Helm operator settings docstring * DOCSP-40332 -- add link to Helm operator settings * DOCSP-40332 -- add link to Helm operator settings * DOCSP-40332 -- add link to Helm operator settings * DOCSP-40332 -- add link to Helm operator settings * DOCSP-40332 -- Update thread count NOTE * DOCSP-40332 -- add snooty link * DOCSP-40332 -- add snooty link * DOCSP-40332 -- copy review revisions * DOCSP-40332 -- copy review revisions
1 parent ad4bb25 commit e184960

File tree

7 files changed

+153
-38
lines changed

7 files changed

+153
-38
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ kubectl = "`kubectl <https://kubernetes.io/docs/reference/kubectl/kubectl/>`__"
132132
kubectl-install = "`Install kubectl <https://kubernetes.io/docs/tasks/tools/#kubectl>`__"
133133
kustomize = "`Kustomize <https://kustomize.io/>`__"
134134
kustomize-install = "`Install Kustomize <https://kubectl.docs.kubernetes.io/installation/kustomize/>`__"
135+
max-concurrent-reconciles = "`MaxConcurrentReconciles <https://pkg.go.dev/github.com/kubernetes-sigs/controller-runtime/pkg/controller#Options>`__"
135136
minio = "`MinIO Operator <https://github.com/minio/operator>`__"
136137
mongodb-multi = "``MongoDBMultiCluster`` resource"
137138
mongodb-multis = "``MongoDBMultiCluster`` resources"

source/faq.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ To learn more, see :ref:`MongoDB Kubernetes Operator Compatibility <k8s-compatib
9999
How many deployments can |k8s-op-full| support?
100100
--------------------------------------------------------------
101101

102-
|k8s-op-short| can support up to 50 deployments. However, changes made to
103-
large numbers of deployments at the same time result in long reconciliation times.
104-
To avoid prolonged reconciliation times, limit a given |k8s-op-short| instance
105-
to 20 deployments. To learn more, see the :ref:`Deploy the Recommended Number of MongoDB Replica Sets <deploy_recommended-number-sets>`.
102+
|k8s-op-short| can support hundreds of deployments.
103+
To facilitate parallel reconciliation operations and avoid prolonged
104+
reconciliation times, :ref:`increase thread count of your Kubernetes Operator instance <increase-thread-count-ops-manager>`.
106105

107106
Should I run MongoDB Server in |k8s| in the same cluster as the application using it?
108107
----------------------------------------------------------------------------------------------
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The number of concurrent reconciliation processes the |k8s-op-short| can perform.

source/reference/helm-operator-settings.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,27 @@ operator.env
290290
# Use dev for more verbose logging
291291
env: prod
292292

293+
.. _mdb-max-concurrent-reconciles-helm:
294+
295+
operator.maxConcurrentReconciles
296+
--------------------------------
297+
298+
The maximum number of concurrent reconciliatios the |k8s-op-short| can perform.
299+
It sets |max-concurrent-reconciles|.
300+
To learn more, see the |k8s-op-short|
301+
:ref:`Deploy Multiple MongoDB Replica Sets. <deploy_recommended-number-sets>`
302+
303+
304+
.. example::
305+
306+
.. code-block:: yaml
307+
308+
operator:
309+
# Control how many reconciles can be performed in parallel.
310+
# Increasing the number of concurrent reconciliations decreases the time needed to reconcile all watched resources,
311+
# but it might result in request load spikes and increased load on the Ops Manager API, and the Kubernetes API server generally.
312+
maxConcurrentReconciles: 10
313+
293314
.. _mdb-default-architecture-helm:
294315

295316
operator.mdbDefaultArchitecture
@@ -591,6 +612,38 @@ registry.opsManager
591612
registry:
592613
opsManager: registry.connect.redhat.com/mongodb
593614

615+
.. _k8s-op-resources-setting:
616+
617+
operator.resources.requests
618+
---------------------------
619+
620+
Specifications for the `CPU and memory consumption limits <https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits>`__ of the |k8s-op-short|.
621+
622+
.. example::
623+
624+
.. code-block:: yaml
625+
626+
# operator cpu requests and limits
627+
resources:
628+
requests:
629+
cpu: 500m
630+
memory: 200Mi
631+
632+
operator.resources.limits
633+
---------------------------
634+
635+
Specifications for the `CPU and memory consumption limits <https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits>`__ of the |k8s-op-short|.
636+
637+
.. example::
638+
639+
.. code-block:: yaml
640+
641+
# operator cpu requests and limits
642+
resources:
643+
limits:
644+
cpu: 1100m
645+
memory: 1Gi
646+
594647
subresourceEnabled
595648
------------------
596649

source/reference/k8s-operator-specification.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ The following settings apply only to sharded cluster resource types:
421421
.. include:: /includes/setting-k8sScConf-spec.shard.agent.rst
422422
.. include:: /includes/setting-k8sScConf-spec.shard.agent.startupOptions.rst
423423
.. include:: /includes/setting-k8sScConf-spec.shardPodSpec.rst
424-
.. include:: /includes/setting-k8sScConf-spec.shardPodSpec.persistence.multiple.data.rst
425424
.. include:: /includes/setting-k8sScConf-spec.shardPodSpec.persistence.single.rst
426425
.. include:: /includes/setting-k8sScConf-spec.shardPodSpec.persistence.multiple.journal.rst
427426
.. include:: /includes/setting-k8sScConf-spec.shardPodSpec.persistence.multiple.logs.rst

source/reference/kubectl-operator-settings.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,27 @@ The default is ``true``.
544544
- name: MDB_WITH_AGENT_FILE_LOGGING
545545
value: true
546546

547+
.. _mdb-max-concurrent-reconciles:
548+
549+
MDB_MAX_CONCURRENT_RECONCILES
550+
------------------------------
551+
552+
.. include:: /includes/op-setting-descs/mdb-max-concurrent-reconciles.rst
553+
554+
.. example::
555+
556+
.. code-block:: yaml
557+
:linenos:
558+
559+
spec:
560+
template:
561+
spec:
562+
serviceAccountName: mongodb-enterprise-operator
563+
containers:
564+
- env:
565+
- name: MDB_MAX_CONCURRENT_RECONCILES
566+
value: "10"
567+
547568
MONGODB_ENTERPRISE_DATABASE_IMAGE
548569
---------------------------------
549570

source/tutorial/plan-k8s-op-considerations.txt

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,14 @@ recommendations for the |k8s-op-full| when running in production.
1717

1818
.. _deploy_recommended-number-sets:
1919

20-
Deploy the Recommended Number of MongoDB Replica Sets
21-
-----------------------------------------------------
20+
Deploy Multiple MongoDB Replica Sets
21+
------------------------------------
2222

2323
We recommend that you use a single instance of the |k8s-op-short|
24-
to deploy up to 20 replica sets in parallel.
24+
to deploy and manage your MongoDB replica sets.
2525

26-
You **may** increase this number to 50 and expect a reasonable
27-
increase in the time that the |k8s-op-short| takes to download,
28-
install, deploy, and reconcile its resources.
29-
30-
For 50 replica sets, the time to deploy varies and might take up to
31-
40 minutes. This time depends on the network bandwidth of the |k8s|
32-
cluster and the time it takes each {+mdbagent+} to download MongoDB
33-
installation binaries from the Internet for each MongoDB cluster member.
34-
35-
To deploy more than 50 MongoDB replica sets in parallel,
36-
use multiple instances of the |k8s-op-short|.
26+
To deploy more than 10 MongoDB replica sets in parallel,
27+
you can :ref:`increase the thread count of your Kubernetes Operator instance <increase-thread-count-ops-manager>`.
3728

3829
Specify CPU and Memory Resource Requirements
3930
--------------------------------------------
@@ -356,12 +347,20 @@ sharded clusters and standalone deployments.
356347
.. _operator_pod_resources:
357348

358349
Set CPU and Memory Utilization Bounds for the |k8s-op-short| Pod
359-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350+
----------------------------------------------------------------
351+
352+
When you deploy MongoDB replica sets with the |k8s-op-short|, the initial
353+
reconcilliation process increases CPU usage for the Pod running the
354+
|k8s-op-short|. However, when the replica set deployment process completes,
355+
the CPU usage by the |k8s-op-short| reduces considerably.
360356

361-
When you deploy replica sets with the |k8s-op-short|, CPU usage for
362-
Pod used to host the |k8s-op-short| is initially high during the
363-
reconciliation process, however, by the time the deployment completes,
364-
it lowers.
357+
.. note::
358+
359+
The severity of CPU usage spikes in the |k8s-op-short| is directly impacted
360+
by :ref:`the thread count <increase-thread-count-ops-manager>` of the
361+
|k8s-op-short|, as the thread count (defined by the :ref:`MDB_MAX_CONCURRENT_RECONCILES <mdb-max-concurrent-reconciles>` value)
362+
is equal to the number of reconcilliation processes that can be running in
363+
parallel at any given time.
365364

366365
For production deployments, to satisfy deploying up to 50 MongoDB
367366
replica sets or sharded clusters in parallel with the |k8s-op-short|,
@@ -373,22 +372,16 @@ as follows:
373372
- ``spec.template.spec.containers.resources.requests.memory`` to 200Mi
374373
- ``spec.template.spec.containers.resources.limits.memory`` to 1Gi
375374

376-
If you don't include the unit of measurement for CPUs, |k8s| interprets
377-
it as the number of cores. If you specify ``m``, such as 500m, |k8s|
378-
interprets it as ``millis``. To learn more, see
379-
:k8sdocs:`Meaning of CPU </concepts/configuration/manage-resources-containers/#meaning-of-cpu>`.
375+
376+
If you use Helm to deploy resources, define these values in
377+
the :ref:`values.yaml file <k8s-op-resources-setting>`.
380378

381379
The following abbreviated example shows the configuration with
382380
recommended CPU and memory bounds for the |k8s-op-short| Pod in your
383381
deployment of 50 replica sets or sharded clusters. If you are
384382
deploying fewer than 50 MongoDB clusters, you may use lower
385383
numbers in the configuration file for the |k8s-op-short| Pod.
386384

387-
.. note::
388-
389-
Monitoring tools report the size of the |k8s-node| rather than the
390-
actual size of the container.
391-
392385
.. example::
393386

394387
.. code-block:: yaml
@@ -451,7 +444,7 @@ file.
451444
.. _mdb_pods_resources:
452445

453446
Set CPU and Memory Utilization Bounds for MongoDB Pods
454-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447+
-------------------------------------------------------
455448

456449
The values for Pods hosting replica sets or sharded clusters map
457450
to the :k8sdocs:`requests field </reference/generated/kubernetes-api/{+k8s-api-version+}/#resourcerequirements-v1-core>`
@@ -470,10 +463,8 @@ for the MongoDB Pod as follows:
470463
- ``spec.podSpec.podTemplate.spec.containers.resources.requests.memory`` to 512M
471464
- ``spec.podSpec.podTemplate.spec.containers.resources.limits.memory`` to 512M
472465

473-
If you don't include the unit of measurement for CPUs, |k8s| interprets
474-
it as the number of cores. If you specify ``m``, such as 500m, |k8s|
475-
interprets it as ``millis``. To learn more, see
476-
:k8sdocs:`Meaning of CPU </concepts/configuration/manage-resources-containers/#meaning-of-cpu>`.
466+
If you use Helm to deploy resources, define these values in
467+
the :ref:`values.yaml file <k8s-op-resources-setting>`.
477468

478469
The following abbreviated example shows the configuration with
479470
recommended CPU and memory bounds for each Pod hosting a MongoDB
@@ -587,3 +578,53 @@ configurations for sharded clusters and standalone MongoDB deployments.
587578

588579
- :k8sdocs:`Running in Multiple Zones </setup/best-practices/multiple-zones/>`
589580
- :k8sdocs:`Node affinity </concepts/scheduling-eviction/assign-pod-node/#node-affinity>`
581+
582+
.. _increase-thread-count-ops-manager:
583+
584+
Increase Thread Count to Run multiple Reconciliation Processes in Parallel
585+
--------------------------------------------------------------------------
586+
587+
If you plan to deploy more than 10 MongoDB replica sets in parallel,
588+
you can configure the |k8s-op-short| to run multiple reconciliation processes
589+
in parallel by setting :ref:`MDB_MAX_CONCURRENT_RECONCILES <mdb-max-concurrent-reconciles>` environment variable in your |k8s-op-short|
590+
deployment or or through the :ref:`operator.maxConcurrentReconciles <mdb-max-concurrent-reconciles-helm>` field in your Helm
591+
``values.yaml`` file to configure a higher thread count.
592+
593+
Increasing the thread count of the |k8s-op-short| allows you to vertically scale your |k8s-op-short|
594+
deployment to hundreds of |k8s-mdbrscs| running within your |k8s| cluster
595+
and optimize CPU utilization.
596+
597+
Please monitor |k8s| API server and |k8s-op-short| resource usage and adjust their respective
598+
resource allocation if necessary.
599+
600+
.. note::
601+
602+
- Proceed with caution when increasing the :ref:`MDB_MAX_CONCURRENT_RECONCILES <mdb-max-concurrent-reconciles>` beyond 10.
603+
In particular, you must monitor the |k8s-op-short|, and the |k8s| API
604+
closely to avoid downtime resulting from increased load on those components.
605+
606+
To determine the thread count that suits your deployment's needs,
607+
use the following guidelines:
608+
609+
- Your requirements for how responsive the |k8s-op-short| must be when
610+
reconciling many resources
611+
612+
- The compute resources available within your |k8s| environment and
613+
the total processing load your |k8s| compute resources are under, including
614+
resources that may be unrelated to MongoDB
615+
616+
- An alternative to increasing the thread count of a single |k8s-op-short|
617+
instance, while still increasing the number of |k8s-mdbrscs| you can support
618+
in your |k8s| cluster, is to deploy multiple |k8s-op-short| instances within
619+
your |k8s| cluster. However, deploying multiple |k8s-op-short|
620+
instances requires that you ensure that no two |k8s-op-short| instances
621+
are monitoring the same |k8s-mdbrscs|.
622+
623+
Running more than one instance of the |k8s-op-short| should be done with care,
624+
as more |k8s-op-short| instances (especially with parallel reconciliation enabled)
625+
put the API server at greater risk of being overwhelmed.
626+
627+
- Scaling of the |k8s| API server is not a valid reason to run
628+
more than one instance of the |k8s-op-short|. If you observe that performance of
629+
the API server is affected, adding more instances of the |k8s-op-short| is
630+
likely to compound the problem.

0 commit comments

Comments
 (0)