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

408
Visualizações
503 Error: Service Unavailable heroku while doing inference

I have deployed a machine learning model using Fast API in Heroku and I have implemented the background worker and async but when I am doing inference I am still getting 503 error. I know the server response time in Heroku is 30 seconds.

But as I am using a background worker I should be able to run in the background, instead, I am getting errors. I am using Heroku free plan to deploy


app = FastAPI()
response = {}
@app.get('/predict')
async def predictions(solute, solvent):
    mol = Chem.MolFromSmiles(solute)
    response["predictions"] = delta_g.item()
    return {'result': response}

async def predict(background_tasks: BackgroundTasks,solute,solvent):
    background_tasks.add_task(predictions,solute,solvent)
    
from predict_json import json_data_func

@app.get('/predict_two')
async def predictions_two(solute):
    for i in data:
        delta_g, interaction_map = model([get_graph_from_smile(Chem.MolToSmiles(Chem.AddHs(Chem.MolFromSmiles(solute)))).to(device), get_graph_from_smile(Chem.MolToSmiles(Chem.AddHs(Chem.MolFromSmiles(i)))).to(device)])
        response_two[i] = delta_g.item()
    return {'result': response_two}

async def predict_two(background_tasks: BackgroundTasks,solute):
    background_tasks.add_task(predictions_two,solute)

Procfile: web: gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app

So what should I have to do to run my code in the background without having a server response time-out error?

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

0

You can add timeout parameter (with -t or --timeout) to the gunicorn as stated in the gunicorn documentation.

Example usage:

gunicorn -w 2 -k uvicorn.workers.UvicornWorker -t 90 main:app
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