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

443
Views
Bad: FastApi response problems

i create api using fastapi framework and i have deployed on heroku, the main function of this api is i have to send (post method) element as query parameter every 10s and i create path to show all elements sent but i facing problem when i refresh page i didn't get all element sent for example if i send [1, 2, 3, 4, 5, 6, 7, 8, 9] sometimes i get [1, 3, 4, 5, 7, 9] and sometimes i get [2, 6, 8], but in local i have api run perfectly.

from fastapi import FastAPI

app = FastAPI()

hr = []


@app.get("/")
async def api_status():
    return {"message": "api running"}


@app.get("/hr")
async def show_hr_values():
    if hr:
        return hr
    return {"message": "hr empty"}


@app.post("/hr")
async def add_hr_value(hr_value: int):
    hr.append(hr_value)
    return {"message": f"hr = {hr_value} added"}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Heroku will not run your application as just one process. Since you're keeping this data in memory, it will only be updated and kept in that process that receives your request.

Use a database or KV store to store your data instead, so that it's stored in a centralized location that all processes can talk to. Heroku supports managed postgres and redis that you can use for either of these use cases.

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!