Differences

This shows you the differences between two versions of the page.

Link to this comparison view

scgc:laboratoare:06 [2020/03/30 22:21]
darius.mihai
scgc:laboratoare:06 [2021/10/27 14:08] (current)
maria.mihailescu
Line 1: Line 1:
-====== ​Laboratory 06. Load balancing and web acceleration ======+====== Load balancing and web acceleration ======
  
 ===== Lab Setup ===== ===== Lab Setup =====
  
-  * We will be using a virtual machine in the [[http://​cloud.curs.pub.ro/​|faculty'​s cloud]]. +  * We will be using a virtual machine in the [[http://​cloud.grid.pub.ro/​|faculty'​s cloud]].
-  * When creating a virtual machine follow the steps in this [[https://​cloud.curs.pub.ro/​about/​tutorial-for-students/​|tutorial]].+
   * When creating a virtual machine in the Launch Instance window:   * When creating a virtual machine in the Launch Instance window:
-    * For **Availability zone**, choose **CAMPUS**, **CI** or **hp** 
     * Select **Boot from image** in **Instance Boot Source** section     * Select **Boot from image** in **Instance Boot Source** section
     * Select **SCGC Template** in **Image Name** section     * Select **SCGC Template** in **Image Name** section
Line 53: Line 51:
 === Topology === === Topology ===
  
-{{:saisp:labs:05:​contents:​lab05-lvs.jpgceva}}+{{ :scgc:laboratoare:schema-lab6.png?​600 ​|}}
  
 The machines from the topology (the 3 KVM machines and the physical one) have the following roles: The machines from the topology (the 3 KVM machines and the physical one) have the following roles:
Line 98: Line 96:
 Using Wireshark (or tcpdump), start a capture on the br0 interface on the client machine. ​ Using Wireshark (or tcpdump), start a capture on the br0 interface on the client machine. ​
 <​code>​ <​code>​
-student@scgc:​~$ sudo tcpdump -i br0+student@scgc:​~$ sudo tcpdump -i br0 -e
 </​code>​ </​code>​
 Notice the IP and MAC addresses from: Notice the IP and MAC addresses from:
Line 233: Line 231:
  
 The above configuration means that any requests received by the Varnish server will be redirected towards the ''​elf.cs.pub.ro''​ server. The requests will be cached and the content of future requests will be directly served from the Varnish cache. The above configuration means that any requests received by the Varnish server will be redirected towards the ''​elf.cs.pub.ro''​ server. The requests will be cached and the content of future requests will be directly served from the Varnish cache.
 +
 +Modify ''/​lib/​systemd/​system/​varnish.service''​ as below to set the Varnish port on ''​80'':​
 +<​code>​
 +root@scgc-vm-1:​~#​ grep ExecStart /​lib/​systemd/​system/​varnish.service
 +
 +ExecStart=/​usr/​sbin/​varnishd -j unix,​user=vcache -F -a :80 -T localhost:​6082 -f /​etc/​varnish/​default.vcl -S /​etc/​varnish/​secret -s malloc,256m
 +</​code>​
  
 Do not forget to restart the Varnish service every time its configuration is changed: Do not forget to restart the Varnish service every time its configuration is changed:
 <​code>​ <​code>​
-student@scgc-vm-1:​~$ service varnish restart+student@scgc-vm-1:​~$ ​sudo systemctl daemon-reload 
 +student@scgc-vm-1:​~$ sudo service varnish restart
 </​code>​ </​code>​
  
Line 292: Line 298:
 </​code>​ </​code>​
  
-We will also need to change the DocumentRoot of the Apache server on ''​scgc-vm-2''​. For this, edit''/​etc/​apache2/​sites-available/​000-default.conf''​ and change the DocumentRoot from ''/​var/​www/​html''​ to ''/​var/​www''​.+We will also need to change the DocumentRoot of the Apache server on ''​scgc-vm-2''​. For this, edit''/​etc/​apache2/​sites-available/​000-default.conf''​ and change the DocumentRoot from ''/​var/​www/​html''​ to ''/​var/​www''​. Restart the ''​apache2''​ service.
  
 In order to measure the duration of the data transfer with and without Varnish, use ''​httperf''​ on the host machine in order to download the following file: http://​10.0.0.20/​data/​10M.dat for direct access or http://​10.0.0.10/​data/​10M.dat for Varnish access. In order to measure the duration of the data transfer with and without Varnish, use ''​httperf''​ on the host machine in order to download the following file: http://​10.0.0.20/​data/​10M.dat for direct access or http://​10.0.0.10/​data/​10M.dat for Varnish access.
Line 298: Line 304:
 While ''​httperf''​ is running, check with ''​htop''​ the load on both virtual machines. ​ While ''​httperf''​ is running, check with ''​htop''​ the load on both virtual machines. ​
  
-Use the ''​--uri''​ option for ''​httperf''​ to specify what page is to be accessed (in our case http://​10.0.0.20/​data/​10M.dat). Notice the difference between the Request rate parameter for the direct access and the Varnish access.+Use the ''​%%--%%uri''​ option for ''​httperf''​ to specify what page is to be accessed (in our case http://​10.0.0.20/​data/​10M.dat). Notice the difference between the Request rate parameter for the direct access and the Varnish access.
  
 ==== 5. [10p] Varnish statistics ==== ==== 5. [10p] Varnish statistics ====
Line 352: Line 358:
  
 <​note>​ <​note>​
-Follow the steps [[https://​varnish-cache.org/​docs/​3.0/tutorial/​purging.html#​bans|here]]. Use the ''​varnishadm''​ command in order to access the Varnish CLI.+Follow the steps [[https://​varnish-cache.org/​docs/​6.1/users-guide/​purging.html#​bans|here]]. Use the ''​varnishadm''​ command in order to access the Varnish CLI.
 </​note>​ </​note>​
  
Line 362: Line 368:
  
 <​note>​ <​note>​
-Follow the steps [[https://​stackoverflow.com/​questions/​10284813/​howto-control-varnish-and-a-browser-using-cache-control-max-age-header-in-a-rai/​10346942#​10346942|here]]. Restart the Varnish service after the configuration.+Follow the steps [[https://​stackoverflow.com/​questions/​10284813/​howto-control-varnish-and-a-browser-using-cache-control-max-age-header-in-a-rai/​10346942#​10346942|here]] and [[https://​varnish-cache.org/​docs/​6.1/​users-guide/​increasing-your-hitrate.html#​overriding-the-time-to-live-ttl|here]]. Restart the Varnish service after the configuration.
 </​note>​ </​note>​
  
Line 374: Line 380:
  
 <​note>​ <​note>​
-Use the [[https://​varnish-cache.org/​docs/​3.0/tutorial/advanced_backend_servers.html|Varnish documentation]].+Use the [[https://​varnish-cache.org/​docs/​6.1/users-guide/vcl-backends.html#​multiple-backends|Varnish documentation]].
 </​note>​ </​note>​
  
 ==== 9. [BONUS - 20p] Load balancing in Varnish ==== ==== 9. [BONUS - 20p] Load balancing in Varnish ====
  
-We will perform load balancing using Varnish (also called [[https://​varnish-cache.org/​docs/​3.0/tutorial/advanced_backend_servers.html#​directors|directors]] in Varnish). We will use the two web servers on ''​scgc-vm-2''​ and ''​scgc-vm-3''​ as back ends for load balancing. ​+We will perform load balancing using Varnish (also called [[https://​varnish-cache.org/​docs/​6.1/users-guide/vcl-backends.html#​directors|directors]] in Varnish). We will use the two web servers on ''​scgc-vm-2''​ and ''​scgc-vm-3''​ as back ends for load balancing. ​
  
 Configure the Varnish service on ''​scgc-vm-1''​ to perform load balancing with the two web servers using a round robin scheduler. Configure the Varnish service on ''​scgc-vm-1''​ to perform load balancing with the two web servers using a round robin scheduler.
  
 <​note>​ <​note>​
-Use these examples [[https://​stackoverflow.com/​questions/​31291374/​varnish-backend-vcc-compiler-failed/​45082602#​45082602|here]] and [[https://​varnish-cache.org/​trac/wiki/LoadBalancing|here]]. Take into account the fact that the VCL version ​is 4.0.+Use the examples ​and information ​[[https://​stackoverflow.com/​questions/​31291374/​varnish-backend-vcc-compiler-failed/​45082602#​45082602|here]] and [[https://​varnish-cache.org/​docs/6.5/reference/​vmod_directors.html#​description|here]]. Take into account the fact that the VCL version ​may differ from the one used by the varnish on your system, and the syntax may be need to be changed.
 </​note>​ </​note>​
  
 In order to verify this task, access in a browser (or wget in the CLI) 10.0.0.10, wait 2 minutes (for the Varnish cache to expire) and access it again. In order to verify this task, access in a browser (or wget in the CLI) 10.0.0.10, wait 2 minutes (for the Varnish cache to expire) and access it again.
  
scgc/laboratoare/06.1585596096.txt.gz · Last modified: 2020/03/30 22:21 by darius.mihai
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0