Viola是一个轻量级和高效的wsgi服务器。

viola的Python项目详细描述


中提琴

build statuspip versionlicense

中文

viola是一个wsgi服务器。轻量级且高效,除了python标准库之外没有其他依赖项。通常与nginx一起使用。我用viola构建blog,用nginx处理静态资源,用viola处理动态内容。你也可以这样做或使用viola作为学习网络编程的参考。

目录:

功能

  • [X]基于事件驱动模型的单线程、非阻塞I/O
  • [X]简化了服务器端的wsgi协议
  • [X]第二定时器
  • [X]http get方法的解析器

要求

  • Python
    • cpython=3.6
  • 平台
    • Linux和内核>;=2.6

安装

包上载于PyPI

您可以使用pip安装:

$ pip install viola

示例

使用中提琴如下:

fromviola.core.event_loopimportEventLoopfromviola.wsgi.serverimportWSGIServerfromviola.core.schedulerimportScheduler# Import your APP in hereif__name__=='__main__':event_loop=EventLoop.instance(Scheduler.instance())server=WSGIServer(event_loop)server.set_wsgi_app(APP)# For example the APP argument is flask or bottleserver.bind(host=HOST,port=PORT)# Replace your real host and real portserver.listen()server.start(1)event_loop.start()

就这些。

性能

以下nginx是一个wsgi服务器的代理。nginx配置是一致的,wsgi服务器响应一个字符串“hello world”。

CPU: 2.7 GHz Intel Core i5
MEM: 8 GB 1867 MHz DDR3
ab -n 10000 -c 500 http://10.211.55.25/

nginx+tornado(tornado同时作为wsgi服务器和web框架)。龙卷风开始一个过程)

$ ab -n 10000 -c 500 http://10.211.55.25/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.211.55.25 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.15.8
Server Hostname:        10.211.55.25
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      500
Time taken for tests:   31.186 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2190000 bytes
HTML transferred:       120000 bytes
Requests per second:    320.65 [#/sec] (mean)
Time per request:       1559.316 [ms] (mean)
Time per request:       3.119 [ms] (mean, across all concurrent requests)
Transfer rate:          68.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.3      0      20
Processing:    13  797 3684.3    121   31161
Waiting:        9  797 3684.3    121   31161
Total:         28  798 3686.2    122   31170

Percentage of the requests served within a certain time (ms)
  50%    122
  66%    132
  75%    141
  80%    149
  90%    168
  95%   1002
  98%  15038
  99%  15135
 100%  31170 (longest request)

nginx+gunicorn(工人4,默认使用同步模式)+瓶子

$ ab -n 10000 -c 500 http://10.211.55.25/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.211.55.25 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.15.8
Server Hostname:        10.211.55.25
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      500
Time taken for tests:   15.113 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      1690000 bytes
HTML transferred:       120000 bytes
Requests per second:    661.67 [#/sec] (mean)
Time per request:       755.662 [ms] (mean)
Time per request:       1.511 [ms] (mean, across all concurrent requests)
Transfer rate:          109.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.0      0      21
Processing:    13  407 1826.5     57   15085
Waiting:       13  407 1826.5     57   15085
Total:         30  408 1827.8     57   15091

Percentage of the requests served within a certain time (ms)
  50%     57
  66%     62
  75%     81
  80%     91
  90%    120
  95%   1063
  98%   7065
  99%  15056
 100%  15091 (longest request)

nginx+viola(viola开始一个过程)+瓶子

$ ab -n 10000 -c 500 http://10.211.55.25/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.211.55.25 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.15.8
Server Hostname:        10.211.55.25
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      500
Time taken for tests:   3.090 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      1290000 bytes
HTML transferred:       120000 bytes
Requests per second:    3236.64 [#/sec] (mean)
Time per request:       154.481 [ms] (mean)
Time per request:       0.309 [ms] (mean, across all concurrent requests)
Transfer rate:          407.74 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.0      0      22
Processing:     1  133 532.0     23    3042
Waiting:        1  133 532.0     23    3042
Total:          9  134 533.3     24    3053

Percentage of the requests served within a certain time (ms)
  50%     24
  66%     28
  75%     35
  80%     39
  90%     50
  95%     67
  98%   3016
  99%   3037
 100%   3053 (longest request)

待办事项

  • []改进了服务器端的wsgi协议
  • []毫秒计时器
  • []http post方法等
  • []改进的响应模块
  • []为更多平台提供事件驱动
  • []提高覆盖率

参考

许可证

维奥拉是根据麻省理工学院的执照被释放的。有关详细信息,请参见LICENSE

贡献

感谢您对维奥拉的贡献感兴趣,您的帮助和贡献是非常宝贵的。

您可以提交问题和请求,请在提交请求前提交问题。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何告诉上下文。搜索(…)。hasMore()返回false,而不是抛出PartialResultException   java SeekBar RGB选择器不断停止   java使用propertyplaceholder处理jar中的属性文件   java使用Javax注释和Hibernate处理三元关系   java为什么我的位集大小为0?   java与Xloggc一起使用相对路径   java无法单击ArrayList项   java Apache Camel jms inOut bean绑定返回类型   java活动不起作用   java如何在代码中确定Android设备的纹理内存限制?   java Wicket AjaxSelfUpdatengTimerBehavior在使用2个浏览器标记打开时刷新整个页面   java如何使用swingworker从一个类到另一个类使用按钮   nio Azure通知中心java。网ConnectException:连接超时:无进一步信息   java Soap客户端:SAAJ0514无法从给定源创建信封,因为根元素未命名为信封   无法访问对象子类的变量?(Java/Android)   java需要BlueJ帮助:方法调用数组   linux您可以使用Applet Java运行shell脚本吗?   java startActivity不工作2   spring boot如何在itext pdf java中动态更改水印值