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

407
Views
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 answers
Answer question

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 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!