Created
October 2, 2011 13:21
-
-
Save JakubOboza/1257446 to your computer and use it in GitHub Desktop.
How Fat is libevent ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14:08 kuba@MacBook-Jakub-Oboza:~% ab -c 10 -n 15000 http://127.0.0.1:8081/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient) | |
Completed 1500 requests | |
Completed 3000 requests | |
Completed 4500 requests | |
Completed 6000 requests | |
Completed 7500 requests | |
Completed 9000 requests | |
Completed 10500 requests | |
Completed 12000 requests | |
Completed 13500 requests | |
Completed 15000 requests | |
Finished 15000 requests | |
Server Software: | |
Server Hostname: 127.0.0.1 | |
Server Port: 8081 | |
Document Path: / | |
Document Length: 23 bytes | |
Concurrency Level: 10 | |
Time taken for tests: 2.659 seconds | |
Complete requests: 15000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 1365637 bytes | |
HTML transferred: 345161 bytes | |
Requests per second: 5642.12 [#/sec] (mean) | |
Time per request: 1.772 [ms] (mean) | |
Time per request: 0.177 [ms] (mean, across all concurrent requests) | |
Transfer rate: 501.63 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 0 0.6 0 12 | |
Processing: 0 1 1.5 1 22 | |
Waiting: 0 1 1.4 1 22 | |
Total: 1 2 1.6 1 22 | |
Percentage of the requests served within a certain time (ms) | |
50% 1 | |
66% 1 | |
75% 2 | |
80% 2 | |
90% 3 | |
95% 5 | |
98% 7 | |
99% 9 | |
100% 22 (longest request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*just the responsiveness of libevent on my old 2 core proccessor is awesome. 5k req/sec | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Heavy loaded CPU with flash video while doing test ;) | |
14:34 kuba@MacBook-Jakub-Oboza:~% httperf --server 127.0.0.1 --num-conn 10000 --num-call 10 --rate 300 --timeout 5 --port 8081 | |
httperf --timeout=5 --client=0/1 --server=127.0.0.1 --port=8081 --uri=/ --rate=300 --send-buffer=4096 --recv-buffer=16384 --num-conns=10000 --num-calls=10 | |
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE | |
Maximum connect burst length: 7 | |
Total: connections 10000 requests 100000 replies 100000 test-duration 33.332 s | |
Connection rate: 300.0 conn/s (3.3 ms/conn, <=25 concurrent connections) | |
Connection time [ms]: min 0.8 avg 2.5 max 82.6 median 0.5 stddev 5.2 | |
Connection time [ms]: connect 0.1 | |
Connection length [replies/conn]: 10.000 | |
Request rate: 3000.1 req/s (0.3 ms/req) | |
Request size [B]: 62.0 | |
Reply rate [replies/s]: min 2998.2 avg 2999.9 max 3000.2 stddev 0.8 (6 samples) | |
Reply time [ms]: response 0.2 transfer 0.0 | |
Reply size [B]: header 125.0 content 23.0 footer 0.0 (total 148.0) | |
Reply status: 1xx=0 2xx=100000 3xx=0 4xx=0 5xx=0 | |
CPU time [s]: user 7.48 system 23.49 (user 22.4% system 70.5% total 92.9%) | |
Net I/O: 615.3 KB/s (5.0*10^6 bps) | |
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0 | |
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <event.h> | |
#include <evhttp.h> | |
void generic_request_handler(struct evhttp_request *req, void *arg) | |
{ | |
struct evbuffer *returnbuffer = evbuffer_new(); | |
evbuffer_add_printf(returnbuffer, "Thanks for the request!"); | |
evhttp_send_reply(req, HTTP_OK, "Client", returnbuffer); | |
evbuffer_free(returnbuffer); | |
return; | |
} | |
int main(int argc, char **argv) | |
{ | |
short http_port = 8081; | |
char *http_addr = "127.0.0.1"; | |
struct evhttp *http_server = NULL; | |
event_init(); | |
http_server = evhttp_start(http_addr, http_port); | |
evhttp_set_gencb(http_server, generic_request_handler, NULL); | |
fprintf(stderr, "Server started on port %d\n", http_port); | |
event_dispatch(); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment