[英]Why is pypy flask aplication slower than cpython?
I have a flask application (app.py) which returns a string,我有一个 flask 应用程序 (app.py),它返回一个字符串,
from flask import Flask
import os
app = Flask(__name__)
@app.route("/")
def hello():
return "Flask inside Docker!!"
if __name__ == "__main__":
port = int(os.environ.get("PORT", 6000))
app.run(debug=True,host='0.0.0.0',port=port)
I ran this application using the below dockerfile content, which gave me the throughput of 320/sec我使用以下 dockerfile 内容运行此应用程序,这给了我320/秒的吞吐量
FROM opensuse/leap:15.3
RUN zypper -n install python3 python3-pip python3-Flask
COPY . /app
WORKDIR /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
However with pypy3, I got only 200/sec throughput , the docker file is given below.但是使用 pypy3,我只有 200/sec 吞吐量,下面给出了 docker 文件。
FROM opensuse/leap:15.3
FROM pypy:3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["pypy3"]
CMD ["app.py"]
where requirements.txt contains only "flask".其中 requirements.txt 仅包含“烧瓶”。
What could be the reason for this performance degradation?这种性能下降的原因可能是什么?
Two things comes to mind.我想到了两件事。
Brushing aside the fact that PyPy might really be intrinsically slower for your case, there are some factors that could be making it unnecessarily slower:撇开PyPy本质上对您的情况来说可能确实较慢这一事实,有一些因素可能会使其不必要地变慢:
PyPy
a lot more than CPython
.CPython
相比,性能分析PyPy
变慢很多。 A nightly build will probably be faster too, as there are many improvements relative to 1.5.每晚构建可能也会更快,因为相对于 1.5 有很多改进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.