-
Notifications
You must be signed in to change notification settings - Fork 4
/
notes
170 lines (129 loc) · 4.3 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
docker build -f Dockerfile -t fastapi_test:latest .
docker run -p 127.0.0.1:8000:8000 --cpus=2 -it fastapi_test:latest
$ ./run_ab.sh
Test 1
Requests per second: 1022.90 [#/sec] (mean)
Time per request: 97.762 [ms] (mean)
Test 2
Requests per second: 1026.24 [#/sec] (mean)
Time per request: 97.443 [ms] (mean)
Test 3
Requests per second: 923.71 [#/sec] (mean)
Time per request: 108.260 [ms] (mean)
docker run -p 127.0.0.1:8000:8000 --cpus=2 -e MIDDLEWARE=laod fastapi_test:latest
$ curl -I 127.0.0.1:8000
HTTP/1.1 404 Not Found
date: Sun, 01 May 2022 12:29:56 GMT
server: uvicorn
content-length: 22
content-type: application/json
x-process-time: 0.0005738735198974609
$ ./run_ab.sh
Test 1
Requests per second: 686.21 [#/sec] (mean)
Time per request: 145.728 [ms] (mean)
Test 2
Requests per second: 689.44 [#/sec] (mean)
Time per request: 145.044 [ms] (mean)
Test 3
Requests per second: 674.90 [#/sec] (mean)
Time per request: 148.170 [ms] (mean)
docker run -p 127.0.0.1:8000:8000 --cpus=2 -e MIDDLEWARE=laod -e DUMMYMIDDLEWARE=load fastapi_test:latest
$ curl -I 127.0.0.1:8000
HTTP/1.1 404 Not Found
date: Sun, 01 May 2022 12:48:19 GMT
server: uvicorn
content-length: 22
content-type: application/json
x-process-time: 0.00045299530029296875
custom: Example
$ ./run_ab.sh
Test 1
Requests per second: 481.74 [#/sec] (mean)
Time per request: 207.580 [ms] (mean)
Test 2
Requests per second: 495.27 [#/sec] (mean)
Time per request: 201.910 [ms] (mean)
Test 3
Requests per second: 485.43 [#/sec] (mean)
Time per request: 206.005 [ms] (mean)
https://github.com/encode/starlette/issues/1012#issuecomment-673461832
https://github.com/encode/starlette/issues/919#issuecomment-672908610
docker run -p 127.0.0.1:8000:8000 -e STARLETTEPROCESSTIMEIDDLEWARE=load --cpus=2 -it fastapi_opt
$ curl -I 127.0.0.1:8000
HTTP/1.1 404 Not Found
date: Thu, 05 May 2022 13:14:03 GMT
server: uvicorn
content-length: 22
content-type: application/json
x-process-time: 0.00010013580322265625
$ ./run_ab.sh
Test 1
Requests per second: 1078.18 [#/sec] (mean)
Time per request: 92.749 [ms] (mean)
Test 2
Requests per second: 1069.59 [#/sec] (mean)
Time per request: 93.494 [ms] (mean)
Test 3
Requests per second: 971.28 [#/sec] (mean)
Time per request: 102.957 [ms] (mean)
docker run -p 127.0.0.1:8000:8000 -e STARLETTEPROCESSTIMEIDDLEWARE=load -e STARLETTECUSTOMHEADERMIDDLEWARE=load --cpus=2 -it fastapi_opt
$ curl -I 127.0.0.1:8000
HTTP/1.1 404 Not Found
date: Thu, 05 May 2022 18:44:08 GMT
server: uvicorn
content-length: 22
content-type: application/json
x-process-time: 0.0002040863037109375
custom: Example
$ ./run_ab.sh
Test 1
Requests per second: 878.93 [#/sec] (mean)
Time per request: 113.774 [ms] (mean)
Test 2
Requests per second: 941.79 [#/sec] (mean)
Time per request: 106.180 [ms] (mean)
Test 3
Requests per second: 974.65 [#/sec] (mean)
Time per request: 102.600 [ms] (mean)
CPU: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
https://github.com/pages-themes/tactile
https://phuston.github.io/patrickandfrantonarethebestninjas/howto
https://jekyllrb.com/docs/
# Different json response
# workers / threads
# sync / async
# connection pool size
# keepalive - nginy - gunicorn
https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py
# test tools - APIFuzzeer, https://schemathesis.readthedocs.io/en/stable/index.html
Sync:
T1 T2 T3 T4 T5
W1 953, 1099, 1106, 1113, 1095
W2 1502, 1552, 1522, 1517, 1540
W3 1246, 1466, 1454, 1439, 1412
W4 1375, 1284, 1349, 1308, 1321
W5 1283, 1297, 1298, 1339, 1342
Async
T1 T2 T3 T4 T5
W1 2011, 2029, 1793, 2215, 1509
W2 2026, 1595, 2062, 1890, 1917
W3 2300, 2146, 1978, 1604, 1911
W4 2026, 1929, 1523, 2218, 2175
W5 2051, 2178, 2186, 2147, 2055
Sync - big response
T1 T2 T3 T4 T5
W1 436, 1561, 1493, 1485, 1500
W2 2260, 1677, 1739, 2372, 2474
W3 475, 2300, 1735, 1749, 2381
W4 2152, 2290, 2180, 2182, 2182
W5 1443, 1523, 2134, 2081, 2049
Async - big response
T1 T2 T3 T4 T5
W1 981, 2034, 1524, 1459, 903
W2 1081, 2365, 1763, 1069, 2406
W3 2304, 1609, 2129, 2263, 927
W4 2101, 2188, 1563, 2190, 1649
W5 940, 1419, 1901, 2130, 1986
https://davidjpfeiffer.github.io/chart-js-examples/
https://stackoverflow.com/a/65049620