@@ -38,16 +38,135 @@ language plpython3u volatile;
3838```
3939
4040Benchmark
41+
42+ TL;DR, jump to [ Conclusion] ( #Conclusions )
43+
44+ Let's test 3 cases:
45+ - http, localhost
46+ - http, ya.ru (answers with redirect, empty body)
47+ - https, ya.ru
48+
4149---
4250``` sh
43- echo " select left(http_get.content, 50) from http_get('https://ya.ru');" > ~ /http_c.sql
44- echo " select left(_get, 50) from http_client._get('https://ya.ru', 2);" > ~ /http_plsh.sql
45- echo " select left(get, 50) from get('https://ya.ru');" > ~ /http_python.sql
46- echo " select left(get_python3, 50) from get_python3('https://ya.ru');" > ~ /http_python3.sql
51+ postgres@dev:~ $ # ### http, localhost
52+ postgres@dev:~ $ echo " select left(http_get.content, 50) from http_get('http://localhost/');" > ~ /local_http_c.sql
53+ postgres@dev:~ $ echo " select left(_get, 50) from http_client._get('http://localhost/', 2);" > ~ /local_http_plsh.sql
54+ postgres@dev:~ $ echo " select left(get, 50) from get('http://localhost/');" > ~ /local_http_python.sql
55+ postgres@dev:~ $ echo " select left(get_python3, 50) from get_python3('http://localhost/');" > ~ /local_http_python3.sql
56+ postgres@dev:~ $ pgbench -f ~ /local_http_c.sql -c 10 -t 100 test
57+ starting vacuum...end.
58+ transaction type: /var/lib/postgresql/local_http_c.sql
59+ scaling factor: 1
60+ query mode: simple
61+ number of clients: 10
62+ number of threads: 1
63+ number of transactions per client: 100
64+ number of transactions actually processed: 1000/1000
65+ latency average = 5.250 ms
66+ tps = 1904.627674 (including connections establishing)
67+ tps = 1915.319878 (excluding connections establishing)
68+ postgres@dev:~ $ pgbench -f ~ /local_http_plsh.sql -c 10 -t 100 test
69+ starting vacuum...end.
70+ transaction type: /var/lib/postgresql/local_http_plsh.sql
71+ scaling factor: 1
72+ query mode: simple
73+ number of clients: 10
74+ number of threads: 1
75+ number of transactions per client: 100
76+ number of transactions actually processed: 1000/1000
77+ latency average = 19.543 ms
78+ tps = 511.693475 (including connections establishing)
79+ tps = 512.487107 (excluding connections establishing)
80+ postgres@dev:~ $ pgbench -f ~ /local_http_python.sql -c 10 -t 100 test
81+ starting vacuum...end.
82+ transaction type: /var/lib/postgresql/local_http_python.sql
83+ scaling factor: 1
84+ query mode: simple
85+ number of clients: 10
86+ number of threads: 1
87+ number of transactions per client: 100
88+ number of transactions actually processed: 1000/1000
89+ latency average = 4.093 ms
90+ tps = 2443.022605 (including connections establishing)
91+ tps = 2461.714190 (excluding connections establishing)
92+ postgres@dev:~ $ pgbench -f ~ /local_http_python3.sql -c 10 -t 100 test
93+ starting vacuum...end.
94+ transaction type: /var/lib/postgresql/local_http_python3.sql
95+ scaling factor: 1
96+ query mode: simple
97+ number of clients: 10
98+ number of threads: 1
99+ number of transactions per client: 100
100+ number of transactions actually processed: 1000/1000
101+ latency average = 4.611 ms
102+ tps = 2168.910404 (including connections establishing)
103+ tps = 2183.211150 (excluding connections establishing)
104+ postgres@dev:~ $
105+ postgres@dev:~ $
106+ postgres@dev:~ $ # ### http, ya.ru
107+ postgres@dev:~ $ echo " select left(http_get.content, 50) from http_get('http://ya.ru/robots.txt');" > ~ /http_c.sql
108+ postgres@dev:~ $ echo " select left(_get, 50) from http_client._get('http://ya.ru/robots.txt', 2);" > ~ /http_plsh.sql
109+ postgres@dev:~ $ echo " select left(get, 50) from get('http://ya.ru/robots.txt');" > ~ /http_python.sql
110+ postgres@dev:~ $ echo " select left(get_python3, 50) from get_python3('http://ya.ru/robots.txt');" > ~ /http_python3.sql
111+ postgres@dev:~ $ pgbench -f ~ /http_c.sql -c 10 -t 100 test
112+ starting vacuum...end.
113+ transaction type: /var/lib/postgresql/http_c.sql
114+ scaling factor: 1
115+ query mode: simple
116+ number of clients: 10
117+ number of threads: 1
118+ number of transactions per client: 100
119+ number of transactions actually processed: 1000/1000
120+ latency average = 106.253 ms
121+ tps = 94.115185 (including connections establishing)
122+ tps = 94.141779 (excluding connections establishing)
123+ postgres@dev:~ $ pgbench -f ~ /http_plsh.sql -c 10 -t 100 test
124+ starting vacuum...end.
125+ transaction type: /var/lib/postgresql/http_plsh.sql
126+ scaling factor: 1
127+ query mode: simple
128+ number of clients: 10
129+ number of threads: 1
130+ number of transactions per client: 100
131+ number of transactions actually processed: 1000/1000
132+ latency average = 121.416 ms
133+ tps = 82.361461 (including connections establishing)
134+ tps = 82.382124 (excluding connections establishing)
135+ postgres@dev:~ $ pgbench -f ~ /http_python.sql -c 10 -t 100 test
136+ starting vacuum...end.
137+ transaction type: /var/lib/postgresql/http_python.sql
138+ scaling factor: 1
139+ query mode: simple
140+ number of clients: 10
141+ number of threads: 1
142+ number of transactions per client: 100
143+ number of transactions actually processed: 1000/1000
144+ latency average = 106.056 ms
145+ tps = 94.290085 (including connections establishing)
146+ tps = 94.317153 (excluding connections establishing)
147+ postgres@dev:~ $ pgbench -f ~ /http_python3.sql -c 10 -t 100 test
148+ starting vacuum...end.
149+ transaction type: /var/lib/postgresql/http_python3.sql
150+ scaling factor: 1
151+ query mode: simple
152+ number of clients: 10
153+ number of threads: 1
154+ number of transactions per client: 100
155+ number of transactions actually processed: 1000/1000
156+ latency average = 106.013 ms
157+ tps = 94.327689 (including connections establishing)
158+ tps = 94.352006 (excluding connections establishing)
159+ postgres@dev:~ $
47160postgres@dev:~ $
161+ postgres@dev:~ $ # ### https, ya.ru
162+ postgres@dev:~ $ echo " select left(http_get.content, 50) from http_get('https://ya.ru');" > ~ /https_c.sql
163+ postgres@dev:~ $ echo " select left(_get, 50) from http_client._get('https://ya.ru', 2);" > ~ /https_plsh.sql
164+ postgres@dev:~ $ echo " select left(get, 50) from get('https://ya.ru');" > ~ /https_python.sql
165+ postgres@dev:~ $ echo " select left(get_python3, 50) from get_python3('https://ya.ru');" > ~ /https_python3.sql
48166postgres@dev:~ $
49167postgres@dev:~ $
50- postgres@dev:~ $ pgbench -f ~ /http_c.sql -c 10 -t 100 test
168+ postgres@dev:~ $
169+ postgres@dev:~ $ pgbench -f ~ /https_c.sql -c 10 -t 100 test
51170starting vacuum...end.
52171transaction type: /var/lib/postgresql/http_c.sql
53172scaling factor: 1
@@ -59,7 +178,7 @@ number of transactions actually processed: 1000/1000
59178latency average = 235.928 ms
60179tps = 42.385814 (including connections establishing)
61180tps = 42.390860 (excluding connections establishing)
62- postgres@dev:~ $ pgbench -f ~ /http_plsh .sql -c 10 -t 100 test
181+ postgres@dev:~ $ pgbench -f ~ /https_plsh .sql -c 10 -t 100 test
63182starting vacuum...end.
64183transaction type: /var/lib/postgresql/http_plsh.sql
65184scaling factor: 1
@@ -71,7 +190,7 @@ number of transactions actually processed: 1000/1000
71190latency average = 306.951 ms
72191tps = 32.578475 (including connections establishing)
73192tps = 32.581800 (excluding connections establishing)
74- postgres@dev:~ $ pgbench -f ~ /http_python .sql -c 10 -t 100 test
193+ postgres@dev:~ $ pgbench -f ~ /https_python .sql -c 10 -t 100 test
75194starting vacuum...end.
76195transaction type: /var/lib/postgresql/http_python.sql
77196scaling factor: 1
@@ -83,7 +202,7 @@ number of transactions actually processed: 1000/1000
83202latency average = 233.735 ms
84203tps = 42.783469 (including connections establishing)
85204tps = 42.789140 (excluding connections establishing)
86- postgres@dev:~ $ pgbench -f ~ /http_python3 .sql -c 10 -t 100 test
205+ postgres@dev:~ $ pgbench -f ~ /https_python3 .sql -c 10 -t 100 test
87206starting vacuum...end.
88207transaction type: /var/lib/postgresql/http_python3.sql
89208scaling factor: 1
@@ -164,9 +283,27 @@ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
164283postgres 10812 3.3 0.1 4562784 32000 ? Ss 07:33 0:00 \_ postgres: postgres test [local] SELECT
165284```
166285
167- Conclusion
286+ Conclusions
168287---
169- Results:
288+ # Results for HTTP, localhost:
289+
290+ Method | Latency, ms | TPS
291+ ------------ | ------------- | -------------
292+ pgsql-http (C) | 5.25 | 1915
293+ plsh (curl) | 19.5 | 512
294+ plpython2u | 4.09 | 2462
295+ plpython3u | 4.61 | 2183
296+
297+ # Results for HTTP, ya.ru:
298+
299+ Method | Latency, ms | TPS
300+ ------------ | ------------- | -------------
301+ pgsql-http (C) | 106.2 | 94.14
302+ plsh (curl) | 121.4 | 82.38
303+ plpython2u | 106.0 | 94.32
304+ plpython3u | 106.0 | 94.35
305+
306+ # Results for HTTPS, ya.ru:
170307
171308Method | Latency, ms | TPS | RSS, MB
172309------------ | ------------- | ------------- | -------------
0 commit comments