- have just set up your blog in middle of nowhere. No one knows your site yet.
- are a layman developer
- don't have a marketing team
- have no plans to advertise your site
- on server log, the only visitors are Google / bing / Yandex / 360Spider / *bot*
You should prepare for reddit hug if you
- have nothing else to do
- want to go hardcore
- are a masochist developer hosting a server at home with a regular PC
So, how to survive reddit hug?
var http = require('http');
var i = 0;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
console.log( "here: " + ( i ++ ) );
}).listen( 12345, "0.0.0.0" );
console.log( 'Server running at http://0.0.0.0:12345/' );
// shared resources
var cache = { "index": "<html> My home page </html>" };
// Connections begins here
for( var i = 0; i < 10000; i ++ )
{
console.log( Cache[ "index" ] );
}
$ ab -r -k -c 1000 -n 10000 https://blog.astropenguin.net/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking blog.astropenguin.net (be patient)
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
SSL handshake failed (5).
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: Apache/2.4.10
Server Hostname: blog.astropenguin.net
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256
Document Path: /
Document Length: 18236 bytes
Concurrency Level: 1000
Time taken for tests: 100.228 seconds
Complete requests: 10000
Failed requests: 7516
(Connect: 0, Receive: 0, Length: 7516, Exceptions: 0)
Non-2xx responses: 7288
Keep-Alive requests: 2616
Total transferred: 50230448 bytes
HTML transferred: 48165552 bytes
Requests per second: 99.77 [#/sec] (mean)
Time per request: 10022.805 [ms] (mean)
Time per request: 10.023 [ms] (mean, across all concurrent requests)
Transfer rate: 489.42 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1433 9469.1 215 92580
Processing: 15 1363 3857.1 53 28077
Waiting: 0 1037 3076.4 50 25263
Total: 15 2795 10174.3 300 93579
Percentage of the requests served within a certain time (ms)
50% 300
66% 399
75% 1069
80% 1811
90% 5878
95% 11942
98% 24983
99% 75332
100% 93579 (longest request)
$ ab -r -k -c 1000 -n 10000 https://blog.astropenguin.net/
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking blog.astropenguin.net (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
SSL handshake failed (5).
Completed 10000 requests
Finished 10000 requests
Server Software: Apache/2.4.10
Server Hostname: blog.astropenguin.net
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256
Document Path: /
Document Length: 18232 bytes
Concurrency Level: 1000
Time taken for tests: 26.143 seconds
Complete requests: 10000
Failed requests: 1
(Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Keep-Alive requests: 9
Total transferred: 183381454 bytes
HTML transferred: 182309960 bytes
Requests per second: 382.51 [#/sec] (mean)
Time per request: 2614.335 [ms] (mean)
Time per request: 2.614 [ms] (mean, across all concurrent requests)
Transfer rate: 6850.06 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1452 2228.0 646 17026
Processing: 18 138 104.3 143 5552
Waiting: 15 74 55.2 68 1810
Total: 18 1590 2229.4 774 17245
Percentage of the requests served within a certain time (ms)
50% 774
66% 1206
75% 1556
80% 1670
90% 3576
95% 6520
98% 8756
99% 13835
100% 17245 (longest request)