简体   繁体   English

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

[英]performance advantages of using bottle for routing?

I started developing a web application based on the web framework a couple of years ago. 几年前,我开始基于 Web框架开发Web应用程序。 I chose Bottle at that time because it was the easiest solution to get up and running fast, and I was just working on building a prototype of an idea I had. 当时我选择Bottle是因为它是快速启动和运行的最简单解决方案,而我当时只是在为自己的想法构建原型。 Now, I have several thousand lines of code, and I'm looking to move into production-level solution. 现在,我有几千行代码,我正在寻求进入生产级解决方案。

At first I thought that I should move to a full stack framework such as 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 例如,我实现了web2py的数据访问层(DAL),以便可以在 , and now I'm looking to into using web2py's scheduler to manage jobs. ,现在我正在考虑使用web2py的调度程序来管理作业。 Then, I began to use as a production-level webserver. 然后,我开始将用作生产级Web服务器。 I tried the rocket server, but I was getting more errors with it, so I preferred cherrypy over rocket. 我尝试了火箭服务器,但是却遇到了更多错误,因此我更喜欢Cherrypy而不是火箭。

I started looking into rewrite my code to fully use web2py's full stack solution; 我开始研究重写代码,以充分利用web2py的完整堆栈解决方案; however, the amount of time to rewrite my routing functions to fully move into web2py seems to be significant, and I really wasn't happy with the rocket server. 但是,重写我的路由功能以完全移入web2py的时间似乎很可观,我对火箭服务器真的不满意。

I really like the simplicity of Bottle, the way that Bottle uses decorator functions to map the routes to the functions, and also the philosophy of extensibility. 我真的很喜欢Bottle的简单性,Bottle使用装饰器函数将路由映射到这些函数的方式,以及可扩展性的哲学。

I want to know if there are any specific advantages in terms of performance in using Bottle to do routing, versus any of the full stack frameworks. 我想知道相对于任何完整的堆栈框架,使用Bottle进行路由在性能方面是否有任何特定优势。

I appreciate anyone's advice on this! 感谢任何人对此的建议!

According to this benchmark and others, Bottle performs significantly faster than some of its peers, which is worth taking into account when comparing web frameworks' performance: 根据该基准测试和其他基准测试 ,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)

But bear in mind that your web framework may not be your bottleneck . 但是请记住, 您的Web框架可能不是您的瓶颈

From the creator of web2py, Massimo Di Pierro: 来自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. 如果您有包含多个模型的简单应用程序,则bottle + gluino可能比web2py更快,因为模型仅执行一次,而不是在每次请求时都执行。

Reference: 参考:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM