Skip to content

Commit cf65d0a

Browse files
committed
Move to gevent from Flask
gevent is a more suitable framework for high performance throughput and benchmarking. This performs around 2x faster than Flask with debug=False when tested on loopback with hey on Kube Signed-off-by: Alex Ellis (VMware) <[email protected]>
1 parent d276066 commit cf65d0a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

template/python3-flask/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ RUN apk --no-cache add curl \
77
&& chmod +x /usr/bin/fwatchdog \
88
&& apk del curl --no-cache
99

10+
RUN apk --no-cache add musl-dev gcc make
11+
1012
WORKDIR /root/
1113

1214
COPY requirements.txt .
@@ -23,6 +25,7 @@ WORKDIR /root/
2325
COPY function function
2426

2527
ENV fprocess="python index.py"
28+
2629
ENV cgi_headers="true"
2730
ENV mode="http"
2831
ENV upstream_url="http://127.0.0.1:5000"

template/python3-flask/index.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from flask import Flask, request
55
from function import handler
6+
#from gevent.wsgi import WSGIServer
7+
from gevent.pywsgi import WSGIServer
68

79
app = Flask(__name__)
810

@@ -12,4 +14,7 @@ def main_route():
1214
return ret
1315

1416
if __name__ == '__main__':
15-
app.run(host='0.0.0.0', port=5000, debug=False)
17+
#app.run(host='0.0.0.0', port=5000, debug=False)
18+
19+
http_server = WSGIServer(('', 5000), app)
20+
http_server.serve_forever()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
flask
2+
gevent
23

0 commit comments

Comments
 (0)