diff --git a/ansible_mitogen/process.py b/ansible_mitogen/process.py index 52ce4ca7..1880f769 100644 --- a/ansible_mitogen/process.py +++ b/ansible_mitogen/process.py @@ -27,6 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. from __future__ import absolute_import +import logging import os import socket import sys @@ -43,6 +44,9 @@ import ansible_mitogen.logging import ansible_mitogen.services +LOG = logging.getLogger(__name__) + + class MuxProcess(object): """ Implement a subprocess forked from the Ansible top-level, as a safe place @@ -146,9 +150,14 @@ class MuxProcess(object): Construct a ContextService and a thread to service requests for it arriving from worker processes. """ - self.pool = mitogen.service.Pool(self.router, [ - ansible_mitogen.services.ContextService(self.router) - ]) + self.pool = mitogen.service.Pool( + router=self.router, + services=[ + ansible_mitogen.services.ContextService(self.router) + ], + size=int(os.environ.get('MITOGEN_POOL_SIZE', '16')), + ) + LOG.debug('Service pool configured: size=%d', self.pool.size) def on_broker_shutdown(self): """ diff --git a/docs/ansible.rst b/docs/ansible.rst index 624d0ba0..6cf4a58c 100644 --- a/docs/ansible.rst +++ b/docs/ansible.rst @@ -115,14 +115,6 @@ This is a proof of concept: issues below are exclusively due to code immaturity. High Risk ~~~~~~~~~ -* Connection establishment is single-threaded until more pressing issues are - solved. To evaluate performance, target only one host. Many hosts still work, - the first playbook step will simply run unnecessarily slowly. - -* `Asynchronous Actions And Polling - `_ has received - minimal testing. - * For now only **built-in Python command modules work**, however almost all modules shipped with Ansible are Python-based. @@ -133,6 +125,10 @@ High Risk file, the host machine could easily exhaust available RAM. This will be fixed soon as it's likely to be tickled by common playbook use cases. +* `Asynchronous Actions And Polling + `_ has received + minimal testing. + * Only Ansible 2.4 is being used for development, with occasional tests under 2.3 and 2.2. It should be more than possible to fully support at least 2.3, if not also 2.2. @@ -172,6 +168,12 @@ Low Risk Behavioural Differences ----------------------- +* Ansible permits up to ``forks`` SSH connections to be setup simultaneously, + whereas in Mitogen this is handled by a thread pool. Eventually this pool + will become per-CPU, but meanwhile, a maximum of 16 SSH connections may be + established simultaneously by default. This can be increased or decreased + setting the ``MITOGEN_POOL_SIZE`` environment variable. + * Mitogen treats connection timeouts for the SSH and become steps of a task invocation separately, meaning that in some circumstances the configured timeout may appear to be doubled. This is since Mitogen internally treats the