I've cloned uWebSockets, wrote the following file.
#include <App.h>
#include <iostream>
int main() {
uWS::App()
.get("/*", [](auto *res, auto *req) {
res->end("Hello world!");
})
.listen(3000, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}
})
.run();
std::cout << "Failed to listen on port 3000" << std::endl;
return 0;
}
Built it with
make -C uWebSockets/uSockets
g++ -flto -O3 -Wconversion -std=c++17 -IuWebSockets/src -IuWebSockets/uSockets/src main.cpp -o main uWebSockets/uSockets/*.o -lz -lssl -lcrypto -luv
When I do a benchmark, this is what I get.
Concurrency Level: 100
Time taken for tests: 116.928 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 68000 bytes
HTML transferred: 12000 bytes
Requests per second: 8.55 [#/sec] (mean)
Time per request: 11692.844 [ms] (mean)
Time per request: 116.928 [ms] (mean, across all concurrent requests)
Transfer rate: 0.57 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 2.6 2 10
Processing: 8923 11690 921.2 11995 12012
Waiting: 0 1 1.3 0 10
Total: 8923 11693 921.7 11999 12012
Percentage of the requests served within a certain time (ms)
50% 11999
66% 12001
75% 12002
80% 12003
90% 12006
95% 12008
98% 12010
99% 12011
100% 12012 (longest request)
If I set concurrency to 1, this happens
Concurrency Level: 1
Time taken for tests: 61.655 seconds
Complete requests: 5
Failed requests: 0
Total transferred: 408 bytes
HTML transferred: 72 bytes
Requests per second: 0.08 [#/sec] (mean)
Time per request: 12330.911 [ms] (mean)
Time per request: 12330.911 [ms] (mean, across all concurrent requests)
Transfer rate: 0.01 [Kbytes/sec] received
Did I do something wrong? Did I miss something? Shouldn't it be faster?
PS. I'm running it on single thread.
I was using apache benchmark tool(ab) and it was slow, not the program. Used bomberdier and got this result
Bombarding http://127.0.0.1:3000/ with 1000000 request(s) using 5000 connection(s)
1000000 / 1000000 [===============================================================================================================================================================================================] 100.00% 316582/s 3s
Done!
Statistics Avg Stdev Max
Reqs/sec 361230.80 54733.74 520938.19
Latency 14.06ms 8.81ms 358.62ms
HTTP codes:
1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 40.48MB/s
Related
My goal is to pull the key items for my servers that we are tracking for KPIs. My plan is to run this daily via a cron job and then have it email me once a week to be able to be put in an excel sheet to grab the monthly KPIs. Here is what I have so far.
#!/bin/bash
server=server1
ports=({8400..8499})
for l in ${ports[#]}
do
echo "checking on '$l'"
sp=$(curl -k --silent "https://"$server":"$l"/server-status" | grep -E "Apache Server|Total accesses|CPU Usage|second|uptime" | sed 's/<[^>]*>//g')
echo "$l: $sp" >> kpi.tmp
grep -v '^$' kpi.tmp > kpi.out
done
The output shows like this.
8400:
8401: Apache Server Status for server1(via x.x.x.x)
Server uptime: 18 days 4 hours 49 minutes 37 seconds
Total accesses: 545 - Total Traffic: 15.2 MB
CPU Usage: u115.57 s48.17 cu0 cs0 - .0104% CPU load
.000347 requests/sec - 10 B/second - 28.6 kB/request
8402: Apache Server Status for server 1(via x.x.x.x)
Server uptime: 20 days 2 hours 20 minutes 26 seconds
Total accesses: 33 - Total Traffic: 487 kB
CPU Usage: u118.64 s49.41 cu0 cs0 - .00968% CPU load
1.9e-5 requests/sec - 0 B/second - 14.8 kB/request
8403:
8404:
8405: Apache Server Status for server1(via x.x.x.x)
Server uptime: 20 days 2 hours 20 minutes 28 seconds
Total accesses: 35 - Total Traffic: 545 kB
CPU Usage: u133.04 s57.48 cu0 cs0 - .011% CPU load
2.02e-5 requests/sec - 0 B/second - 15.6 kB/request
I am having a hard time figuring out how to filter the out put to the way i would like it. As you can see from my desired output, if it does not have any data to not put it in the file, cut some of the info out of the returned data.
I would like my output to look like this:
8401:server1(via x.x.x.x)
Server uptime: 18 days 4 hours 49 minutes 37 seconds
Total accesses: 545 - Total Traffic: 15.2 MB
CPU Usage: .0104% CPU load
.000347 requests/sec - 10 B/second - 28.6 kB/request
8402: server1(via x.x.x.x)
Server uptime: 20 days 2 hours 20 minutes 26 seconds
Total accesses: 33 - Total Traffic: 487 kB
CPU Usage: .00968% CPU load
1.9e-5 requests/sec - 0 B/second - 14.8 kB/request
8405: server1(via x.x.x.x)
Server uptime: 20 days 2 hours 20 minutes 28 seconds
Total accesses: 35 - Total Traffic: 545 kB
CPU Usage: .011% CPU load
2.02e-5 requests/sec - 0 B/second - 15.6 kB/request
In our render-loop we've always had a FPS limiter in the form of this_thread::sleep_until(Thisframe + milliseconds(1000 / 60)); but after compiling on the latest version the FPS never went above 32. So played around with the delay and found that any sleep >= 1 micro-second added 5-16ms. Anyone else noticed something similar?
// std::this_thread::sleep_for(std::chrono::nanoseconds(N));
------------------------------------------------------------
N | Max (ns) | Avg (ns) | Min (ns)
------------------------------------------------------------
1 541 532 530
10 526 526 523
100 526 526 525
1'000 5'105'253 5'035'142 4'945'181
10'000 15'849'245 15'829'724 15'751'297
100'000 15'900'155 15'884'466 15'846'923
1'000'000 15'885'041 15'877'936 15'872'767
10'000'000 15'899'457 15'884'640 15'881'723
// std::this_thread::sleep_for(std::chrono::nanoseconds(N));
------------------------------------------------------------
N | Avg (ns)
------------------------------------------------------------
3'000 17'759'597
2'500 13'888'173
2'000 10'093'005
1'500 9'393'417
1'000 4'735'949
750 2'841'692
700 5'445'165
650 4'658'634
600 2'153
500 1'789
Solved thanks to #Raymond Chen's comment on the question above:
You might be seeing this: New Thread.Sleep behaviour under Windows 10 October Update 20H2. The system used to let you get away with somebody else cranking the timer resolution via timeBeginPeriod() (usually the web browser), but now it requires you to do it yourself.
I am trying to benchmark the PostgresDB on a Redhat Linux OS VM with 4 core CPU and 16GB mem.
using this documentation https://www.postgresql.org/docs/11/pgbench.html
The Transcation can be a set of sql statements.
Below are test results
Test 1
1 Transaction is 1- Query, 1 – insert , 3 -updates
scaling factor: 10
query mode: simple
number of clients: 10
number of threads: 2
number of transactions per client: 10000
number of transactions actually processed: 100000/100000
latency average = 105.812 ms
tps = 94.507634 (including connections establishing)
tps = 94.507961 (excluding connections establishing)
scaling factor: 10
query mode: simple
number of clients: 4
number of threads: 2
number of transactions per client: 10000
number of transactions actually processed: 40000/40000
latency average = 15.667 ms
tps = 255.315579 (including connections establishing)
tps = 255.321942 (excluding connections establishing)
Test 2
1 Transaction is 1- Query , 1 – update , 1- insert
scaling factor: 10
query mode: simple
number of clients: 10
number of threads: 2
number of transactions per client: 10000
number of transactions actually processed: 100000/100000
latency average = 87.134 ms
tps = 114.766068 (including connections establishing)
tps = 114.766546 (excluding connections establishing)
scaling factor: 10
query mode: simple
number of clients: 4
number of threads: 2
number of transactions per client: 10000
number of transactions actually processed: 40000/40000
latency average = 13.067 ms
tps = 306.121787 (including connections establishing)
tps = 306.131759 (excluding connections establishing)
How do we intrepret these above results.
We are looking if postgres is capable of handling 5000TPS. 1TPS(2 simple query with primary key + 2 update(insert)).
we have few EC2 server on AWS but one one particular server we are noticing odd issues. First of all, SSH takes tens of seconds but only happens intermittently. Secondly, get request to the server also takes tens of seconds, but again it happens intermittently. We checked the stats on the server and everything looks fine. CPU average is around 7% and 25GB of free ram.
Here is the response from ss -s:
Total: 2553 (kernel 0)
TCP: 12015 (estab 2342, closed 9189, orphaned 478, synrecv 0, timewait 9188/0), ports 0
Transport Total IP IPv6
* 0 - -
RAW 0 0 0
UDP 4 4 0
TCP 2826 2765 61
INET 2830 2769 61
FRAG 0 0 0
And breakdown of current connection status:
1 established)
1 Foreign
6 LISTEN
62 LAST_ACK
136 SYN_RECV
155 CLOSING
251 FIN_WAIT1
1078 FIN_WAIT2
2197 ESTABLISHED
8229 TIME_WAIT
We have ruled out DNS issue, as it happens when we try to access it via it's hostname or the ip address. There are no load balancer in front of that server. We do use Route53 for routing purposes, but I don't see any issue with that.
Using AB to do get requests:
Run #1
Server Software: nginx/1.6.1
Server Hostname: my.hidden.com
Server Port: 443
SSL/TLS Protocol: TLSv1,DHE-RSA-AES256-SHA,2048,256
Document Path: /debug
Document Length: 43 bytes
Concurrency Level: 1
Time taken for tests: 104.415 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 162304 bytes
HTML transferred: 21500 bytes
Requests per second: 4.79 [#/sec] (mean)
Time per request: 208.829 [ms] (mean)
Time per request: 208.829 [ms] (mean, across all concurrent requests)
Transfer rate: 1.52 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 134 160 35.7 154 709
Processing: 39 49 8.2 48 127
Waiting: 39 49 8.2 48 127
Total: 178 209 38.6 203 809
Percentage of the requests served within a certain time (ms)
50% 203
66% 209
75% 212
80% 215
90% 225
95% 244
98% 273
99% 302
100% 809 (longest request)
Run #2
Server Software: nginx/1.6.1
Server Hostname: my.hidden.com
Server Port: 443
SSL/TLS Protocol: TLSv1,DHE-RSA-AES256-SHA,2048,256
Document Path: /debug
Document Length: 43 bytes
Concurrency Level: 1
Time taken for tests: 515.608 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 162284 bytes
HTML transferred: 21500 bytes
Requests per second: 0.97 [#/sec] (mean)
Time per request: 1031.216 [ms] (mean)
Time per request: 1031.216 [ms] (mean, across all concurrent requests)
Transfer rate: 0.31 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 136 980 1251.8 164 5575
Processing: 39 51 33.0 48 730
Waiting: 39 51 33.0 48 730
Total: 180 1031 1258.7 216 6306
Percentage of the requests served within a certain time (ms)
50% 216
66% 243
75% 2839
80% 2850
90% 2874
95% 2903
98% 2935
99% 2992
100% 6306 (longest request)
Run #3
Server Software: nginx/1.6.1
Server Hostname: my.hidden.com
Server Port: 443
SSL/TLS Protocol: TLSv1,DHE-RSA-AES256-SHA,2048,256
Document Path: /debug
Document Length: 43 bytes
Concurrency Level: 1
Time taken for tests: 417.639 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 162320 bytes
HTML transferred: 21500 bytes
Requests per second: 1.20 [#/sec] (mean)
Time per request: 835.279 [ms] (mean)
Time per request: 835.279 [ms] (mean, across all concurrent requests)
Transfer rate: 0.38 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 137 781 1140.0 162 5053
Processing: 38 54 56.6 49 1281
Waiting: 38 54 56.6 49 1281
Total: 179 835 1141.2 213 5104
Percentage of the requests served within a certain time (ms)
50% 213
66% 233
75% 334
80% 2835
90% 2872
95% 2915
98% 3030
99% 3137
100% 5104 (longest request)
Run #4
Server Software: nginx/1.6.1
Server Hostname: my.hidden.com
Server Port: 443
SSL/TLS Protocol: TLSv1,DHE-RSA-AES256-SHA,2048,256
Document Path: /debug
Document Length: 43 bytes
Concurrency Level: 1
Time taken for tests: 104.806 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 162250 bytes
HTML transferred: 21500 bytes
Requests per second: 4.77 [#/sec] (mean)
Time per request: 209.611 [ms] (mean)
Time per request: 209.611 [ms] (mean, across all concurrent requests)
Transfer rate: 1.51 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 135 160 13.8 157 227
Processing: 39 50 8.8 48 159
Waiting: 39 50 8.8 48 159
Total: 179 209 17.7 206 331
Percentage of the requests served within a certain time (ms)
50% 206
66% 212
75% 216
80% 219
90% 230
95% 240
98% 266
99% 275
100% 331 (longest request)
Run #5
Server Software: nginx/1.6.1
Server Hostname: my.hidden.com
Server Port: 443
SSL/TLS Protocol: TLSv1,DHE-RSA-AES256-SHA,2048,256
Document Path: /debug
Document Length: 43 bytes
Concurrency Level: 1
Time taken for tests: 110.983 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 162282 bytes
HTML transferred: 21500 bytes
Requests per second: 4.51 [#/sec] (mean)
Time per request: 221.967 [ms] (mean)
Time per request: 221.967 [ms] (mean, across all concurrent requests)
Transfer rate: 1.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 132 170 149.3 159 3460
Processing: 38 52 25.8 49 589
Waiting: 38 52 25.8 49 589
Total: 177 222 152.6 208 3532
Percentage of the requests served within a certain time (ms)
50% 208
66% 217
75% 222
80% 227
90% 240
95% 257
98% 282
99% 336
100% 3532 (longest request)
I am experimenting with launching rsync from QProcess and although it runs, it behaves differently when run from QProcess compared to running the exact same command from the command line.
Here is the command and stdout when run from QProcess
/usr/bin/rsync -atv --stats --progress --port=873 --compress-level=9 --recursive --delete --exclude="/etc/*.conf" --exclude="A*" rsync://myhost.com/haast/tmp/mysync/* /tmp/mysync/
receiving incremental file list
created directory /tmp/mysync
A
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=6/7)
B
0 100% 0.00kB/s 0:00:00 (xfer#2, to-check=5/7)
test.conf
0 100% 0.00kB/s 0:00:00 (xfer#3, to-check=4/7)
subdir/
subdir/A2
0 100% 0.00kB/s 0:00:00 (xfer#4, to-check=2/7)
subdir/C
0 100% 0.00kB/s 0:00:00 (xfer#5, to-check=1/7)
subdir/D
0 100% 0.00kB/s 0:00:00 (xfer#6, to-check=0/7)
Number of files: 7
Number of files transferred: 6
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 105
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 174
Total bytes received: 367
sent 174 bytes received 367 bytes 360.67 bytes/sec
total size is 0 speedup is 0.00
Notice that although I excluded 'A*', it still copied them! Now running the exact same command from the command line:
/usr/bin/rsync -atv --stats --progress --port=873 --compress-level=9 --recursive --delete --exclude="/etc/*.conf" --exclude="A*" rsync://myhost.com/haast/tmp/mysync/* /tmp/mysync/
receiving incremental file list
created directory /tmp/mysync
B
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=4/5)
test.conf
0 100% 0.00kB/s 0:00:00 (xfer#2, to-check=3/5)
subdir/
subdir/C
0 100% 0.00kB/s 0:00:00 (xfer#3, to-check=1/5)
subdir/D
0 100% 0.00kB/s 0:00:00 (xfer#4, to-check=0/5)
Number of files: 5
Number of files transferred: 4
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 83
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 132
Total bytes received: 273
sent 132 bytes received 273 bytes 270.00 bytes/sec
total size is 0 speedup is 0.00
Notice that now the 'A*' exclude is respected! Can someone explain why they are performing differently?
A noticed that if I removed the quotes surrounding the excludes, then the QProcess run performs correctly.
In your command-line execution, bash interpreter performs a previous substitution and remove quotes, so they are not passed to rsync arg list.
Next script shows how bash substitution is performed:
[tmp]$ cat printargs.sh
#!/bin/bash
echo $*
[tmp]$ ./printargs.sh --exclude="A*"
--exclude=A*