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

feat: PLT-396: Add gevent pooler #148

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

feat: PLT-396: Add gevent pooler #148

wants to merge 1 commit into from

Conversation

farioas
Copy link
Member

@farioas farioas commented Jun 24, 2024

Let's say you need to execute thousands of HTTP GET requests to fetch data from external REST APIs. The time it takes to complete a single GET request depends almost entirely on the time it takes the server to handle that request. Most of the time, your tasks wait for the server to send the response, not using any CPU.

The bottleneck for this kind of task is not the CPU. The bottleneck is waiting for an Input/Output operation to finish. This is an Input/Output-bound task (I/O bound). The time the task takes to complete is determined by the time spent waiting for an input/output operation to finish.

If you run a single process execution pool, you can only handle one request at a time. It takes a long time to complete those thousands of GET requests. So you spawn more processes.

However, there is a tipping point where adding more processes to the execution pool hurts performance. The overhead of managing the process pool becomes more expensive than the marginal gain for an additional process.

In this scenario, spawning hundreds (or even thousands) of threads is a much more efficient way to increase capacity for I/O-bound tasks. Celery supports two thread-based execution pools: eventlet and gevent. Here, the execution pool runs in the same process as the Celery worker itself. To be precise, both eventlet and gevent use greenlets and not threads.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 43.72%. Comparing base (91dc1d6) to head (e9d7644).
Report is 3 commits behind head on master.

Files Patch % Lines
server/tasks/process_file.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #148      +/-   ##
==========================================
- Coverage   43.79%   43.72%   -0.08%     
==========================================
  Files          40       40              
  Lines        1813     1816       +3     
==========================================
  Hits          794      794              
- Misses       1019     1022       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robot-ci-heartex robot-ci-heartex temporarily deployed to fb-PLT-396 June 24, 2024 12:50 Destroyed
@robot-ci-heartex
Copy link
Collaborator

@robot-ci-heartex robot-ci-heartex marked this pull request as draft June 24, 2024 15:45
@robot-ci-heartex
Copy link
Collaborator

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 this pull request may close these issues.

3 participants