Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore: Move mold promotion logic in workers #32

Closed
casperisfine opened this issue Feb 14, 2023 · 0 comments · Fixed by #38
Closed

Explore: Move mold promotion logic in workers #32

casperisfine opened this issue Feb 14, 2023 · 0 comments · Fixed by #38

Comments

@casperisfine
Copy link
Contributor

Right now, it's the master process that keeps an eye on workers and chose to promote one of them when some condition is reached.

Pros:

  • It's somewhat easy to make it race-condition free because only a single threaded process makes the decision.

Cons:

  • It prevent the master from sleeping for prolonged amount of time, like in unicorn, as we have to wake up frequently to check if the promotion condition was reached. That's not great.
  • The condition has to be checked on all workers sequentially, which means it doesn't scale very well with the number of workers.
  • We don't really know if the worker is idle of busy with a request that will still take a very long time. So we may end up selecting a busy worker that will end up timing out. We currently handle this case, but it delays the new generation.
  • It makes it harder to allow custom mold selection implementations, as the master doesn't load the app.

Since that's a lot of cons, I think we should explore moving this logic into the workers.

Pros:

  • Workers would only be considered for promotion when they are idle (or just finished a request).
  • That reduce load on the master.

Cons:

  • We need some shared mutex/semaphore to make sure only one worker is promoted, but that should be doable with a Raindrop atomic counter.

The logic would be something like:

def check_promotion
  if condition_met
    if acquire_promotion_lock
      start_promotion # start by notifying master, promote, confirm to master.
    else
      # somehow debounce promotion_check ?
      # e.g. if we continue to use request_count, we can do `request_limit *= 1.20`
    end
  end
end
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
casperisfine pushed a commit that referenced this issue Mar 28, 2023
Fix: #32

This remove a lot of busy work from the server, and allow to promote
as soon as the condition is reached.

The small downside is that we need a lock between processes to ensure
two workers won't try to promote at the same time.

This also means that the mold selector is removed. It wasn't that
interesting anyway, because the Unicorn/Pitchfork architecute introduce
a bias in request distribution, worker#0 will almost always get requests
first so will almost always be the best candidate for promotion.
casperisfine pushed a commit that referenced this issue Mar 28, 2023
Fix: #32

This remove a lot of busy work from the server, and allow to promote
as soon as the condition is reached.

The small downside is that we need a lock between processes to ensure
two workers won't try to promote at the same time.

This also means that the mold selector is removed. It wasn't that
interesting anyway, because the Unicorn/Pitchfork architecute introduce
a bias in request distribution, worker#0 will almost always get requests
first so will almost always be the best candidate for promotion.
casperisfine pushed a commit that referenced this issue Mar 28, 2023
Fix: #32

This remove a lot of busy work from the server, and allow to promote
as soon as the condition is reached.

The small downside is that we need a lock between processes to ensure
two workers won't try to promote at the same time.

This also means that the mold selector is removed. It wasn't that
interesting anyway, because the Unicorn/Pitchfork architecute introduce
a bias in request distribution, worker#0 will almost always get requests
first so will almost always be the best candidate for promotion.
casperisfine pushed a commit that referenced this issue Mar 28, 2023
Fix: #32

This remove a lot of busy work from the server, and allow to promote
as soon as the condition is reached.

The small downside is that we need a lock between processes to ensure
two workers won't try to promote at the same time.

This also means that the mold selector is removed. It wasn't that
interesting anyway, because the Unicorn/Pitchfork architecute introduce
a bias in request distribution, worker#0 will almost always get requests
first so will almost always be the best candidate for promotion.
casperisfine pushed a commit that referenced this issue Mar 28, 2023
Fix: #32

This remove a lot of busy work from the server, and allow to promote
as soon as the condition is reached.

The small downside is that we need a lock between processes to ensure
two workers won't try to promote at the same time.

This also means that the mold selector is removed. It wasn't that
interesting anyway, because the Unicorn/Pitchfork architecute introduce
a bias in request distribution, worker#0 will almost always get requests
first so will almost always be the best candidate for promotion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant