Menu

1 / 2

Fairness Under Load: Asyncio, Priority Semaphores, and Hedged Fallbacks in FastAPI

DEV Community: fastapi·Andrew Kihara·3 days ago
#VO75Mk6T
#devtofastapi#devto#dev#l314#l289
Long article (3231 words) — no AI summary yet.
Reading 0:00
15s threshold

This is Part 3 (final) of a 3-part series on the post-hackathon engineering behind Star Hunters ( live app ). Part 1 covered the architecture and UI redesign, and Part 2 unpacked our 4-tier caching pipeline. Here, I dive into backend_service.py , spherex_coadd.py , and archival_resolver.py .

Background: When Fast async def Routes Secretly Block Each Other

"Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once." (Rob Pike)

One of the easiest traps in AI-generated FastAPI code is sprinkling async def and run_in_executor everywhere and assuming concurrency is "solved."

When I started stress-testing our post-hackathon server on a shared-cpu-2x ( 2048 MB RAM) Fly.io configuration, two completely different user actions were fighting over the exact same resources:

Heavy Background Sky-Tile Builds ( get_sky_patch_async ): When a user pans onto an uncached sky coordinate, the server downloads up to 18 scientific images, aligns their camera projections onto a…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.