Why FastAPI Beat Django and Flask

In 2024, FastAPI became more popular than Django and Flask.

Source Jetbrains Python Developers Survey 2024.

Async-First Design

My previous article, Django vs FastAPI: A Practical Comparison, highlighted the challenges of using Django in an async application.

Asynchronous apps are increasingly needed when a person wants to assign a task to an agent and then do some other work instead of waiting for the agent to complete.

Common examples:

  • request is sent to an LLM and it takes several minutes to get a response
  • complex search on database
  • upload and download large files
  • web crawling

The following table from the same JetBrains Python survey illustrates the rise of async apps with FastAPI.

The following Python packages are used in async apps:

  • Asyncio
  • aiohttp
  • httpx

Asyncio is used by 42% of people using FastAPI compared to 26% for Django.

As aiohttp and httpx are similar, I’ll add them together in a async http group.

async http is used by 50% of the people using FastAPI. Only 31% of the people are using these technologies with Django.

Summary

Although Django can be used to build asynchronous applications, the simplicity of using async-first FastAPI makes it more popular than Django

Next Steps

Join us in exploration asynchronous Python AI application development with FastOpp.

1 Like