Appendix A
File Sources

A.1 Benchmark Script

Listing A.1 shows the source code of the benchmarking script which was developed for this thesis. The script takes patch files (see A.2, page §) as parameters.


Listing A.1: Benchmark – benchmark.sh
 
1#!/bin/sh 
2 
3# configuration 
4 
5if [ -z "$EXTERNAL_CONFIG" ]; then 
6  PRETEST_NUMCONNS=1 
7  PRETEST_SLEEP=5 
8  NUMCONNS=1000 
9  CONCURR=100 
10  FILES="skeleton.php pres-skel.php index.php links.php" 
11fi 
12COUNT=0 
13 
14# check for correct parameter count 
15check_params () { 
16  if [ -z "$1" ]; then 
17     echo "please specify at least one patch script" 
18     exit 1 
19  fi 
20 
21  until [ -z "$1" ]; do 
22     if [ ! -e $1 ]; then 
23        echo "patch file $1 could not be found." 
24        exit 1 
25     fi 
26     shift 
27  done 
28} 
29 
30# all config files are prepared, run the test 
31run_benchmark () { 
32  LOGFILE=$1.log 
33  CHARTFILE=../$1.chart 
34  # empty files 
35  rm -f $LOGFILE $CHARTFILE 
36 
37  echo "" 
38  echo $1 
39 
40  # restart programs to have fair results (need to shut down all of them first) 
41  sudo /etc/init.d/apache2 stop 
42  sudo /etc/init.d/mysql stop 
43  sudo /etc/init.d/squid stop 
44  sudo /etc/init.d/apache2 start 
45  sudo /etc/init.d/mysql start 
46  sudo /etc/init.d/squid start 
47  sudo rm -rf /var/www/bandnews/cache/* 
48 
49  echo starting tests.. 
50 
51  # create a chart file as input for gnuplot 
52  echo $1 > $CHARTFILE 
53  echo File Requests_per_second >> $CHARTFILE 
54 
55  # test each of these files 
56  for f in $FILES; do 
57     echo -n testing $f... 
58     if [ $PRETEST_NUMCONNS -gt 0 ]; then 
59        ab -n $PRETEST_NUMCONNS -c $CONCURR http://localhost/$f > /dev/null 
60        sleep $PRETEST_SLEEP 
61     fi 
62 
63     ab -t 60 -n $NUMCONNS -c $CONCURR -H Accept-Encoding: gzip http://localhost/$f >> $LOGFILE.$f 
64     echo finished. 
65     REQSEQ=‘grep "Requests per" $LOGFILE.$f | awk ’{ print $4 }’‘ 
66 
67     cat $LOGFILE.$f >> $LOGFILE 
68     rm -f $LOGFILE.$f 
69 
70     echo $f $REQSEQ >> $CHARTFILE 
71 
72  done 
73} 
74 
75run () { 
76  let COUNT=$COUNT+1 
77  RUN=1 
78  if [ "$RUN_ONLY" ] && [ $COUNT -ne $RUN_ONLY ]; then 
79     RUN=0 
80  fi 
81  if [ $RUN -eq 1 ]; then 
82     run_benchmark $1 
83  fi 
84} 
85 
86# the config files are prepared here and start the benchmark when done 
87test_run () { 
88  # the identifier is used to 
89  local identifier=$1 
90  shift 
91  local cur=$1 
92  shift 
93 
94  if [ -n "$1" ]; then 
95     test_run ${identifier}_${cur}0 "$@" 
96  else 
97     run ${identifier}_${cur}0 
98  fi 
99 
100  sudo patch -p0 -i $cur 
101  if [ -n "$1" ]; then 
102     test_run ${identifier}_${cur}1 "$@" 
103  else 
104     run ${identifier}_${cur}1 
105  fi 
106 
107  # undo the patch 
108  sudo patch -R -p0 -i $cur 
109} 
110 
111check_params "$@" 
112# include the test parameters in the file name 
113test_run "${PRETEST_NUMCONNS}-${PRETEST_SLEEP}-${NUMCONNS}-${CONCURR}" "$@"

A.2 Patch Files


Listing A.2: Squid patch file – squid
 
1*** /etc/squid/squid.conf2005-04-12 09:13:43.965791648 +0200 
2--- squid.conf2005-04-12 09:14:07.775172072 +0200 
3*************** 
4*** 50,56 **** 
5  #visible on the internal address. 
6  # 
7  #Default: 
8! # http_port 3128 
9 
10  #  TAG: https_port 
11  # Note: This option is only available if Squid is rebuilt with the 
12--- 50,56 ---- 
13  #visible on the internal address. 
14  # 
15  #Default: 
16! http_port 80 
17 
18  #  TAG: https_port 
19  # Note: This option is only available if Squid is rebuilt with the 
20*************** 
21*** 1844,1850 **** 
22  #of your access lists to avoid potential confusion. 
23  # 
24  #Default: 
25! # http_access deny all 
26  # 
27  #Recommended minimum configuration: 
28  # 
29--- 1844,1850 ---- 
30  #of your access lists to avoid potential confusion. 
31  # 
32  #Default: 
33! http_access allow all 
34  # 
35  #Recommended minimum configuration: 
36  # 
37*************** 
38*** 2182,2188 **** 
39  #the httpd_accel_with_proxy option. 
40  # 
41  #Default: 
42! # httpd_accel_port 80 
43 
44  #  TAG: httpd_accel_single_hoston|off 
45  #If you are running Squid as an accelerator and have a single backend 
46--- 2182,2189 ---- 
47  #the httpd_accel_with_proxy option. 
48  # 
49  #Default: 
50! httpd_accel_host 127.0.0.1 
51! httpd_accel_port 81 
52 
53  #  TAG: httpd_accel_single_hoston|off 
54  #If you are running Squid as an accelerator and have a single backend 
55*************** 
56*** 2211,2217 **** 
57  #setting) 
58  # 
59  #Default: 
60! # httpd_accel_with_proxy off 
61 
62  #  TAG: httpd_accel_uses_host_headeron|off 
63  #HTTP/1.1 requests include a Host: header which is basically the 
64--- 2212,2218 ---- 
65  #setting) 
66  # 
67  #Default: 
68! httpd_accel_with_proxy on 
69 
70  #  TAG: httpd_accel_uses_host_headeron|off 
71  #HTTP/1.1 requests include a Host: header which is basically the 
72*************** 
73*** 2231,2237 **** 
74  #require the Host: header will not be properly cached. 
75  # 
76  #Default: 
77! # httpd_accel_uses_host_header off 
78 
79  #  TAG: httpd_accel_no_pmtu_discon|off 
80  #In many setups of transparently intercepting proxies Path-MTU 
81--- 2232,2238 ---- 
82  #require the Host: header will not be properly cached. 
83  # 
84  #Default: 
85! httpd_accel_uses_host_header on 
86 
87  #  TAG: httpd_accel_no_pmtu_discon|off 
88  #In many setups of transparently intercepting proxies Path-MTU 
89*** /etc/apache2/ports.conf2005-04-12 09:13:43.963791952 +0200 
90--- ports.conf2005-04-12 09:13:24.624731936 +0200 
91*************** 
92*** 1 **** 
93! Listen 80 
94--- 1 ---- 
95! Listen 81

Listing A.3: APC patch file – apc
 
1*** /etc/php4/apache2/php.ini2005-04-07 16:49:07.454799952 +0200 
2--- php.ini2005-04-07 16:50:32.645848944 +0200 
3*************** 
4*** 1077,1080 **** 
5  ; End: 
6  extension=curl.so 
7  extension=mysql.so 
8! ;extension=apc.so 
9--- 1077,1080 ---- 
10  ; End: 
11  extension=curl.so 
12  extension=mysql.so 
13! extension=apc.so

Listing A.4: MySQL Query Cache patch file – mqc
 
1*** /etc/mysql/my.cnf2005-04-07 17:16:04.555963208 +0200 
2--- my.cnf2005-04-07 17:27:01.430103160 +0200 
3*************** 
4*** 56,62 **** 
5  # Query Cache Configuration 
6  # 
7  query_cache_limit= 1048576 
8! query_cache_size           = 0 
9  query_cache_type           = 1 
10  # 
11  # Here you can see queries with especially long duration 
12--- 56,62 ---- 
13  # Query Cache Configuration 
14  # 
15  query_cache_limit= 1048576 
16! query_cache_size           = 26214400 
17  query_cache_type           = 1 
18  # 
19  # Here you can see queries with especially long duration

Listing A.5: Persistent connection patch file – persist
 
1*** /etc/php4/apache2/php.ini2005-04-24 13:15:06.384164796 +0200 
2--- php.ini2005-04-24 13:14:15.499717762 +0200 
3*************** 
4*** 595,601 **** 
5 
6  [MySQL] 
7  ; Allow or prevent persistent links. 
8! mysql.allow_persistent = Off 
9 
10  ; Maximum number of persistent links.  -1 means no limit. 
11  mysql.max_persistent = -1 
12--- 595,601 ---- 
13 
14  [MySQL] 
15  ; Allow or prevent persistent links. 
16! mysql.allow_persistent = On 
17 
18  ; Maximum number of persistent links.  -1 means no limit. 
19  mysql.max_persistent = -1 
20*** /var/www/bandnews/db/db.php2005-04-26 09:48:44.140531952 +0200 
21--- db.php2005-04-26 09:48:52.170311240 +0200 
22*************** 
23*** 12,18 **** 
24 
25  $options = array( 
26              debug => 0, 
27!            persistent => false, 
28  ); 
29 
30  $db = DB::connect($dsn, $options); 
31--- 12,18 ---- 
32 
33  $options = array( 
34              debug => 0, 
35!            persistent => true, 
36  ); 
37 
38  $db = DB::connect($dsn, $options);

Listing A.6: Smarty Caching patch file – persist
 
1*** /var/www/bandnews/inc/smarty.inc.php2005-04-26 12:54:03.921068360 +0200 
2--- smarty.inc.php2005-04-26 12:53:47.958495040 +0200 
3*************** 
4*** 10,16 **** 
5        $this->config_dir = ROOT_PATH . "/config/"; 
6        $this->register_block(’dynamic’, smarty_block_dynamic’, false); 
7        $this->register_modifier(’convert_to_class’, smarty_modifier_convert_to_class’, false); 
8! $this->caching = false; 
9        $this->cache_lifetime = -1; 
10        $this->use_sub_dirs = true; 
11        $this->security = false; 
12--- 10,16 ---- 
13        $this->config_dir = ROOT_PATH . "/config/"; 
14        $this->register_block(’dynamic’, smarty_block_dynamic’, false); 
15        $this->register_modifier(’convert_to_class’, smarty_modifier_convert_to_class’, false); 
16! $this->caching = true; 
17        $this->cache_lifetime = -1; 
18        $this->use_sub_dirs = true; 
19        $this->security = false;