Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Klein adds significant performance overhead over a twisted.web server #755

Open
itamarst opened this issue May 31, 2024 · 6 comments · May be fixed by #773
Open

Klein adds significant performance overhead over a twisted.web server #755

itamarst opened this issue May 31, 2024 · 6 comments · May be fixed by #773

Comments

@itamarst
Copy link
Contributor

A minimal hello world benchmark, just routing "/" and returning a string, is half the speed of the equivalent minimal twisted.web server.

I will start investigating where the performance overhead is, and hopefully find some places to optimize.

@itamarst itamarst changed the title Klein adds significant performance overhead over Twisted web Klein adds significant performance overhead over a twisted.web server May 31, 2024
@itamarst
Copy link
Contributor Author

Initial investigation suggests no obvious Klein-side improvements, other than a minor 1% improvements. Possibly would benefit from additional performance optimizations on the Twisted side though that weren't exposed by previous benchmarks.

@adiroiban
Copy link
Member

Is klein designed to be used for high performance applications ?

I see klein and other similar "microframework" as a quick way to get a simple site up and runnig, without the expectation of performance or doing advance/custome HTTP operations.

@glyph
Copy link
Member

glyph commented Jun 1, 2024

Is klein designed to be used for high performance applications ?

If it's for use in production then it should be as fast as is reasonable.

@glyph
Copy link
Member

glyph commented Jun 1, 2024

I will start investigating where the performance overhead is, and hopefully find some places to optimize.

How much of it is happening in Klein vs. e.g. Werkzeug?

@itamarst
Copy link
Contributor Author

itamarst commented Jun 1, 2024

Werkzeug is pretty minimal. It's mostly additional twisted.web interactions (therefore places where twisted.web optimizations might help), twisted Deferreds, and the fact that klein is very forgiving in what you can return. Architectural improvements for the latter might involve looking at function return signatures and assuming they're accurate, maybe, so you don't have to all the if IResource.providedBy stuff.

@itamarst
Copy link
Contributor Author

itamarst commented Jun 1, 2024

And it's also possible there's work being done on in klein that's duplicative to what twisted.web does.

@itamarst itamarst linked a pull request Sep 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants