Performance Evaluation when static web pages and dynamic web pages are put in the same web server and in different web servers
[Topology]
H1 (10.0.1.1)
--------(10.0.1.254) (Nginx Load Balancer) (10.0.0.254) ----------(10.0.0.1)
Web1
(10.0.2.254)----------(10.0.2.1) Web2
Scenario 1: a.jpg
and index.php (with a SQL query) are put in the web1
Scenario 2: a.jpg
is in put in the web1 and index.php are put in the web2
Minint for network
setup (test2.py)
from mininet.cli
import CLI from mininet.net import Containernet from mininet.link
import Link,TCLink,Intf from mininet.log import setLogLevel,info if '__main__' == __name__:
setLogLevel('info')
net = Containernet(link=TCLink)
h1 = net.addHost('h1', mac =
'00:00:00:00:01:01', ip="10.0.1.1/24")
h2 = net.addHost('h2')
h3 = net.addDocker('h3', mac =
'00:00:00:00:03:03', ip= '10.0.0.1/24', dimage="apache-php-mysql:v2")
h4 = net.addDocker('h4', mac =
'00:00:00:00:04:04', ip= '10.0.2.1/24', dimage="apache-php-mysql:v2")
linkopt=dict(bw=1,delay='1ms',loss=0)
linkopt1=dict(bw=10,delay='1ms',loss=0)
TCLink(h1, h2, **linkopt1)
TCLink(h2, h3, **linkopt)
TCLink(h2, h4, **linkopt)
net.build()
h2.cmd("ifconfig h2-eth0 0")
h2.cmd("ifconfig h2-eth1 0")
h2.cmd("ifconfig h2-eth2 0")
h2.cmd("ip addr
add 10.0.1.254/24 brd + dev h2-eth0")
h2.cmd("ip addr
add 10.0.0.254/24 brd + dev h2-eth1")
h2.cmd("ip addr
add 10.0.2.254/24 brd + dev h2-eth2")
h2.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")
h1.cmd("ip route add default via
10.0.1.254")
h3.cmd("ip route del default")
h3.cmd("ip route add default via
10.0.0.254")
h3.cmd("/etc/init.d/apache2
start &")
h3.cmd("/etc/init.d/mysql start &")
h4.cmd("ip route del default")
h4.cmd("ip route add default via
10.0.2.254")
h4.cmd("/etc/init.d/apache2
start &")
h4.cmd("/etc/init.d/mysql start &")
CLI(net) net.stop() |
nginx.conf (for scenario 1)
user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; #
multi_accept on; } http { ## #
Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; #
server_tokens off; #
server_names_hash_bucket_size 64; #
server_name_in_redirect off; include
/etc/nginx/mime.types; default_type application/octet-stream; server
{ listen 8080; location
~ .*\.(php|jpg)$ { add_header Cache-Control no-store; expires
-1; proxy_pass http://10.0.0.1:80; } #location
~ .*\.(php)$ { # add_header Cache-Control no-store; # expires -1; # proxy_pass http://10.0.0.1:80; #} #location
~ .*\.(jpg)$ { # add_header Cache-Control no-store; # expires -1; # proxy_pass http://10.0.2.1:80; #} } ## #
SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3,
ref: POODLE ssl_prefer_server_ciphers on; ## #
Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## #
Gzip Settings ## gzip on; gzip_disable "msie6"; #
gzip_vary on; #
gzip_proxied any; #
gzip_comp_level 6; #
gzip_buffers 16 8k; #
gzip_http_version 1.1; #
gzip_types text/plain text/css
application/json application/javascript text/xml
application/xml application/xml+rss text/javascript; ## #
Virtual Host Configs ## include
/etc/nginx/conf.d/*.conf; include
/etc/nginx/sites-enabled/*; } #mail { # #
See sample authentication script at: # #
http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # #
auth_http localhost/auth.php; # #
pop3_capabilities "TOP" "USER"; # #
imap_capabilities "IMAP4rev1"
"UIDPLUS"; # # server
{ # listen localhost:110; # protocol pop3; # proxy on; # } # # server
{ # listen localhost:143; # protocol imap; # proxy on; # } #} |
nginx.conf (for scenario 2)
user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; #
multi_accept on; } http { ## #
Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; #
server_tokens off; #
server_names_hash_bucket_size 64; #
server_name_in_redirect off; include
/etc/nginx/mime.types; default_type application/octet-stream; server
{ listen 8080; #location
~ .*\.(php|jpg)$ { # add_header Cache-Control no-store; # expires -1; # proxy_pass http://10.0.0.1:80; #} location ~ .*\.(php)$ { add_header Cache-Control no-store; expires
-1; proxy_pass http://10.0.0.1:80; } location
~ .*\.(jpg)$ { add_header Cache-Control no-store; expires
-1; proxy_pass http://10.0.2.1:80; } } ## #
SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3,
ref: POODLE ssl_prefer_server_ciphers on; ## #
Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## #
Gzip Settings ## gzip on; gzip_disable "msie6"; #
gzip_vary on; #
gzip_proxied any; #
gzip_comp_level 6; #
gzip_buffers 16 8k; #
gzip_http_version 1.1; #
gzip_types text/plain text/css
application/json application/javascript text/xml
application/xml application/xml+rss text/javascript; ## #
Virtual Host Configs ## include
/etc/nginx/conf.d/*.conf; include
/etc/nginx/sites-enabled/*; } #mail { # #
See sample authentication script at: # #
http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # #
auth_http localhost/auth.php; # #
pop3_capabilities "TOP" "USER"; # #
imap_capabilities "IMAP4rev1"
"UIDPLUS"; # # server
{ # listen localhost:110; # protocol pop3; # proxy on; # } # # server
{ # listen localhost:143; # protocol imap; # proxy on; # } #} |
(file: frequest2)
http://10.0.1.254:8080/a.jpg http://10.0.1.254:8080/index.php |
(file:run_test2.sh)
siege -c 5 -r 10 -f ./frequest2 -b |
Execution
1.run the mininet script
2. open a terminal for h2 and run the nginx load balancer
3. open a terminal for h1 and run the performance evaluation
4. change the nginx.conf and run the evaluation again.
From the above results, we can see that when a static webpage and a dynamic webpage put in different web servers can get better performance (110sec vs. 120vs) in our case.
Dr. Chih-Heng Ke (smallko@gmail.com)
Department of Computer Science and Information
Engineering,
National Quemoy University, Kinmen, Taiwan.