Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda