最近使用Flask写了webserver,但是部署却成了问题
![](https://img-blog.csdnimg.cn/img_convert/590809fdcf590d152b6ef69312bddde7.png)
![](https://img-blog.csdnimg.cn/img_convert/957a9c9975caddf57b042c5ff0c8d888.png)
于是网络搜寻一番,做了一些尝试,得到以下一些方案
![](https://img-blog.csdnimg.cn/img_convert/f5302dd852a41cef63abf31bb37f37eb.png)
测试代码如下:
from flask import Flask, request, jsonify
import os
app = Flask(__name__)
@app.route('/env')
def get_env():
return jsonify({'os.env': dict(os.environ), 'req.env': str(request.environ)})
测试命令如下:
ab -n 10000 -c 100 http://localhost:xxxx/env
Windows
1.1 IIS+wfastcgi
![](https://img-blog.csdnimg.cn/img_convert/f287af39ea2f9873f920bb191b88fd21.png)
1.2 Apache+mod_wsgi
![](https://img-blog.csdnimg.cn/img_convert/f4981a63e28c454b02222ad85f5262ef.png)
1.3 waitress
![](https://img-blog.csdnimg.cn/img_convert/e958a2cb9e8af043338db9b4fdbb7c88.png)
Linux
2.1 Nginx+uwsgi
![](https://img-blog.csdnimg.cn/img_convert/27b8dfa56858925d6a5d742adb81ff6a.png)
2.2 Nginx+gunicorn
![](https://img-blog.csdnimg.cn/img_convert/03da23899e1c7b6158bc4d8b9bfd259c.png)
![](https://img-blog.csdnimg.cn/img_convert/1be00a5ce5592a5d5206f92c0c95927b.png)
2.3 ...
总的看下来,Server还是Linux下面的资源效率比较高
Ngnix+uwsgi最好用
IIS+wfastcgi最耗资源,第一次request latency很大,但是后续就很快
Ngnix作为Web server在Windows下使用也是极好的
uwsgi在windows使用需要wsl或者cygwin
waitress也不错...