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

242
Visualizações
gunicorn doesn't use all CPU resulting in lot of failed requests

I am load-testing a gunicorn server(uses Uvicorn workers with fastapi) on AWS EC2 machine that I sshed into and port mapped to(doing ssh -L 8000:localhost:8000), for all requests at port 8000 on my local machine to be routed to the EC2 machine.

And I am using k6 to generate artificial traffic(load-test) for gunicorn server in EC2 instance from my local machine. With ONLY 500-800 vus, upwards of 46% requests always fail, but the CPU usage of EC2 machine never goes past 30% for any of the 8 cores(from htop). I am using c5a.2xlarge machine(has 4cores or 8threads).

Here's how I am lauching the gunicorn from terminal(because of the config, gunicorn launches with 4 workers):

$ gunicorn api.main:app --worker-class uvicorn.workers.UvicornWorker --user dockerd --capture-output --keep-alive 0 --port 8000

and the configuration file I am using is from tiangolo's uvicorn-gunicorn-docker

This is a fastapi app, serving a scikit-learn model without any calls to database or anything like that. So, this is a completely cpu-bound app.

I am happy to provide more information as required.

Where and what changes do I make in uvicorn or gunicorn to be able to serve lots of requests with as less failure rate as possible, while using all resources to the maximum(or to the extent needed).

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Please check load average on your instance. It is possible that the CPU is not being maxed out because you have the disk that is becoming the bottleneck. If your loadaverage indicates several jobs are piled up but the CPU % is not going up, it might mean disk latency.

It is better to remove all logs. load average is available in "sudo htop". you can look that up. I am quite sure now that your problem is the disk

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