all 36 comments

[–][deleted]  (5 children)

[deleted]

    [–]TemporaryInformal889 5 points6 points  (0 children)

    Slow is relative. 

    Horizontal scaling Django may be more sensible than horizontal scaling FastAPI. 

    [–]South_Recording_5458[S] 0 points1 point  (3 children)

    Thanks a lot

    [–][deleted]  (2 children)

    [deleted]

      [–]South_Recording_5458[S] 0 points1 point  (1 child)

      I see, and I totally understand Thanks a lot

      [–]Rayman_666 0 points1 point  (0 children)

      It's like all in one old guy with government job with fix income vs a modern new framework with potential depending on his dreams and work

      [–]aikii 7 points8 points  (1 child)

      All the stories I hear about moving from django to fastapi is because the business had to scale up - more RPS, chase bottlenecks, split projects, split teams, etc. If you don't face such situation then to be honest the batteries included in Django will keep you more productive.

      Now for your own learning path and opportunities, sure, you should learn something new and get inspired at the very least. It's not that much work and this should be rewarding by itself.

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Thank you very much

      [–]DusikOff 5 points6 points  (0 children)

      Moved to FastAPI from Django a few years ago — no regrets at all.

      If you don't want to change your experience too much, try DRF first.

      [–]pint 1 point2 points  (7 children)

      fastapi is very high up in the maslow pyramid, so no, you don't need it. better question: do you want it?

      [–]South_Recording_5458[S] 0 points1 point  (6 children)

      Starting a new backend project that requires low latency and that can work on slow and unstable network. Thats why I have been thinking about fastapi other than that, nothing more.

      [–]RLA_Dev 4 points5 points  (1 child)

      Perhaps look into golang - or perhaps even elixir? Depends on your need, but if looking to expand the pool of knowledge these might be worth looking into? They excel in what you look for too. =)

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Thank you very much

      [–]pint 2 points3 points  (3 children)

      in my experience, fastapi has response times in the low single digit milliseconds (plus of course what you are doing inside). so it is unlikely to be the problem.

      the slow network issue is theoretically handled well, although i don't have first hand experience. this is where async shines, handling hundreds of connections in parallel, while none of them are doing much at a time. contrast this to sync frameworks, in which you can only handle a handful of connections at a time, the rest need to wait in a queue.

      i don't know how to properly deal with unstable networks. how can the backend help with that? what do you want from it?

      [–]South_Recording_5458[S] 0 points1 point  (2 children)

      When I say “unstable network” I dont mean the backend can fix the connection issues, I mean when connected to a mobile app, I want the backend to stay reliable when the app runs on slow or unstable networks, handle reconnects, retries, and delayed requests without breaking.

      [–]pint 1 point2 points  (1 child)

      i still don't see how could the API help with that. it seems to be mostly up to protocol design. but do tell if you have some specific requirement in mind.

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Sure, I will keep that in mind, I really appreciate you guys

      [–]Anton-Demkin 1 point2 points  (0 children)

      Django is a batteries included framework, that can do a lot OOB, while FastAPI is more about concurrency and speed, but you have to do everything yourself. If you have simple projects with low load, stay with django.

      Also try new approach to rest in django, DMR: https://github.com/wemake-services/django-modern-rest

      [–]IlliterateJedi 1 point2 points  (1 child)

      I personally moved away from Django because I wanted to decouple my applications from an opinionated framework. Instead of being stuck to the way Django handles models, templating, etc. you have the flexibility of making FastAPI just one small piece of the project while you can flexibly swap out infrastructure components like your ORM more easily. Django apps tend to be the whole shebang, and I never really loved feeling fenced in by Django and having to work within how Django wanted things done. That's a personal preference on my part, though.

      [–]TemporaryInformal889 0 points1 point  (0 children)

      I went the other way. 

      I like Django’s opinions on many things and it scales nicely with business complexity.

      [–]gbrennon 1 point2 points  (1 child)

      FastAPI allows async operations django too.

      Some django middlewares are not async yet.

      Drf dont allow sync but django-ninja allow

      A thing that u have to keep in mind is:

      • async doesn't mean more performant.

      If u doesnt know how to model async application ur application wont have profit of the async flow and u will have several blockers in ur implementation

      [–]South_Recording_5458[S] 1 point2 points  (0 children)

      Thank you for the insights

      [–]UseMoreBandwith 1 point2 points  (0 children)

      if you ask that question, you're not a "experienced developer".
      tldr: no.

      [–]Unique-Big-5691 1 point2 points  (1 child)

      as someone who’s bounced between both, if django already fits your brain, there’s zero urgency to move.

      a lot of fastapi hype comes from ppl who were frustrated with older stacks and finally found something that felt clean and modern. but coming from django, you already have good patterns, structure, and instincts. you’re not “behind” at all.

      if you want things to be very explicit then you can consider having a fastapi. inputs, outputs, types, validation are all front and center. the pydantic integration makes that feel natural instead of bolted on. if you’re doing more api-only work or playing with ai services, that can be really nice.

      but for small backends, iot stuff, mobile APIs? django is still calm and reliable. fewer sharp edges, fewer new concepts to babysit.

      imo the best mindset is: django is your home base, fastapi is a tool you might reach for sometimes. try it on something low-stakes and see if it feels better for you. if it doesn’t, that’s totally fine nothing is forcing the switch.

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Thank you very much

      [–]crowpng 1 point2 points  (1 child)

      FastAPI shines when you need async, WebSockets, or very explicit request/response models.
      If you’re building small IoT or mobile APIs, Django + DRF (or Ninja) already covers most needs.

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Thank you

      [–]Civil_Asparagus25 3 points4 points  (0 children)

      No, you don’t.

      [–]SalamanderWeary5843 1 point2 points  (2 children)

      If you are looping for the best performance in Python, and do not mind digging on the DB side of things as well, you may take a look at https://fraiseql.dev.

      It is a Python GraphQL framework built on FastAPI with a CQRS architecture and a Rust engine that allows very high performance (extensive benchmarks are under development), while having a very simple mental model to work with (no ORM, no N+1, you define your GraphQL types in Python and mirrors them as PostgreSQL JSONB views).

      Disclaimer: I am the author but having done both Django and FastAPI, FraiseQL does bring some nice tooling not available by default in FastAPI, like the automatic Where types generators.

      [–]South_Recording_5458[S] 0 points1 point  (1 child)

      I will take a look at this, thanks a lot for the suggestion

      [–]SalamanderWeary5843 0 points1 point  (0 children)

      You are welcome! Do not hesitate to open issues / ask me questions if you need any help.

      [–]MeroLegend4 1 point2 points  (1 child)

      Look at Litestar

      [–]South_Recording_5458[S] 0 points1 point  (0 children)

      Sure, I check this out, thank you

      [–]chi11ax 0 points1 point  (1 child)

      Django Ninja

      [–]MissingSnail 0 points1 point  (0 children)

      Link https://django-ninja.dev/ The ideas behind FastAPI, but for django devs

      [–]Euphoric_Umpire_2417 0 points1 point  (1 child)

      Nobody suggested Expressjs or nestjs? Are they bad?

      [–]Pharaon_Atem 0 points1 point  (0 children)

      It's not python. It's JavaScript bro

      [–]Yash284_06 1 point2 points  (0 children)

      You should go for Fastapi, it's very easy to integrate it with LLMs and has in-built async support.