// ============================================================================ // Benchmark framework used to test the G-WAN Web App. Server http://gwan.ch/ // ---------------------------------------------------------------------------- // bench.c: invoke Apache Benchmark (ab) for a concurrency range and collect // results in a file suitable for OpenOffice.org SpreadSheet charting. // // 100.html is a 100-byte file initially designed to avoid testing the // kernel (I wanted to compare the CPU efficiency of each Web server). // // The ITER define can be set to 1 to speed up a test but in that case // values are not as reliable as when using more rounds (and using a // low ITER[ations] value usually gives lower performances). // // G-WAN for Windows upgrades Registry system values to remove some // artificial limits (original values are just renamed), you need to // reboot after you run G-WAN for the first time to load those values. // Rebooting for each test has an effect on Windows (you are faster), // like testing after IIS 7.0 was tested (you are even faster), and // the Windows Vista 64-bit TCP/IP stack is 10% faster (for all) if // ASP.Net is *not* installed. // // Linux Ubuntu 8.1 did not show those boot-related side-effects but // here also I have had to tune the system to run the test: // // sudo gedit /etc/security/limits.conf // * soft nofile = 200000 // * hard nofile = 200000 // // sudo gedit /etc/sysctl.conf // fs.file-max = 200000 // net.ipv4.ip_local_port_range = 1024 65535 // net.ipv4.ip_forward = 0 // net.ipv4.conf.default.rp_filter = 1 // net.core.rmem_max = 262143 // net.core.rmem_default = 262143 // net.core.netdev_max_backlog = 32768 // net.core.somaxconn = 2048 // net.ipv4.tcp_rmem = 4096 131072 262143 // net.ipv4.tcp_wmem = 4096 131072 262143 // net.ipv4.tcp_sack = 0 // net.ipv4.tcp_dsack = 0 // net.ipv4.tcp_fack = 0 // net.ipv4.tcp_fin_timeout = 30 // net.ipv4.tcp_orphan_retries = 0 // net.ipv4.tcp_keepalive_time = 120 // net.ipv4.tcp_keepalive_probes = 3 // net.ipv4.tcp_keepalive_intvl = 10 // net.ipv4.tcp_retries2 = 15 // net.ipv4.tcp_retries1 = 3 // net.ipv4.tcp_synack_retries = 5 // net.ipv4.tcp_syn_retries = 5 // net.ipv4.tcp_timestamps = 0 // net.ipv4.tcp_max_tw_buckets = 32768 // net.ipv4.tcp_moderate_rcvbuf = 1 // kernel.sysrq = 0 // kernel.shmmax = 67108864 // // As I was not able to make the 'open files limit' persist for G-WAN // after a reboot, G-WAN attemps to setup this to an 'optimal' value // depending on the amount of RAM available on your system: // // fd_max=(256*(totalram/4)<200000)?256*(total/4):1000000; // // For this to work, you have to run gwan as 'root': // // ~/Desktop/gwan# gwan -b // // The -b flag (optional) disables G-WAN's denial of service shield, // this gives better raw performances (mandatory under Windows). // // NB: this test was 15-20% faster (for all) when ab was running on a // computer and the Web server on another machine via a gigabit // LAN (but absolute performances were less interesting me than // relative server performances). // // This program is left in the public domain. // http://trustleap.ch/ // // ============================================================================ #include #include #include #include #include #ifdef _WIN32 # include # include #else #define Sleep(v) sleep(v/1000) #define strstri strcasestr #endif // ---------------------------------------------------------------------------- #define FROM 0 // the range to cover (0-1000 concurrent clients) #define TO 1000 // the range to cover (0-1000 concurrent clients) #define ITER 10 // the number of iterations (worse, average, best) // ---------------------------------------------------------------------------- int main(int argc, char *argv[]) { int i, j, nbr, best, worse, aver; char str[256], buff[4000]; FILE *f, *fo=fopen("test.txt", "w+b"); for(i=FROM; i<=TO; i+=10) { sprintf(str, "ab -n 1000000 -c %u -k -t 1" // KEEP-ALIVES // sprintf(str, "ab -n 1000000 -c %u -t 1" // NO Keep-Alives // ---- Static files ---------------------------------------------------------- // " \"http://192.168.200.88:8080/1000.html\"" // " \"http://192.168.200.88:8080/100.html\"" // ---- Apache/PHP ------------------------------------------------------------ // " \"http://192.168.200.88:80/hello.php\"" // " \"http://192.168.200.88:80/loan.php?name=Eva&amount=10000&rate=3.5&term=1\"" // " \"http://192.168.200.88:80/loan.php?name=Eva&amount=10000&rate=3.5&term=10\"" // " \"http://192.168.200.88:80/loan.php?name=Eva&amount=10000&rate=3.5&term=50\"" // " \"http://192.168.200.88:80/loan.php?name=Eva&amount=10000&rate=3.5&term=90\"" // ---- GlassFish/Java ------------------------------------------------------- // " \"http://192.168.200.88:8080/hello\"" // " \"http://192.168.200.88:8080/loan/?name=Eva&amount=10000&rate=3.5&term=1\"" // " \"http://192.168.200.88:8080/loan/?name=Eva&amount=10000&rate=3.5&term=10\"" // " \"http://192.168.200.88:8080/loan/?name=Eva&amount=10000&rate=3.5&term=50\"" // " \"http://192.168.200.88:8080/loan/?name=Eva&amount=10000&rate=3.5&term=90\"" // ---- G-WAN/C --------------------------------------------------------------- // " \"http://192.168.200.88:8080/csp?hello\"" // " \"http://192.168.200.88:8080/csp?hellox&name=Eva\"" // " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=1\"" // " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=10\"" // " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=50\"" // " \"http://192.168.200.88:8080/csp?loan&name=Eva&amount=10000&rate=3.5&term=90\"" // ---- IIS/ASP.Net C# -------------------------------------------------------- // " \"http://192.168.200.88:80/asp/hello.aspx"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3.5&term=1\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3.5&term=10\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3.5&term=50\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3.5&term=90\"" // depending on your locale settings you will need to use a comma or a point for 'rate' // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3,5&term=1\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3,5&term=10\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3,5&term=50\"" // " \"http://192.168.200.88:80/asp/loan.aspx?name=Eva&amount=10000&rate=3,5&term=90\"" " > ab.txt", i?i:1); for(best=0, aver=0, worse=0xffff0, j=0; j='0'&&*p<='9') p++; *p=0; nbr=atol(n); } else puts("* Requ. per sec. not found!"); } if(bestnbr) worse=nbr; aver+=nbr; } aver/=ITER; // display data for convenience and save data on disk printf("##### %4u,%5u,%5u,%5u #####\n", i, worse, aver, best); fprintf(fo, "%u,%u,%u,%u\n", i, worse, aver, best); fflush(fo); // in case we interrupt the test } fclose(fo); return 0; } // ============================================================================ // End of Source Code // ============================================================================