DEV Community

Cover image for Litestar 2.0 incoming: Speed of Light - Power of Stars!
Phyo Arkar Lwin
Phyo Arkar Lwin

Posted on • Updated on

Litestar 2.0 incoming: Speed of Light - Power of Stars!

Litestar 2.0 [Formerly Starlite] is coming soon!

In the world of Python web development frameworks, they can be categorized into two extremes:

  • One category is full-stack frameworks like Django and Odoo. They are often considered bloated and heavy, making it hard to optimize performance. These frameworks impose their own way of doing things and can get in the way of both frontend and backend developers. They may not even provide a proper REST API by default. While they can be customized to some extent (especially Django), implementing special features can be challenging, requiring hacky workarounds or forks. Although some functionality can be added through addons, not all addons are properly maintained or meet the quality standards of the core frameworks.

  • The others are there are micro frameworks like Flask, Sanic, and FastAPI that are simple (just an HTTP server with route handlers) for the sake of simplicity. However, they reject many features that could benefit developers. This often leads teams to build their own half-cooked frameworks based on these micro frameworks, which eventually become too complex to maintain. Consequently, teams often abandon their custom frameworks and migrate to frameworks like Django, which may not support their specific use cases.

Why we choose Litestar over of FastAPI?

We are one of a small , but experienced Software development agency in Yangon , Myanmar. In past decade , we had used various python web frameworks - back in 2010 we used web2py for quick and easy applications development then we moved to Django for more fuller stack/admin style dev needs. During 2015-2019 we developed our own chatrooms , and realtime social application so we used Tornado web for that. It is still great , high quality Realtime web framework but it doesn't have any support for building REST/OpenAPI systems out so we started trying FastAPI around 2020 .

Shortfalls of FastAPI

At the start, everything went great. However, soon after we moved it to staging and tested it with a few hundred users, it started encountering problems.

  • We faced memory leak issues that had been reported and had pull requests by other contributors that fix it ready for a long time.
  • Additionally, we experienced unexpected asynchronous problems and random failures in file uploads.

What's worse is that the repo had quality pull requests waiting to be merged for years, and the maintainers won't even actually review them. Although the repository seemed active with daily commits and sponsor updates, there were only a few lines of documentation and README.md changes. After multiple requests from the community,the maintainer replied but we weren't convinced by his replies and questioned their judgment (a few months ago, all the issues were abruptly converted into discussions without any notice too) .

Around the same time, the Starlite framework was released. Even in its alpha version, it proved to be a lot faster than FastAPI and was already well-architected with a proper Dependency Injection system. FastAPI, on the other hand, still struggled in this aspect. Consequently, we decided to rewrite our app using Starlite, and since then, we haven't looked back. Starlite has proven to be more stable and significantly faster, improving performance by 40% to 120% even in older versions, on our use cases.

I have also joined the Starlite community and genuinely appreciate their commitment to producing quality work, which is nonexistent in FastAPI. We have been using Starlite (Litestar) for over a year now, and it has been a great experience.

Enter Litestar!

Starlite is getting renamed as Litestar , Starting at 2.0 release.

Litestar is a framework that strikes a balance between simple micro framework and enterprise full-stack frameworks. With Litestar, you can start with a route handler function (with typed parameters) and already get auto-generated OpenAPI 3.1 documentation, Swagger/Redoc/Element interfaces,and auto generated example schema documentation with just five lines of code. It even provides TypeScript types. Next, Litestar won't get in your way, but it offers batteries-included functionality to build fully functional, full-stack web applications. Just import or included the already included contrib moduels, middlewares, and plugins maintained by core maintainers who are industry experts.

In Litestar 2.0, you can build full framework-style applications by utilizing the following features:

Visit litestar.dev they have a great discord at:

The maintainers are very helpful and they keep a great community culture. They keep high bar for code quality and I learnt a lot contributing there . Code together with us!

In the next post, I will show how a simple route handler script can evolve into a complex application using DDD: DTO and Repository patterns.

Top comments (0)