{"id":16433218,"url":"https://github.com/vikyw89/fastapi-deployment-benchmark","last_synced_at":"2025-10-05T15:05:13.411Z","repository":{"id":251774820,"uuid":"838383734","full_name":"vikyw89/fastapi-deployment-benchmark","owner":"vikyw89","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-14T12:48:58.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"alpha","last_synced_at":"2025-06-13T22:07:58.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vikyw89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T14:27:30.000Z","updated_at":"2024-08-14T12:49:01.000Z","dependencies_parsed_at":"2024-08-05T18:07:38.209Z","dependency_job_id":"dd33990a-aaa8-47c7-bcec-366a3b452fef","html_url":"https://github.com/vikyw89/fastapi-deployment-benchmark","commit_stats":null,"previous_names":["vikyw89/fastapi-deployment-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vikyw89/fastapi-deployment-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikyw89%2Ffastapi-deployment-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikyw89%2Ffastapi-deployment-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikyw89%2Ffastapi-deployment-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikyw89%2Ffastapi-deployment-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vikyw89","download_url":"https://codeload.github.com/vikyw89/fastapi-deployment-benchmark/tar.gz/refs/heads/alpha","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikyw89%2Ffastapi-deployment-benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278470201,"owners_count":25992206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T08:45:27.239Z","updated_at":"2025-10-05T15:05:13.370Z","avatar_url":"https://github.com/vikyw89.png","language":"Python","readme":"# FastAPI Benchmark\n\nThis README provides a benchmark comparison between synchronous and asynchronous endpoints in FastAPI, running under different server configurations.\n\n## Server Code\n\n```python\n@app.get(\"/sync/{item_id}\")\ndef read_item(item_id: int, q: Union[str, None] = None):\n    time.sleep(1)\n    return {\"item_id\": item_id, \"q\": q}\n\n@app.get(\"/async/{item_id}\")\nasync def aread_item(item_id: int, q: Union[str, None] = None):\n    await asyncio.sleep(1)\n    return {\"item_id\": item_id, \"q\": q}\n```\n\n## Benchmark Results\n\n### Running with `fastapi run benchmark/main.py`\n\n| Endpoint | Command                                                 | Requests per second (mean) |\n| -------- | ------------------------------------------------------- | -------------------------- |\n| Async    | `ab -c 10000 -n 10000 \"http://localhost:8000/async/31\"` | 1496.38 [#/sec]            |\n| Sync     | `ab -c 10000 -n 10000 \"http://localhost:8000/sync/31\"`  | 39.48 [#/sec]              |\n\n### Running with `poetry run gunicorn benchmark.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker`\n\n| Endpoint | Command                                                 | Requests per second (mean) |\n| -------- | ------------------------------------------------------- | -------------------------- |\n| Async    | `ab -c 10000 -n 10000 \"http://localhost:8000/async/31\"` | 3462.74 [#/sec]            |\n| Sync     | `ab -c 10000 -n 10000 \"http://localhost:8000/sync/31\"`  | 105.77 [#/sec]             |\n\n### Running with `poetry run gunicorn benchmark.main:app --workers 12 --worker-class uvicorn.workers.UvicornWorker`\n\n| Endpoint | Command                                                 | Requests per second (mean) |\n| -------- | ------------------------------------------------------- | -------------------------- |\n| Async    | `ab -c 10000 -n 10000 \"http://localhost:8000/async/31\"` | 7593.36 [#/sec]            |\n| Sync     | `ab -c 10000 -n 10000 \"http://localhost:8000/sync/31\"`  | 155.80 [#/sec]             |\n\n### Running with `uvicorn benchmark.main:app --workers 4 --host 0.0.0.0 --port 8000`\n\n| Endpoint | Command                                                 | Requests per second (mean) |\n| -------- | ------------------------------------------------------- | -------------------------- |\n| Async    | `ab -c 10000 -n 10000 \"http://localhost:8000/async/31\"` | 7507.83 [#/sec]            |\n\n## Conclusion\n\n- Asynchronous endpoints significantly outperform synchronous ones in terms of requests per second.\n- Increasing the number of workers with Gunicorn improves the performance for both synchronous and asynchronous endpoints.\n- The asynchronous approach is particularly beneficial for I/O-bound operations, as demonstrated in this benchmark.\n\n### @vikyw89-20240805\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikyw89%2Ffastapi-deployment-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvikyw89%2Ffastapi-deployment-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikyw89%2Ffastapi-deployment-benchmark/lists"}