nickva opened a new pull request #2927:
URL: https://github.com/apache/couchdb/pull/2927


   Instead of max workers all waiting on accept, and racing to grab the same 
job,
   generating conflicts and retries in the process, switch to having `A` 
acceptors
   and `W` workers as separate configurable items, such that `A < W`.
   
   A smaller number of acceptors (5 by default) will be spawned and will wait to
   accept jobs. As soon any one accepts a job, and start executing, they will
   notify the parent server via a gen_server call. The main couch_views_server,
   when notified, will mark the acceptor as a worker as long as `A + W <
   max_workers`.
   
   When any worker exists, the main server may spawn more acceptors if number of
   current acceptors `A < max_acceptors` _and_ `A + W < max_workers`.
   
   The main idea behind `A + W < max_workers` is that we consider acceptors as
   potential workers, they could accept a job at any time and immediately start
   executing it, so we wouldn't want to start another acceptor.
   
   As an example here is what might happen with say max_acceptors = 5 and
   max_workers = 100:
   
   1. Starting out:
     `A = 5, W = 0`
   
   2. After 2 acceptors get jobs and start running them:
     `A = 3, W = 2`
   Then immediately spawn another 2 acceptors:
     `A = 5, W = 2`
   
   3. After 95 workers are started it might look like:
     `A = 5, W = 95`
   
   4. Now if 3 acceptors accept a job, it would look like:
     `A = 2, W = 98`
   But no more acceptors would be started.
   
   5. If the last 2 acceptors also accept jobs it might look like:
    `A = 0, W = 100`
   This is when it reaches full utilization and doesn't accept any more jobs.
   
   6. Then if 1 worker exits:
    `A = 0, W = 99`
   And 1 acceptor will be spawned
    `A = 1, W = 99`
   
   7. If all 99 workers exit, it will go back to:
    `A = 5, W = 0`
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to