twisted/klein

Klein adds significant performance overhead over a twisted.web server

Opened this issue · 6 comments

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.

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.

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.

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.

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?

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.

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