Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Sequential request processing (CPU-heavy processing)

I am running a compute-heavy Flask app behind gunicorn. Requests are handled by Nginx that passes them onto gunicorn and the Flask app:

gunicorn -access-logfile - wsgi --bind 127.0.0.1:5002 --workers 2 --threads 8

Each request takes about 1 second to process (CPU-heavy). If two requests arrive in close succession, I would like the second request to "wait", while the first is being processed. But instead it seems that both requests get slower as the CPU attempts to process both in parallel.

Is there a way to force the app to process incoming requests sequentially?

Thank you!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use python-filelock to achieve your goal, try to acquire the same lock on all processes/threads before running your CPU-heavy code.

But I am not sure why do you use --workers 2 --threads 8. This answer to the question "How many concurrent requests does a single Flask process receive?" , might also provide an answer to your usecase

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!