使用瓶子进行路由的性能优势?

performance advantages of using bottle for routing?

几年前,我开始基于 网络框架开发网络应用程序。当时我选择了 Bottle,因为它是最简单的解决方案,可以快速 运行,而且我只是在构建我的想法的原型。现在,我有几千行代码,我正在寻找 production-level 解决方案。

起初我认为我应该转向一个完整的堆栈框架,例如 or . As I was moving that direction, I started just using various parts of other frameworks as I needed them. For example, I implemented web2py's data access layer (DAL) so that I could run my application on , and now I'm looking to into using web2py's scheduler to manage jobs. Then, I began to use 作为 production-level 网络服务器。我尝试了 rocket 服务器,但我遇到了更多错误,所以我更喜欢 cherrypy 而不是 rocket。

我开始考虑重写我的代码以充分利用 web2py 的完整堆栈解决方案;然而,重写我的路由功能以完全迁移到 web2py 的时间似乎很长,而且我真的对火箭服务器不满意。

我非常喜欢 Bottle 的简单性,Bottle 使用装饰器函数将路由映射到函数的方式,以及可扩展性的理念。

我想知道与任何全栈框架相比,使用 Bottle 进行路由在性能方面是否有任何具体优势。

感谢任何人对此的建议!

根据 this benchmark 和其他人的说法,Bottle 的执行速度明显快于一些同类产品,在比较 Web 框架的性能时值得考虑这一点:

1. wheezy.web........52,245 req/sec or  19 μs/req (48x)
2. Falcon............30,195 req/sec or  33 μs/req (28x)
3. Bottle............11,977 req/sec or  83 μs/req (11x)
4. webpy..............6,950 req/sec or 144 μs/req (6x)
5. Werkzeug...........6,837 req/sec or 146 μs/req (6x)
6. pyramid............4,035 req/sec or 248 μs/req (4x)
7. Flask..............3,300 req/sec or 303 μs/req (3x)
8. Pecan..............2,881 req/sec or 347 μs/req (3x)
9. django.............1,882 req/sec or 531 μs/req (2x)
10. CherryPy..........1,090 req/sec or 917 μs/req (1x)

但请记住 your web framework may not be your bottleneck

来自 web2py 的创建者 Massimo Di Pierro:

If you have simple app with lots of models, bottle+gluino may be faster than web2py because models are executed only once and not at every request.

参考:

groups.google.com/forum/#!topic/web2py/4gB9mVPKmho