SlideShare a Scribd company logo
1 of 98
Download to read offline
Thijs	
  Feryn
Evangelist
+32	
  (0)9	
  218	
  79	
  06
thijs@combellgroup.com

PHP	
  UK	
  Conference
Friday	
  February	
  25th	
  2011
London,	
  UK




   Varnish	
  in	
  ac*on
About	
  me




 I’m	
  an	
  evangelist	
  at	
  Combell
About	
  me




 I’m	
  a	
  board	
  member	
  at	
  PHPBenelux
I	
  live	
  in	
  the	
  wonderful	
  city	
  of	
  Bruges
      MPBecker	
  -­‐	
  Bruges	
  by	
  Night	
  hZp://www.flickr.com/photos/galverson2/3715965933
Follow	
  me	
  on	
  TwiZer:	
  @ThijsFeryn

Give	
  me	
  feedback:	
  hZp://joind.in/2521

  Read	
  my	
  blog:	
  hZp://blog.feryn.eu
Varnish
Varnish




          Reverse	
  proxy?

          Caching	
  proxy?

          Loadbalancer?
Varnish




          HTTP	
  accelerator	
  !
Caching
Caching




     Storing	
  computed	
  data	
  for	
  faster	
  
        serving	
  of	
  future	
  requests
Basically




       Pueng	
  stuff	
  in	
  boxes	
  for	
  later	
  use
Why?
Protect	
  your	
  server
In	
  the	
  beginning	
  there	
  was	
  ...
Browser	
  cache
Browser	
  cache:	
  expira*on




     Expires:	
  Sun,	
  25	
  Jun	
  2006	
  14:57:12	
  

        Cache-­‐Control:	
  max-­‐age=86400,	
  
                 must-­‐revalidate
Browser	
  cache:	
  valida*on



 Last-­‐Modified:	
  Sun,	
  25	
  Jun	
  2006	
  14:57:12	
  GMT

            ETag:	
  “686897696a7c876b7e”
Browser	
  cache:	
  valida*on



 Last-­‐Modified:	
  Sun,	
  25	
  Jun	
  2006	
  14:57:12	
  GMT

             ETag:	
  “686897696a7c876b7e”


     Compared	
  with	
  the	
  “If-­‐None-­‐Match”	
  header.	
  
     Throws	
  “HTTP/1.0	
  304	
  Not	
  Modified”	
  accordingly
Browser	
  cache:	
  in	
  PHP
Browser	
  cache:	
  in	
  PHP


<?php
$seconds = 10;
$expires = gmdate('D, j M Y H:i:s T', time() + $seconds);
header("Expires: $expires");
header("Cache-Control: max-age=$seconds, must-revalidate");
?>
<ul>
    <li>Current date/time: <?= gmdate('D, j M Y H:i:s T')?></li>
    <li>Expires: <?= $expires ?></li>
    <li>Cache-control: <?= $seconds?> seconds</li>
</ul>
Browser	
  cache:	
  in	
  Apache
Browser	
  cache:	
  in	
  Apache



ExpiresAc*ve	
  on
ExpiresDefault	
  "access	
  plus	
  1	
  month"
ExpiresDefault	
  "now	
  plus	
  4	
  weeks"
ExpiresDefault	
  "modifica*on	
  plus	
  30	
  days"
ExpiresByType	
  text/html	
  "access	
  plus	
  1	
  month	
  15	
  days	
  2	
  
hours"
Browser	
  cache	
  is	
  your	
  friend	
  !
Problems	
  with	
  browser	
  cache
Problems	
  with	
  browser	
  cache


                 Mul*ple	
  standards

           Can	
  be	
  ignored	
  by	
  browser

                      Force	
  refresh

                   Cache	
  per	
  client
Solu*ons:	
  use	
  a	
  caching/reverse	
  proxy!



                    Use	
  a	
  caching/reverse	
  proxy

                             Varnish	
  does	
  that

                         It’ll	
  make	
  your	
  site	
  fly!
Info



•Website:	
  h$p://www.varnish-­‐cache.org
•Wiki:	
  h$p://www.varnish-­‐cache.org/trac/wiki
•Examples:	
  h$p://www.varnish-­‐cache.org/trac/wiki/VCLExamples
•DocumentaHon	
  site:	
  h$p://www.varnish-­‐cache.org/docs/2.1	
  
Setup	
  Varnish
Setup	
  Varnish

    curl http://repo.varnish-cache.org/debian/
    GPG-key.txt | apt-key add -

    echo "deb http://repo.varnish-cache.org/
    debian/ $(lsb_release -s -c) varnish-2.1"
    >> /etc/apt/sources.list


    apt-get update

    apt-get install varnish
Setup	
  Varnish

    START=yes

    DAEMON_OPTS="-a :80 
    -T localhost:6082 
    -f /etc/varnish/default.vcl 
    -s file,/var/lib/varnish/$INSTANCE/
    varnish_storage.bin,1G"



    In	
  “/etc/default/varnish”
Setup	
  the	
  backend
Setup	
  the	
  backend




        backend default {
              .host = "127.0.0.1";
              .port = "8080";
        }



   In	
  “/etc/varnish/default.vcl”
Setup	
  the	
  backend




        Listen 8080




   In	
  “/etc/apache2/ports.conf”
Out	
  of	
  the	
  box	
  Varnish	
  will	
  only	
  ...
...	
  obey	
  your	
  caching	
  headers
...	
  and	
  cache	
  sta*c	
  files
Request                          vcl_recv




                                             Yes         Cacheable?
                         vcl_hash



            Yes                                No
                         In cache?



                                                                      No
vcl_hit()                                           vcl_miss()




                                     vcl_fetch()




              vcl_deliver()




                  Response
Hits	
  &	
  misses
Logging	
  &	
  sta*s*cs	
  
Varnishstat




  Real	
  *me	
  stats	
  of	
  running	
  varnishd	
  instance

  hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishstat.html
Hitrate	
  ratio:	
  	
  	
  	
  	
  	
  	
  10	
  	
  	
  	
  	
  	
  100	
  	
  	
  	
  	
  	
  121
Hitrate	
  avg:	
  	
  	
  	
  	
  0.5365	
  	
  	
  0.5287	
  	
  	
  0.5277

	
  	
  	
  	
  	
  	
  	
  	
  9957	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  4.10	
  Client	
  connections	
  accepted
	
  	
  	
  	
  	
  	
  	
  58932	
  	
  	
  	
  	
  	
  	
  	
  67.92	
  	
  	
  	
  	
  	
  	
  	
  24.28	
  Client	
  requests	
  received
	
  	
  	
  	
  	
  	
  	
  30483	
  	
  	
  	
  	
  	
  	
  	
  	
  1.00	
  	
  	
  	
  	
  	
  	
  	
  12.56	
  Cache	
  hits
	
  	
  	
  	
  	
  	
  	
  	
  8592	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  3.54	
  Cache	
  hits	
  for	
  pass
	
  	
  	
  	
  	
  	
  	
  18991	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  	
  7.82	
  Cache	
  misses
	
  	
  	
  	
  	
  	
  	
  28449	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  11.72	
  Backend	
  connections	
  success
	
  	
  	
  	
  	
  	
  	
  22562	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  	
  9.30	
  Backend	
  connections	
  reuses
	
  	
  	
  	
  	
  	
  	
  28357	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  11.68	
  Backend	
  connections	
  recycles
	
  	
  	
  	
  	
  	
  	
  	
  	
  488	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  srcaddr
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  7	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  active	
  struct	
  srcaddr
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  81	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  sess_mem
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  21	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  sess
	
  	
  	
  	
  	
  	
  	
  	
  4398	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  object
	
  	
  	
  	
  	
  	
  	
  	
  4401	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  objecthead
	
  	
  	
  	
  	
  	
  	
  	
  9220	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  smf
	
  	
  	
  	
  	
  	
  	
  	
  	
  355	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  small	
  free	
  smf
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  6	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  large	
  free	
  smf
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  2	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  vbe_conn
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  10	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  struct	
  bereq
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  17	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  worker	
  threads
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  28	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  0.01	
  N	
  worker	
  threads	
  created
	
  	
  	
  	
  	
  	
  	
  	
  	
  164	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  0.07	
  N	
  overflowed	
  work	
  requests
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  1	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  backends
	
  	
  	
  	
  	
  	
  	
  14608	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  expired	
  objects
	
  	
  	
  	
  	
  	
  	
  24113	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .	
  	
  	
  N	
  LRU	
  moved	
  objects
	
  	
  	
  	
  	
  	
  	
  53778	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  22.16	
  Objects	
  sent	
  with	
  write
	
  	
  	
  	
  	
  	
  	
  	
  9957	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  4.10	
  Total	
  Sessions
	
  	
  	
  	
  	
  	
  	
  58935	
  	
  	
  	
  	
  	
  	
  	
  67.92	
  	
  	
  	
  	
  	
  	
  	
  24.28	
  Total	
  Requests
	
  	
  	
  	
  	
  	
  	
  	
  9458	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  3.90	
  Total	
  pass
	
  	
  	
  	
  	
  	
  	
  28445	
  	
  	
  	
  	
  	
  	
  	
  66.92	
  	
  	
  	
  	
  	
  	
  	
  11.72	
  Total	
  fetch
	
  	
  	
  	
  22496844	
  	
  	
  	
  	
  23506.62	
  	
  	
  	
  	
  	
  9269.40	
  Total	
  header	
  bytes
	
  	
  	
  606897837	
  	
  	
  	
  263427.01	
  	
  	
  	
  250060.91	
  Total	
  body	
  bytes
	
  	
  	
  	
  	
  	
  	
  	
  1384	
  	
  	
  	
  	
  	
  	
  	
  	
  0.00	
  	
  	
  	
  	
  	
  	
  	
  	
  0.57	
  Session	
  Closed
Varnishlog




  Display	
  requests	
  of	
  running	
  varnishd	
  instance

  hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishlog.html
Varnishlog

                 Notable	
  tags

• ReqEnd       • TxHeader          • RxHeader
• ReqStart     • TxLostHeader      • RxLostHeader
• Hit          • TxProtocol        • RxProtocol
• Error        • TxRequest         • RxRequest
• VCL_call     • TxResponse        • RxResponse
• VCL_return   • TxStatus          • RxStatus
• VCL_acl      • TxURL             • RxURL
Varnishlog




   varnishlog	
  -­‐c	
  -­‐o	
  RxRequest	
  POST


                  All	
  POST	
  requests
Varnishlog




  varnishlog	
  -­‐c	
  -­‐i	
  RxHeader	
  -­‐I	
  ^User-­‐Agent


                All	
  user	
  agents
Varnishlog




 varnishlog	
  -­‐i	
  TxURL


          All	
  URL’s	
  that	
  “missed”
Varnishlog




  varnishlog	
  	
  -­‐o	
  VCL_call	
  hit	
  |	
  grep	
  RxURL


                      All	
  URL’s	
  that	
  “hit”
Varnishlog


 varnishlog	
  	
  -­‐w	
  /tmp/yourfile.log


                    Write	
  log	
  to	
  file

  varnishlog	
  	
  -­‐r	
  /tmp/yourfile.log


                   Read	
  log	
  from	
  file
 	
  	
  12	
  SessionOpen	
  	
  c	
  172.16.26.1	
  50396	
  :8080
	
  	
  	
  12	
  ReqStart	
  	
  	
  	
  	
  c	
  172.16.26.1	
  50396	
  668213522
	
  	
  	
  12	
  RxRequest	
  	
  	
  	
  c	
  GET
	
  	
  	
  12	
  RxURL	
  	
  	
  	
  	
  	
  	
  	
  c	
  /test.php
	
  	
  	
  12	
  RxProtocol	
  	
  	
  c	
  HTTP/1.1
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Host:	
  varnish.dev:8080
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  User-­‐Agent:	
  Mozilla/5.0	
  (Macintosh;	
  U;	
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;	
  
rv:1.9.2.10)	
  Gecko/20100914	
  Firefox/3.6.10
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Accept:	
  text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Accept-­‐Language:	
  nl,en-­‐us;q=0.7,en;q=0.3
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Accept-­‐Encoding:	
  gzip,deflate
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Accept-­‐Charset:	
  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Keep-­‐Alive:	
  115
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Connection:	
  keep-­‐alive
	
  	
  	
  12	
  RxHeader	
  	
  	
  	
  	
  c	
  Cookie:	
  PHPSESSID=2n2pkit81qdgk6k4trf1crft16
	
  	
  	
  12	
  VCL_call	
  	
  	
  	
  	
  c	
  recv
	
  	
  	
  12	
  VCL_return	
  	
  	
  c	
  pass
	
  	
  	
  12	
  VCL_call	
  	
  	
  	
  	
  c	
  hash
	
  	
  	
  12	
  VCL_return	
  	
  	
  c	
  hash
	
  	
  	
  12	
  VCL_call	
  	
  	
  	
  	
  c	
  pass
	
  	
  	
  12	
  VCL_return	
  	
  	
  c	
  pass
	
  	
  	
  14	
  BackendClose	
  -­‐	
  default
	
  	
  	
  14	
  BackendOpen	
  	
  b	
  default	
  127.0.0.1	
  34267	
  127.0.0.1	
  80
	
  	
  	
  12	
  Backend	
  	
  	
  	
  	
  	
  c	
  14	
  default	
  default
 	
  	
  14	
  TxRequest	
  	
  	
  	
  b	
  GET
	
  	
  	
  14	
  TxURL	
  	
  	
  	
  	
  	
  	
  	
  b	
  /test.php
	
  	
  	
  14	
  TxProtocol	
  	
  	
  b	
  HTTP/1.1
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Host:	
  varnish.dev:8080
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  User-­‐Agent:	
  Mozilla/5.0	
  (Macintosh;	
  U;	
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;	
  
rv:1.9.2.10)	
  Gecko/20100914	
  Firefox/3.6.10
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Accept:	
  text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Accept-­‐Language:	
  nl,en-­‐us;q=0.7,en;q=0.3
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Accept-­‐Encoding:	
  gzip,deflate
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Accept-­‐Charset:	
  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  Cookie:	
  PHPSESSID=2n2pkit81qdgk6k4trf1crft16
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  X-­‐Forwarded-­‐For:	
  172.16.26.1
	
  	
  	
  14	
  TxHeader	
  	
  	
  	
  	
  b	
  X-­‐Varnish:	
  668213522
	
  	
  	
  14	
  RxProtocol	
  	
  	
  b	
  HTTP/1.1
	
  	
  	
  14	
  RxStatus	
  	
  	
  	
  	
  b	
  200
	
  	
  	
  14	
  RxResponse	
  	
  	
  b	
  OK
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Date:	
  Tue,	
  19	
  Oct	
  2010	
  12:54:49	
  GMT
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Server:	
  Apache/2.2.16	
  (Ubuntu)
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  X-­‐Powered-­‐By:	
  PHP/5.3.3-­‐1ubuntu9
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Vary:	
  Accept-­‐Encoding
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Content-­‐Encoding:	
  gzip
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Content-­‐Length:	
  36
	
  	
  	
  14	
  RxHeader	
  	
  	
  	
  	
  b	
  Content-­‐Type:	
  text/html
 	
  	
  12	
  TTL	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  c	
  668213522	
  RFC	
  120	
  1287492889	
  0	
  0	
  0	
  0
	
  	
  	
  12	
  VCL_call	
  	
  	
  	
  	
  c	
  fetch
	
  	
  	
  12	
  TTL	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  c	
  668213522	
  VCL	
  10	
  1287492889
	
  	
  	
  12	
  VCL_return	
  	
  	
  c	
  pass
	
  	
  	
  12	
  ObjProtocol	
  	
  c	
  HTTP/1.1
	
  	
  	
  12	
  ObjStatus	
  	
  	
  	
  c	
  200
	
  	
  	
  12	
  ObjResponse	
  	
  c	
  OK
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  Date:	
  Tue,	
  19	
  Oct	
  2010	
  12:54:49	
  GMT
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  Server:	
  Apache/2.2.16	
  (Ubuntu)
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  X-­‐Powered-­‐By:	
  PHP/5.3.3-­‐1ubuntu9
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  Vary:	
  Accept-­‐Encoding
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  Content-­‐Encoding:	
  gzip
	
  	
  	
  12	
  ObjHeader	
  	
  	
  	
  c	
  Content-­‐Type:	
  text/html
	
  	
  	
  14	
  Length	
  	
  	
  	
  	
  	
  	
  b	
  36
	
  	
  	
  14	
  BackendReuse	
  b	
  default
	
  	
  	
  12	
  VCL_call	
  	
  	
  	
  	
  c	
  deliver
	
  	
  	
  12	
  VCL_return	
  	
  	
  c	
  deliver
	
  	
  	
  12	
  TxProtocol	
  	
  	
  c	
  HTTP/1.1
	
  	
  	
  12	
  TxStatus	
  	
  	
  	
  	
  c	
  200
	
  	
  	
  12	
  TxResponse	
  	
  	
  c	
  OK
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Server:	
  Apache/2.2.16	
  (Ubuntu)
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  X-­‐Powered-­‐By:	
  PHP/5.3.3-­‐1ubuntu9
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Vary:	
  Accept-­‐Encoding
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Content-­‐Encoding:	
  gzip
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Content-­‐Type:	
  text/html
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Content-­‐Length:	
  36
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Date:	
  Tue,	
  19	
  Oct	
  2010	
  12:54:49	
  GMT
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  X-­‐Varnish:	
  668213522
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Age:	
  0
	
  	
  	
  12	
  TxHeader	
  	
  	
  	
  	
  c	
  Via:	
  1.1	
  varnish
Varnishtop




  Read	
  memory	
  logs	
  and	
  presents	
  them	
  as	
  a	
  
  con*nuously	
  updated	
  list	
  of	
  commonly	
  
  occuring	
  log	
  entries

  hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishtop.html
Varnishtop




  varnishtop	
  -­‐i	
  RxHeader	
  -­‐I	
  ^User-­‐Agent


             Get	
  the	
  top	
  user	
  agents
Varnishtop




  varnishtop	
  -­‐i	
  RxRequest


        Get	
  the	
  top	
  request	
  methods
Varnishtop




  varnishtop	
  -­‐i	
  TxURL


                Get	
  the	
  top	
  misses
list	
  length	
  90	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
dev

	
  	
  	
  	
  76.42	
  VCL_return	
  	
  	
  	
  	
  pass	
  	
  	
  
	
  	
  	
  	
  50.95	
  RxProtocol	
  	
  	
  	
  	
  HTTP/1.1
	
  	
  	
  	
  50.95	
  TxProtocol	
  	
  	
  	
  	
  HTTP/1.1
	
  	
  	
  	
  27.54	
  Length	
  	
  	
  	
  	
  	
  	
  	
  	
  110
	
  	
  	
  	
  25.48	
  Debug	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  herding
	
  	
  	
  	
  25.47	
  RxRequest	
  	
  	
  	
  	
  	
  GET
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Host:	
  varnish.dev:8080
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  User-­‐Agent:	
  Mozilla/5.0	
  (Macintosh;	
  U;	
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;
rv:1.9.2.10)	
  Gecko/20100914	
  Firefox/3.6.10
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Accept:	
  text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Accept-­‐Language:	
  nl,en-­‐us;q=0.7,en;q=0.3
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Accept-­‐Encoding:	
  gzip,deflate
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Accept-­‐Charset:	
  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Keep-­‐Alive:	
  115
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Connection:	
  keep-­‐alive
	
  	
  	
  	
  25.47	
  RxHeader	
  	
  	
  	
  	
  	
  	
  Cookie:	
  PHPSESSID=2n2pkit81qdgk6k4trf1crft16
	
  	
  	
  	
  25.47	
  VCL_call	
  	
  	
  	
  	
  	
  	
  recv
	
  	
  	
  	
  25.47	
  VCL_call	
  	
  	
  	
  	
  	
  	
  hash
	
  	
  	
  	
  25.47	
  VCL_return	
  	
  	
  	
  	
  hash
	
  	
  	
  	
  25.47	
  VCL_call	
  	
  	
  	
  	
  	
  	
  pass
	
  	
  	
  	
  25.47	
  Backend	
  	
  	
  	
  	
  	
  	
  	
  14	
  default	
  default
	
  	
  	
  	
  25.47	
  TxRequest	
  	
  	
  	
  	
  	
  GET
	
  	
  	
  	
  25.47	
  TxHeader	
  	
  	
  	
  	
  	
  	
  Host:	
  varnish.dev:8080
	
  	
  	
  	
  25.47	
  TxHeader	
  	
  	
  	
  	
  	
  	
  User-­‐Agent:	
  Mozilla/5.0	
  (Macintosh;	
  U;	
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;
rv:1.9.2.10)	
  Gecko/20100914	
  Firefox/3.6.10
	
  	
  	
  	
  25.47	
  TxHeader	
  	
  	
  	
  	
  	
  	
  Accept:	
  text/html,application/xhtml+xml,application/
Varnishncsa




  Read	
  memory	
  logs	
  and	
  presents	
  them	
  in	
  the	
  
  Apache	
  /	
  NCSA	
  “combined”	
  log	
  format

  hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishncsa.html
Varnishncsa


  varnishncsa	
  -­‐D	
  -­‐a	
  -­‐w	
  /var/log/some.log

  172.16.26.1	
  -­‐	
  -­‐	
  [19/Oct/2010:16:08:02	
  +0200]	
  "GET	
  hZp://
  varnish.dev:8080/	
  HTTP/1.1"	
  200	
  97	
  "-­‐"	
  "Mozilla/5.0	
  (Macintosh;	
  U;	
  
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;	
  rv:1.9.2.10)	
  Gecko/20100914	
  Firefox/3.6.10"
  172.16.26.1	
  -­‐	
  -­‐	
  [19/Oct/2010:16:08:10	
  +0200]	
  "GET	
  hZp://
  varnish.dev:8080/test.php	
  HTTP/1.1"	
  200	
  36	
  "-­‐"	
  "Mozilla/5.0	
  
  (Macintosh;	
  U;	
  Intel	
  Mac	
  OS	
  X	
  10.6;	
  nl;	
  rv:1.9.2.10)	
  Gecko/20100914	
  
  Firefox/3.6.10"
Varnishreplay




 The	
  varnishreplay	
  u*lity	
  parses	
  varnish	
  logs	
  and	
  
 aZempts	
  to	
  reproduce	
  the	
  traffic

 hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishreplay.html
Varnishreplay




  varnishlog	
  	
  -­‐w	
  /tmp/yourfile.log

  varnishreplay	
  	
  -­‐r	
  /tmp/yourfile.log
Management	
  via	
  telnet
Management	
  via	
  telnet

  root@dev:/#	
  telnet	
  localhost	
  6082
  Trying	
  ::1...
  Connected	
  to	
  localhost.
  Escape	
  character	
  is	
  '^]'.
  200	
  154	
  	
  	
  	
  	
  
  -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐
  Varnish	
  HTTP	
  accelerator	
  CLI.
  -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐
  Type	
  'help'	
  for	
  command	
  list.
  Type	
  'quit'	
  to	
  close	
  CLI	
  session.
Management	
  via	
  telnet

                       Notable	
  ac*ons
• vcl.load	
  <configname>	
  <filename>
• vcl.use	
  <configname>
• vcl.discard	
  <configname>         Avoid	
  interrup*on
• vcl.list
• vcl.show	
  <configname>
Request                          vcl_recv




                                             Yes         Cacheable?
                         vcl_hash



            Yes                                No
                         In cache?



                                                                      No
vcl_hit()                                           vcl_miss()




                                     vcl_fetch()




              vcl_deliver()




                  Response
Cache	
  sta*c	
  files


sub vcl_recv {
  if ( (req.request == "GET" || req.request == "HEAD")
&& req.url ~ ".(png|gif|jpe?g|swf|css|js|html?|sstm)
$" ) {
      return(lookup);
  } else {
      return(pass);
  }
}
Provide	
  HIT/MISS	
  informa*on


sub vcl_deliver {
    if (obj.hits > 0) {
        set resp.http.X-Cache = "HIT";
    } else {
        set resp.http.X-Cache = "MISS";
    }
}
Manipulate	
  TTL



sub vcl_fetch {
        set beresp.ttl = 10s;
}
Cache	
  ...	
  even	
  with	
  cookies

sub vcl_recv {
   if (req.request == "GET" || req.request ==
"HEAD") {
     return (lookup);
   }
}
sub vcl_hash {
  if (req.http.Cookie) {
    set req.hash += req.http.Cookie;
  }
}
Remove	
  cookies


 sub vcl_recv {
     unset req.http.cookie;
 }
 sub vcl_fetch {
     unset beresp.http.set-cookie;
 }
Remove	
  Google	
  Analy*cs	
  cookies

sub vcl_recv {
if (req.http.Cookie) {
    set req.http.Cookie = regsuball
(req.http.Cookie,"(^|; ) *__utm.=[^;]+;?
*","1");
    if (req.http.Cookie == "") {
        remove req.http.Cookie;
    }
}
Mul*ple	
  backends:	
  hostname	
  filtering

backend default {
    .host = "default.server.com";
    .port = "80";
}
backend other {
    .host = "other.server.com";
    .port = "80";
}
sub vcl_recv {
    if(req.http.host ~ "^www."){
        set req.backend= default;
    } else {
        set req.backend = other;
    }
}
www.example.com   example.com




Default backend   Other backend
Grace	
  mode



sub vcl_recv {
    if (req.backend.healthy) {
        set req.grace = 1s;
    } else {
        set req.grace = 10s;
    }
}
                Keep	
  reading	
  from	
  cache,	
  
                   even	
  when	
  expired
Mul*ple	
  backends:	
  health	
  checks

backend default {
    .host = "default.server.com";
    .port = "80";
    .probe = {
        .url = "/";
        .timeout = 50 ms;
        .interval = 1s;
        .window = 2;
        .threshold = 2;
    }
}
Mul*ple	
  backends:	
  health	
  checks

backend other {
    .host = "other.server.com";
    .port = "80";
    .probe = {
        .url = "/";
        .timeout = 50 ms;
        .interval = 1s;
        .window = 2;
        .threshold = 2;
    }
}
Mul*ple	
  backends:	
  health	
  checks
sub vcl_recv {
  if (req.restarts == 0) {
    set req.backend = default;
  } else {
    set req.backend = other;
  }
  return(pass);
}
sub vcl_error {
  if (obj.status == 503 && req.restarts
< 4) {
    restart;
  }
}
Default backend   Other backend
Default backend   Other backend
Loadbalancing	
  via	
  directors



director back round-robin {
        {.backend = default;}
        {.backend = other;}
}
sub vcl_recv {
    set req.backend = back;
    return(pass);
}
50%      50%




Default backend   Other backend
Loadbalancing	
  via	
  directors



director back random {
  {.backend = default; .weight=1;}
  {.backend = other; .weight=2;}
}
sub vcl_recv {
  set req.backend = back;
  return(pass);
}
33%      66%




Default backend   Other backend
Purging

acl purge_acl {
  "localhost";
  "1.2.3.4";
  "some.host.ext";
}
sub vcl_recv {
  if (req.request == "PURGE") {
     if (!client.ip ~ purge_acl) {
        error 405 "Not allowed.";
     }
     purge_url(req.url);
     error 200 "Purged.";
  }
  return(lookup);
}
    curl	
  -­‐X	
  PURGE	
  hZp://yoursite.com/yourpage
Edge	
  Side	
  Includes:	
  the	
  final	
  piece	
  of	
  the	
  puzzle
header.php



menu.php          main.php



           footer.php
<html>
<body>
    <table>
      <tr>
        <td colspan="2" >
           <?php include('header.php') ?>
        </td>
      </tr>
      <tr>
        <td><?php include('menu.php') ?></td>
        <td><?php include('main.php') ?></td>
      </tr>      
      <tr>
        <td colspan="2" >
           <?php include('footer.php') ?>
        </td>
      </tr>      
    </table>
  </body>
</html>
No	
  caching
   TTL	
  10s
                header.php

                                             TTL	
  2s
menu.php               main.php



                footer.php

                                    TTL	
  5s
<html>
<body>
    <table>
      <tr>
        <td colspan="2" >
          <esi:include src="/header.php"   />
        </td>
      </tr>
      <tr>
        <td><esi:include src="/menu.php"   /></td>
        <td><esi:include src="/main.php"   /></td>
      </tr>
      <tr>
        <td colspan="2" >
          <esi:include src="/footer.php"   />
        </td>
      </tr>
    </table>
  </body>
<?php
function esi($file){
    if(array_key_exists('HTTP_X_VARNISH',$_SERVER)){
        header("esi-enabled: 1");
        $url = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER
['SCRIPT_NAME'],0,1+strrpos($_SERVER['SCRIPT_NAME'],'/')).
$file;
        echo "<esi:include src="$url" />".PHP_EOL;
    } else {
        include($file);
    }
}
<?php
class My_View_Helper_Esi extends Zend_View_Helper_Abstract
{
  protected $_requestHeader;
  protected $_responseHeader;
  protected $_frontController;
  public function esi
($controller = 'index', $action='index', $requestHeader = 'X_VARNISH', 
$responseHeader = 'esi-enabled: 1')
  {
      $this->_requestHeader = $requestHeader;
      $this->_responseHeader = $responseHeader;
      $this->_frontController = Zend_Controller_Front::getInstance();
      if($this->_getRequestHeader()){
          $this->_getResponseHeader();
          return $this->_buildEsi($controller,$action);
      } else {
          return $this->_dispatch($controller, $action);
      }
  }
...
...
protected function _getRequestHeader()
{
  if($this->_requestHeader === null || $this-
>_requestHeader === false){
   return false;
  }        
  $request = $this->_frontController->getRequest();
  if($request->getHeader($this->_requestHeader) === false){
      return false;
  } else {
      return true;
  }
}
protected function _getResponseHeader()
{
  if($this->_responseHeader !== null && $this-
>_responseHeader !== false){
    header($this->_responseHeader);
  }
}
...
...
   protected function _dispatch($controller,$action)
   {
     $request = new Zend_Controller_Request_Simple
($action, $controller);
    $response = new Zend_Controller_Response_Http();
    $dispatcher = $this->_frontController->getDispatcher();
    $dispatcher->dispatch($request, $response);
    return $response->getBody();
   }
   protected function _buildEsi($controller,$action)
   {
     $router = $this->_frontController->getRouter();
     $url = $router->assemble(array('controller'=>
$controller,'action'=>$action));
     return "<esi:include src="{$url}"/>";
   }
}
<html>
<body>
 <table>
  <tr>
   <td colspan="2" >
     <?php echo $this->esi('index',‘header’) ?>
   </td>
  </tr>
  <tr>
   <td><?php echo $this->esi('index',‘menu’) ?></td>
   <td><?php echo $this->esi('index',‘main’) ?></td>
  </tr>      
  <tr>
   <td colspan="2" >
     <?php echo $this->esi('index',‘footer’) ?>
   </td>
  </tr>      
 </table>
sub vcl_recv {
  if(req.url == "/header.php") {
    return (pass);
  }
  if(req.url ~ "^/(footer|main|menu).php$") {
    return (lookup);
  }
}
sub vcl_fetch {
  if (beresp.http.esi-enabled == "1") {
    esi;
    unset beresp.http.esi-enabled;
  }
  if(req.url == "/footer.php") {
        set beresp.ttl = 5s;
  }
  if(req.url == "/menu.php") {
        set beresp.ttl = 10s;
  }
  if(req.url == "/main.php") {
        set beresp.ttl = 2s;
  }
}
Q&A

More Related Content

What's hot

Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.js
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.jsJS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.js
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.jsJSFestUA
 
Caching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersCaching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeWim Godden
 
ioDrive de benchmarking 2011 1209_zem_distribution
ioDrive de benchmarking 2011 1209_zem_distributionioDrive de benchmarking 2011 1209_zem_distribution
ioDrive de benchmarking 2011 1209_zem_distributionMasahito Zembutsu
 
Nsd, il tuo compagno di viaggio quando Domino va in crash
Nsd, il tuo compagno di viaggio quando Domino va in crashNsd, il tuo compagno di viaggio quando Domino va in crash
Nsd, il tuo compagno di viaggio quando Domino va in crashFabio Pignatti
 
MongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and QueueingMongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and QueueingBoxed Ice
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014odnoklassniki.ru
 
Immutable, and More
Immutable, and MoreImmutable, and More
Immutable, and MoreChase Zhang
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Codemotion
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyYusuke Yamamoto
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming PatternsHao Chen
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1app
 
Advanced rac troubleshooting
Advanced rac troubleshootingAdvanced rac troubleshooting
Advanced rac troubleshootingRiyaj Shamsudeen
 

What's hot (20)

Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.js
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.jsJS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.js
JS Fest 2019. Thomas Watson. Post-Mortem Debugging in Node.js
 
Caching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersCaching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4Developers
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)Qt Network Explained (Portuguese)
Qt Network Explained (Portuguese)
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
ioDrive de benchmarking 2011 1209_zem_distribution
ioDrive de benchmarking 2011 1209_zem_distributionioDrive de benchmarking 2011 1209_zem_distribution
ioDrive de benchmarking 2011 1209_zem_distribution
 
Nsd, il tuo compagno di viaggio quando Domino va in crash
Nsd, il tuo compagno di viaggio quando Domino va in crashNsd, il tuo compagno di viaggio quando Domino va in crash
Nsd, il tuo compagno di viaggio quando Domino va in crash
 
MongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and QueueingMongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and Queueing
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
 
ChtiJUG - Cassandra 2.0
ChtiJUG - Cassandra 2.0ChtiJUG - Cassandra 2.0
ChtiJUG - Cassandra 2.0
 
Immutable, and More
Immutable, and MoreImmutable, and More
Immutable, and More
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Redo internals ppt
Redo internals pptRedo internals ppt
Redo internals ppt
 
Advanced rac troubleshooting
Advanced rac troubleshootingAdvanced rac troubleshooting
Advanced rac troubleshooting
 

Viewers also liked

Im Cb Trobada Ice 1 09
Im Cb Trobada Ice 1 09Im Cb Trobada Ice 1 09
Im Cb Trobada Ice 1 09Nuria Alart
 
Conte La Castanyera
Conte La CastanyeraConte La Castanyera
Conte La CastanyeraVeronicavm
 
WordCamp Toronto 2011 - Managing Your Editorial Workflow
WordCamp Toronto 2011 - Managing Your Editorial WorkflowWordCamp Toronto 2011 - Managing Your Editorial Workflow
WordCamp Toronto 2011 - Managing Your Editorial WorkflowMo Jangda
 
Keeping the cloud in check cvodmd
Keeping the cloud in check cvodmdKeeping the cloud in check cvodmd
Keeping the cloud in check cvodmdCombell NV
 
Colorado EAPA
Colorado EAPAColorado EAPA
Colorado EAPAjenplace
 
Think innovation issue 4 share - scamper
Think innovation issue 4   share - scamperThink innovation issue 4   share - scamper
Think innovation issue 4 share - scamperThinkInnovation
 
Love Again, Or Never Love
Love Again, Or Never LoveLove Again, Or Never Love
Love Again, Or Never LoveMrs. McCabe
 
Market Perspective
Market PerspectiveMarket Perspective
Market PerspectiveEvo Terra
 
Cloud hosting today
Cloud hosting todayCloud hosting today
Cloud hosting todayCombell NV
 
Educazione secondo Joanna de Angelis
Educazione secondo Joanna de AngelisEducazione secondo Joanna de Angelis
Educazione secondo Joanna de AngelisArlete Laenzlinger
 
Weird Time - Ignite Phoenix
Weird Time - Ignite PhoenixWeird Time - Ignite Phoenix
Weird Time - Ignite PhoenixEvo Terra
 
Portàtils a l’aula
Portàtils a l’aulaPortàtils a l’aula
Portàtils a l’aulaNuria Alart
 
Big Distance - Talk from Ignite Phoenix 3
Big Distance - Talk from Ignite Phoenix 3Big Distance - Talk from Ignite Phoenix 3
Big Distance - Talk from Ignite Phoenix 3Evo Terra
 

Viewers also liked (20)

Im Cb Trobada Ice 1 09
Im Cb Trobada Ice 1 09Im Cb Trobada Ice 1 09
Im Cb Trobada Ice 1 09
 
Conte La Castanyera
Conte La CastanyeraConte La Castanyera
Conte La Castanyera
 
WordCamp Toronto 2011 - Managing Your Editorial Workflow
WordCamp Toronto 2011 - Managing Your Editorial WorkflowWordCamp Toronto 2011 - Managing Your Editorial Workflow
WordCamp Toronto 2011 - Managing Your Editorial Workflow
 
Sdumo Trust
Sdumo  TrustSdumo  Trust
Sdumo Trust
 
Paris
ParisParis
Paris
 
25 n 2010_powerpointatalayas
25 n 2010_powerpointatalayas25 n 2010_powerpointatalayas
25 n 2010_powerpointatalayas
 
Keeping the cloud in check cvodmd
Keeping the cloud in check cvodmdKeeping the cloud in check cvodmd
Keeping the cloud in check cvodmd
 
Colorado EAPA
Colorado EAPAColorado EAPA
Colorado EAPA
 
Gel Electrophoresis
Gel ElectrophoresisGel Electrophoresis
Gel Electrophoresis
 
Web quest 2.0
Web quest 2.0Web quest 2.0
Web quest 2.0
 
Think innovation issue 4 share - scamper
Think innovation issue 4   share - scamperThink innovation issue 4   share - scamper
Think innovation issue 4 share - scamper
 
Love Again, Or Never Love
Love Again, Or Never LoveLove Again, Or Never Love
Love Again, Or Never Love
 
Market Perspective
Market PerspectiveMarket Perspective
Market Perspective
 
King And Tub
King And TubKing And Tub
King And Tub
 
Cloud hosting today
Cloud hosting todayCloud hosting today
Cloud hosting today
 
Tutoria Màster
Tutoria MàsterTutoria Màster
Tutoria Màster
 
Educazione secondo Joanna de Angelis
Educazione secondo Joanna de AngelisEducazione secondo Joanna de Angelis
Educazione secondo Joanna de Angelis
 
Weird Time - Ignite Phoenix
Weird Time - Ignite PhoenixWeird Time - Ignite Phoenix
Weird Time - Ignite Phoenix
 
Portàtils a l’aula
Portàtils a l’aulaPortàtils a l’aula
Portàtils a l’aula
 
Big Distance - Talk from Ignite Phoenix 3
Big Distance - Talk from Ignite Phoenix 3Big Distance - Talk from Ignite Phoenix 3
Big Distance - Talk from Ignite Phoenix 3
 

Similar to Varnish in action phpuk11

Varnish in action phpday2011
Varnish in action phpday2011Varnish in action phpday2011
Varnish in action phpday2011Combell NV
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyLeif Hedstrom
 
PHP London Dec 2013 - Varnish - The 9 circles of hell
PHP London Dec 2013 - Varnish - The 9 circles of hellPHP London Dec 2013 - Varnish - The 9 circles of hell
PHP London Dec 2013 - Varnish - The 9 circles of hellluis-ferro
 
Varnish presentation for the Symfony Zaragoza user group
Varnish presentation for the Symfony Zaragoza user groupVarnish presentation for the Symfony Zaragoza user group
Varnish presentation for the Symfony Zaragoza user groupJorge Nerín
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Joe Arnold
 
Nginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteNginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteWim Godden
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)err
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformniyof97
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
Varnish Web Accelerator
Varnish Web AcceleratorVarnish Web Accelerator
Varnish Web AcceleratorRahul Ghose
 

Similar to Varnish in action phpuk11 (20)

Varnish in action phpday2011
Varnish in action phpday2011Varnish in action phpday2011
Varnish in action phpday2011
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Usenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a ProxyUsenix LISA 2012 - Choosing a Proxy
Usenix LISA 2012 - Choosing a Proxy
 
PHP London Dec 2013 - Varnish - The 9 circles of hell
PHP London Dec 2013 - Varnish - The 9 circles of hellPHP London Dec 2013 - Varnish - The 9 circles of hell
PHP London Dec 2013 - Varnish - The 9 circles of hell
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Varnish presentation for the Symfony Zaragoza user group
Varnish presentation for the Symfony Zaragoza user groupVarnish presentation for the Symfony Zaragoza user group
Varnish presentation for the Symfony Zaragoza user group
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
 
Varnish qconsp 2011
Varnish qconsp 2011Varnish qconsp 2011
Varnish qconsp 2011
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
Nginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteNginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your site
 
Checking Bitcoin
 Checking Bitcoin Checking Bitcoin
Checking Bitcoin
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)
 
Advanced Cassandra
Advanced CassandraAdvanced Cassandra
Advanced Cassandra
 
oSC22ww4.pdf
oSC22ww4.pdfoSC22ww4.pdf
oSC22ww4.pdf
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
Varnish Cache
Varnish CacheVarnish Cache
Varnish Cache
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Varnish Web Accelerator
Varnish Web AcceleratorVarnish Web Accelerator
Varnish Web Accelerator
 

More from Combell NV

Play it extra safe! Kies een goede cyberverzekering
Play it extra safe! Kies een goede cyberverzekeringPlay it extra safe! Kies een goede cyberverzekering
Play it extra safe! Kies een goede cyberverzekeringCombell NV
 
Hoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellHoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellCombell NV
 
Managed WordPress bij Combell – wat doet dat precies?
Managed WordPress bij Combell – wat doet dat precies?Managed WordPress bij Combell – wat doet dat precies?
Managed WordPress bij Combell – wat doet dat precies?Combell NV
 
Back-ups: Hoe ze je kunnen redden van een cyberaanval
Back-ups: Hoe ze je kunnen redden van een cyberaanvalBack-ups: Hoe ze je kunnen redden van een cyberaanval
Back-ups: Hoe ze je kunnen redden van een cyberaanvalCombell NV
 
Cyberaanvallen: Overzicht, gevolgen en beveiligingstips
Cyberaanvallen: Overzicht, gevolgen en beveiligingstipsCyberaanvallen: Overzicht, gevolgen en beveiligingstips
Cyberaanvallen: Overzicht, gevolgen en beveiligingstipsCombell NV
 
Hoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellHoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellCombell NV
 
Hoe laat je jouw website scoren in zoekmachines zoals Google
Hoe laat je jouw website scoren in zoekmachines zoals GoogleHoe laat je jouw website scoren in zoekmachines zoals Google
Hoe laat je jouw website scoren in zoekmachines zoals GoogleCombell NV
 
Een webshop bouwen in WooCommerce – advanced sessie
Een webshop bouwen in WooCommerce – advanced sessieEen webshop bouwen in WooCommerce – advanced sessie
Een webshop bouwen in WooCommerce – advanced sessieCombell NV
 
Hoe start je een webshop met WordPress / WooCommerce
Hoe start je een webshop met WordPress / WooCommerceHoe start je een webshop met WordPress / WooCommerce
Hoe start je een webshop met WordPress / WooCommerceCombell NV
 
Hybrid cloud wiskyweb2012
Hybrid cloud wiskyweb2012Hybrid cloud wiskyweb2012
Hybrid cloud wiskyweb2012Combell NV
 
2012 03-27 developers e-commercedag presentatie5 ssl
2012 03-27 developers e-commercedag presentatie5 ssl2012 03-27 developers e-commercedag presentatie5 ssl
2012 03-27 developers e-commercedag presentatie5 sslCombell NV
 
2012 03-27 developers e-commercedag presentatie2 drupal
2012 03-27 developers e-commercedag presentatie2 drupal2012 03-27 developers e-commercedag presentatie2 drupal
2012 03-27 developers e-commercedag presentatie2 drupalCombell NV
 
2012 03-27 developers e-commercedag presentatie1 magento
2012 03-27 developers e-commercedag presentatie1 magento2012 03-27 developers e-commercedag presentatie1 magento
2012 03-27 developers e-commercedag presentatie1 magentoCombell NV
 
2012 03-27 developers e-commercedag presentatie4 ogone
2012 03-27 developers e-commercedag presentatie4 ogone2012 03-27 developers e-commercedag presentatie4 ogone
2012 03-27 developers e-commercedag presentatie4 ogoneCombell NV
 
10 doe-het-zelf tips om aan e-commerce te doen
10 doe-het-zelf tips om aan e-commerce te doen10 doe-het-zelf tips om aan e-commerce te doen
10 doe-het-zelf tips om aan e-commerce te doenCombell NV
 
Develop and deploy using Hybrid Cloud Strategies confoo2012
Develop and deploy using Hybrid Cloud Strategies confoo2012Develop and deploy using Hybrid Cloud Strategies confoo2012
Develop and deploy using Hybrid Cloud Strategies confoo2012Combell NV
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confooCombell NV
 
Hybrid Cloud PHPUK2012
Hybrid Cloud PHPUK2012Hybrid Cloud PHPUK2012
Hybrid Cloud PHPUK2012Combell NV
 
2012 02-07 sql denali presentatie microsoft
2012 02-07 sql denali presentatie microsoft2012 02-07 sql denali presentatie microsoft
2012 02-07 sql denali presentatie microsoftCombell NV
 
11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallen11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallenCombell NV
 

More from Combell NV (20)

Play it extra safe! Kies een goede cyberverzekering
Play it extra safe! Kies een goede cyberverzekeringPlay it extra safe! Kies een goede cyberverzekering
Play it extra safe! Kies een goede cyberverzekering
 
Hoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellHoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van Combell
 
Managed WordPress bij Combell – wat doet dat precies?
Managed WordPress bij Combell – wat doet dat precies?Managed WordPress bij Combell – wat doet dat precies?
Managed WordPress bij Combell – wat doet dat precies?
 
Back-ups: Hoe ze je kunnen redden van een cyberaanval
Back-ups: Hoe ze je kunnen redden van een cyberaanvalBack-ups: Hoe ze je kunnen redden van een cyberaanval
Back-ups: Hoe ze je kunnen redden van een cyberaanval
 
Cyberaanvallen: Overzicht, gevolgen en beveiligingstips
Cyberaanvallen: Overzicht, gevolgen en beveiligingstipsCyberaanvallen: Overzicht, gevolgen en beveiligingstips
Cyberaanvallen: Overzicht, gevolgen en beveiligingstips
 
Hoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van CombellHoe gebruik je het resellerplatform als partner van Combell
Hoe gebruik je het resellerplatform als partner van Combell
 
Hoe laat je jouw website scoren in zoekmachines zoals Google
Hoe laat je jouw website scoren in zoekmachines zoals GoogleHoe laat je jouw website scoren in zoekmachines zoals Google
Hoe laat je jouw website scoren in zoekmachines zoals Google
 
Een webshop bouwen in WooCommerce – advanced sessie
Een webshop bouwen in WooCommerce – advanced sessieEen webshop bouwen in WooCommerce – advanced sessie
Een webshop bouwen in WooCommerce – advanced sessie
 
Hoe start je een webshop met WordPress / WooCommerce
Hoe start je een webshop met WordPress / WooCommerceHoe start je een webshop met WordPress / WooCommerce
Hoe start je een webshop met WordPress / WooCommerce
 
Hybrid cloud wiskyweb2012
Hybrid cloud wiskyweb2012Hybrid cloud wiskyweb2012
Hybrid cloud wiskyweb2012
 
2012 03-27 developers e-commercedag presentatie5 ssl
2012 03-27 developers e-commercedag presentatie5 ssl2012 03-27 developers e-commercedag presentatie5 ssl
2012 03-27 developers e-commercedag presentatie5 ssl
 
2012 03-27 developers e-commercedag presentatie2 drupal
2012 03-27 developers e-commercedag presentatie2 drupal2012 03-27 developers e-commercedag presentatie2 drupal
2012 03-27 developers e-commercedag presentatie2 drupal
 
2012 03-27 developers e-commercedag presentatie1 magento
2012 03-27 developers e-commercedag presentatie1 magento2012 03-27 developers e-commercedag presentatie1 magento
2012 03-27 developers e-commercedag presentatie1 magento
 
2012 03-27 developers e-commercedag presentatie4 ogone
2012 03-27 developers e-commercedag presentatie4 ogone2012 03-27 developers e-commercedag presentatie4 ogone
2012 03-27 developers e-commercedag presentatie4 ogone
 
10 doe-het-zelf tips om aan e-commerce te doen
10 doe-het-zelf tips om aan e-commerce te doen10 doe-het-zelf tips om aan e-commerce te doen
10 doe-het-zelf tips om aan e-commerce te doen
 
Develop and deploy using Hybrid Cloud Strategies confoo2012
Develop and deploy using Hybrid Cloud Strategies confoo2012Develop and deploy using Hybrid Cloud Strategies confoo2012
Develop and deploy using Hybrid Cloud Strategies confoo2012
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
Hybrid Cloud PHPUK2012
Hybrid Cloud PHPUK2012Hybrid Cloud PHPUK2012
Hybrid Cloud PHPUK2012
 
2012 02-07 sql denali presentatie microsoft
2012 02-07 sql denali presentatie microsoft2012 02-07 sql denali presentatie microsoft
2012 02-07 sql denali presentatie microsoft
 
11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallen11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallen
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Varnish in action phpuk11

  • 1. Thijs  Feryn Evangelist +32  (0)9  218  79  06 thijs@combellgroup.com PHP  UK  Conference Friday  February  25th  2011 London,  UK Varnish  in  ac*on
  • 2. About  me I’m  an  evangelist  at  Combell
  • 3. About  me I’m  a  board  member  at  PHPBenelux
  • 4. I  live  in  the  wonderful  city  of  Bruges MPBecker  -­‐  Bruges  by  Night  hZp://www.flickr.com/photos/galverson2/3715965933
  • 5. Follow  me  on  TwiZer:  @ThijsFeryn Give  me  feedback:  hZp://joind.in/2521 Read  my  blog:  hZp://blog.feryn.eu
  • 6.
  • 8. Varnish Reverse  proxy? Caching  proxy? Loadbalancer?
  • 9. Varnish HTTP  accelerator  !
  • 11. Caching Storing  computed  data  for  faster   serving  of  future  requests
  • 12. Basically Pueng  stuff  in  boxes  for  later  use
  • 13. Why?
  • 15. In  the  beginning  there  was  ...
  • 17. Browser  cache:  expira*on Expires:  Sun,  25  Jun  2006  14:57:12   Cache-­‐Control:  max-­‐age=86400,   must-­‐revalidate
  • 18. Browser  cache:  valida*on Last-­‐Modified:  Sun,  25  Jun  2006  14:57:12  GMT ETag:  “686897696a7c876b7e”
  • 19. Browser  cache:  valida*on Last-­‐Modified:  Sun,  25  Jun  2006  14:57:12  GMT ETag:  “686897696a7c876b7e” Compared  with  the  “If-­‐None-­‐Match”  header.   Throws  “HTTP/1.0  304  Not  Modified”  accordingly
  • 21. Browser  cache:  in  PHP <?php $seconds = 10; $expires = gmdate('D, j M Y H:i:s T', time() + $seconds); header("Expires: $expires"); header("Cache-Control: max-age=$seconds, must-revalidate"); ?> <ul>     <li>Current date/time: <?= gmdate('D, j M Y H:i:s T')?></li>     <li>Expires: <?= $expires ?></li>     <li>Cache-control: <?= $seconds?> seconds</li> </ul>
  • 23. Browser  cache:  in  Apache ExpiresAc*ve  on ExpiresDefault  "access  plus  1  month" ExpiresDefault  "now  plus  4  weeks" ExpiresDefault  "modifica*on  plus  30  days" ExpiresByType  text/html  "access  plus  1  month  15  days  2   hours"
  • 24. Browser  cache  is  your  friend  !
  • 26. Problems  with  browser  cache Mul*ple  standards Can  be  ignored  by  browser Force  refresh Cache  per  client
  • 27. Solu*ons:  use  a  caching/reverse  proxy! Use  a  caching/reverse  proxy Varnish  does  that It’ll  make  your  site  fly!
  • 28. Info •Website:  h$p://www.varnish-­‐cache.org •Wiki:  h$p://www.varnish-­‐cache.org/trac/wiki •Examples:  h$p://www.varnish-­‐cache.org/trac/wiki/VCLExamples •DocumentaHon  site:  h$p://www.varnish-­‐cache.org/docs/2.1  
  • 30. Setup  Varnish curl http://repo.varnish-cache.org/debian/ GPG-key.txt | apt-key add - echo "deb http://repo.varnish-cache.org/ debian/ $(lsb_release -s -c) varnish-2.1" >> /etc/apt/sources.list apt-get update apt-get install varnish
  • 31. Setup  Varnish START=yes DAEMON_OPTS="-a :80 -T localhost:6082 -f /etc/varnish/default.vcl -s file,/var/lib/varnish/$INSTANCE/ varnish_storage.bin,1G" In  “/etc/default/varnish”
  • 33. Setup  the  backend backend default { .host = "127.0.0.1"; .port = "8080"; } In  “/etc/varnish/default.vcl”
  • 34. Setup  the  backend Listen 8080 In  “/etc/apache2/ports.conf”
  • 35. Out  of  the  box  Varnish  will  only  ...
  • 36. ...  obey  your  caching  headers
  • 37. ...  and  cache  sta*c  files
  • 38. Request vcl_recv Yes Cacheable? vcl_hash Yes No In cache? No vcl_hit() vcl_miss() vcl_fetch() vcl_deliver() Response
  • 41. Varnishstat Real  *me  stats  of  running  varnishd  instance hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishstat.html
  • 42. Hitrate  ratio:              10            100            121 Hitrate  avg:          0.5365      0.5287      0.5277                9957                  0.00                  4.10  Client  connections  accepted              58932                67.92                24.28  Client  requests  received              30483                  1.00                12.56  Cache  hits                8592                  0.00                  3.54  Cache  hits  for  pass              18991                66.92                  7.82  Cache  misses              28449                66.92                11.72  Backend  connections  success              22562                66.92                  9.30  Backend  connections  reuses              28357                66.92                11.68  Backend  connections  recycles                  488                    .                        .      N  struct  srcaddr                      7                    .                        .      N  active  struct  srcaddr                    81                    .                        .      N  struct  sess_mem                    21                    .                        .      N  struct  sess                4398                    .                        .      N  struct  object                4401                    .                        .      N  struct  objecthead                9220                    .                        .      N  struct  smf                  355                    .                        .      N  small  free  smf                      6                    .                        .      N  large  free  smf                      2                    .                        .      N  struct  vbe_conn                    10                    .                        .      N  struct  bereq                    17                    .                        .      N  worker  threads                    28                  0.00                  0.01  N  worker  threads  created                  164                  0.00                  0.07  N  overflowed  work  requests                      1                    .                        .      N  backends              14608                    .                        .      N  expired  objects              24113                    .                        .      N  LRU  moved  objects              53778                66.92                22.16  Objects  sent  with  write                9957                  0.00                  4.10  Total  Sessions              58935                67.92                24.28  Total  Requests                9458                  0.00                  3.90  Total  pass              28445                66.92                11.72  Total  fetch        22496844          23506.62            9269.40  Total  header  bytes      606897837        263427.01        250060.91  Total  body  bytes                1384                  0.00                  0.57  Session  Closed
  • 43. Varnishlog Display  requests  of  running  varnishd  instance hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishlog.html
  • 44. Varnishlog Notable  tags • ReqEnd • TxHeader • RxHeader • ReqStart • TxLostHeader • RxLostHeader • Hit • TxProtocol • RxProtocol • Error • TxRequest • RxRequest • VCL_call • TxResponse • RxResponse • VCL_return • TxStatus • RxStatus • VCL_acl • TxURL • RxURL
  • 45. Varnishlog varnishlog  -­‐c  -­‐o  RxRequest  POST All  POST  requests
  • 46. Varnishlog varnishlog  -­‐c  -­‐i  RxHeader  -­‐I  ^User-­‐Agent All  user  agents
  • 47. Varnishlog varnishlog  -­‐i  TxURL All  URL’s  that  “missed”
  • 48. Varnishlog varnishlog    -­‐o  VCL_call  hit  |  grep  RxURL All  URL’s  that  “hit”
  • 49. Varnishlog varnishlog    -­‐w  /tmp/yourfile.log Write  log  to  file varnishlog    -­‐r  /tmp/yourfile.log Read  log  from  file
  • 50.      12  SessionOpen    c  172.16.26.1  50396  :8080      12  ReqStart          c  172.16.26.1  50396  668213522      12  RxRequest        c  GET      12  RxURL                c  /test.php      12  RxProtocol      c  HTTP/1.1      12  RxHeader          c  Host:  varnish.dev:8080      12  RxHeader          c  User-­‐Agent:  Mozilla/5.0  (Macintosh;  U;  Intel  Mac  OS  X  10.6;  nl;   rv:1.9.2.10)  Gecko/20100914  Firefox/3.6.10      12  RxHeader          c  Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8      12  RxHeader          c  Accept-­‐Language:  nl,en-­‐us;q=0.7,en;q=0.3      12  RxHeader          c  Accept-­‐Encoding:  gzip,deflate      12  RxHeader          c  Accept-­‐Charset:  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7      12  RxHeader          c  Keep-­‐Alive:  115      12  RxHeader          c  Connection:  keep-­‐alive      12  RxHeader          c  Cookie:  PHPSESSID=2n2pkit81qdgk6k4trf1crft16      12  VCL_call          c  recv      12  VCL_return      c  pass      12  VCL_call          c  hash      12  VCL_return      c  hash      12  VCL_call          c  pass      12  VCL_return      c  pass      14  BackendClose  -­‐  default      14  BackendOpen    b  default  127.0.0.1  34267  127.0.0.1  80      12  Backend            c  14  default  default
  • 51.      14  TxRequest        b  GET      14  TxURL                b  /test.php      14  TxProtocol      b  HTTP/1.1      14  TxHeader          b  Host:  varnish.dev:8080      14  TxHeader          b  User-­‐Agent:  Mozilla/5.0  (Macintosh;  U;  Intel  Mac  OS  X  10.6;  nl;   rv:1.9.2.10)  Gecko/20100914  Firefox/3.6.10      14  TxHeader          b  Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8      14  TxHeader          b  Accept-­‐Language:  nl,en-­‐us;q=0.7,en;q=0.3      14  TxHeader          b  Accept-­‐Encoding:  gzip,deflate      14  TxHeader          b  Accept-­‐Charset:  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7      14  TxHeader          b  Cookie:  PHPSESSID=2n2pkit81qdgk6k4trf1crft16      14  TxHeader          b  X-­‐Forwarded-­‐For:  172.16.26.1      14  TxHeader          b  X-­‐Varnish:  668213522      14  RxProtocol      b  HTTP/1.1      14  RxStatus          b  200      14  RxResponse      b  OK      14  RxHeader          b  Date:  Tue,  19  Oct  2010  12:54:49  GMT      14  RxHeader          b  Server:  Apache/2.2.16  (Ubuntu)      14  RxHeader          b  X-­‐Powered-­‐By:  PHP/5.3.3-­‐1ubuntu9      14  RxHeader          b  Vary:  Accept-­‐Encoding      14  RxHeader          b  Content-­‐Encoding:  gzip      14  RxHeader          b  Content-­‐Length:  36      14  RxHeader          b  Content-­‐Type:  text/html
  • 52.      12  TTL                    c  668213522  RFC  120  1287492889  0  0  0  0      12  VCL_call          c  fetch      12  TTL                    c  668213522  VCL  10  1287492889      12  VCL_return      c  pass      12  ObjProtocol    c  HTTP/1.1      12  ObjStatus        c  200      12  ObjResponse    c  OK      12  ObjHeader        c  Date:  Tue,  19  Oct  2010  12:54:49  GMT      12  ObjHeader        c  Server:  Apache/2.2.16  (Ubuntu)      12  ObjHeader        c  X-­‐Powered-­‐By:  PHP/5.3.3-­‐1ubuntu9      12  ObjHeader        c  Vary:  Accept-­‐Encoding      12  ObjHeader        c  Content-­‐Encoding:  gzip      12  ObjHeader        c  Content-­‐Type:  text/html      14  Length              b  36      14  BackendReuse  b  default      12  VCL_call          c  deliver      12  VCL_return      c  deliver      12  TxProtocol      c  HTTP/1.1      12  TxStatus          c  200      12  TxResponse      c  OK      12  TxHeader          c  Server:  Apache/2.2.16  (Ubuntu)      12  TxHeader          c  X-­‐Powered-­‐By:  PHP/5.3.3-­‐1ubuntu9      12  TxHeader          c  Vary:  Accept-­‐Encoding      12  TxHeader          c  Content-­‐Encoding:  gzip      12  TxHeader          c  Content-­‐Type:  text/html      12  TxHeader          c  Content-­‐Length:  36      12  TxHeader          c  Date:  Tue,  19  Oct  2010  12:54:49  GMT      12  TxHeader          c  X-­‐Varnish:  668213522      12  TxHeader          c  Age:  0      12  TxHeader          c  Via:  1.1  varnish
  • 53. Varnishtop Read  memory  logs  and  presents  them  as  a   con*nuously  updated  list  of  commonly   occuring  log  entries hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishtop.html
  • 54. Varnishtop varnishtop  -­‐i  RxHeader  -­‐I  ^User-­‐Agent Get  the  top  user  agents
  • 55. Varnishtop varnishtop  -­‐i  RxRequest Get  the  top  request  methods
  • 56. Varnishtop varnishtop  -­‐i  TxURL Get  the  top  misses
  • 57. list  length  90                                                                                                                                                     dev        76.42  VCL_return          pass              50.95  RxProtocol          HTTP/1.1        50.95  TxProtocol          HTTP/1.1        27.54  Length                  110        25.48  Debug                    herding        25.47  RxRequest            GET        25.47  RxHeader              Host:  varnish.dev:8080        25.47  RxHeader              User-­‐Agent:  Mozilla/5.0  (Macintosh;  U;  Intel  Mac  OS  X  10.6;  nl; rv:1.9.2.10)  Gecko/20100914  Firefox/3.6.10        25.47  RxHeader              Accept:  text/html,application/xhtml+xml,application/ xml;q=0.9,*/*;q=0.8        25.47  RxHeader              Accept-­‐Language:  nl,en-­‐us;q=0.7,en;q=0.3        25.47  RxHeader              Accept-­‐Encoding:  gzip,deflate        25.47  RxHeader              Accept-­‐Charset:  ISO-­‐8859-­‐1,utf-­‐8;q=0.7,*;q=0.7        25.47  RxHeader              Keep-­‐Alive:  115        25.47  RxHeader              Connection:  keep-­‐alive        25.47  RxHeader              Cookie:  PHPSESSID=2n2pkit81qdgk6k4trf1crft16        25.47  VCL_call              recv        25.47  VCL_call              hash        25.47  VCL_return          hash        25.47  VCL_call              pass        25.47  Backend                14  default  default        25.47  TxRequest            GET        25.47  TxHeader              Host:  varnish.dev:8080        25.47  TxHeader              User-­‐Agent:  Mozilla/5.0  (Macintosh;  U;  Intel  Mac  OS  X  10.6;  nl; rv:1.9.2.10)  Gecko/20100914  Firefox/3.6.10        25.47  TxHeader              Accept:  text/html,application/xhtml+xml,application/
  • 58. Varnishncsa Read  memory  logs  and  presents  them  in  the   Apache  /  NCSA  “combined”  log  format hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishncsa.html
  • 59. Varnishncsa varnishncsa  -­‐D  -­‐a  -­‐w  /var/log/some.log 172.16.26.1  -­‐  -­‐  [19/Oct/2010:16:08:02  +0200]  "GET  hZp:// varnish.dev:8080/  HTTP/1.1"  200  97  "-­‐"  "Mozilla/5.0  (Macintosh;  U;   Intel  Mac  OS  X  10.6;  nl;  rv:1.9.2.10)  Gecko/20100914  Firefox/3.6.10" 172.16.26.1  -­‐  -­‐  [19/Oct/2010:16:08:10  +0200]  "GET  hZp:// varnish.dev:8080/test.php  HTTP/1.1"  200  36  "-­‐"  "Mozilla/5.0   (Macintosh;  U;  Intel  Mac  OS  X  10.6;  nl;  rv:1.9.2.10)  Gecko/20100914   Firefox/3.6.10"
  • 60. Varnishreplay The  varnishreplay  u*lity  parses  varnish  logs  and   aZempts  to  reproduce  the  traffic hZp://www.varnish-­‐cache.org/docs/2.1/reference/varnishreplay.html
  • 61. Varnishreplay varnishlog    -­‐w  /tmp/yourfile.log varnishreplay    -­‐r  /tmp/yourfile.log
  • 63. Management  via  telnet root@dev:/#  telnet  localhost  6082 Trying  ::1... Connected  to  localhost. Escape  character  is  '^]'. 200  154           -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐ Varnish  HTTP  accelerator  CLI. -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐ Type  'help'  for  command  list. Type  'quit'  to  close  CLI  session.
  • 64. Management  via  telnet Notable  ac*ons • vcl.load  <configname>  <filename> • vcl.use  <configname> • vcl.discard  <configname> Avoid  interrup*on • vcl.list • vcl.show  <configname>
  • 65. Request vcl_recv Yes Cacheable? vcl_hash Yes No In cache? No vcl_hit() vcl_miss() vcl_fetch() vcl_deliver() Response
  • 66. Cache  sta*c  files sub vcl_recv { if ( (req.request == "GET" || req.request == "HEAD") && req.url ~ ".(png|gif|jpe?g|swf|css|js|html?|sstm) $" ) { return(lookup); } else { return(pass); } }
  • 67. Provide  HIT/MISS  informa*on sub vcl_deliver { if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; } else { set resp.http.X-Cache = "MISS"; } }
  • 68. Manipulate  TTL sub vcl_fetch { set beresp.ttl = 10s; }
  • 69. Cache  ...  even  with  cookies sub vcl_recv { if (req.request == "GET" || req.request == "HEAD") { return (lookup); } } sub vcl_hash { if (req.http.Cookie) { set req.hash += req.http.Cookie; } }
  • 70. Remove  cookies sub vcl_recv { unset req.http.cookie; } sub vcl_fetch { unset beresp.http.set-cookie; }
  • 71. Remove  Google  Analy*cs  cookies sub vcl_recv { if (req.http.Cookie) { set req.http.Cookie = regsuball (req.http.Cookie,"(^|; ) *__utm.=[^;]+;? *","1"); if (req.http.Cookie == "") { remove req.http.Cookie; } }
  • 72. Mul*ple  backends:  hostname  filtering backend default { .host = "default.server.com"; .port = "80"; } backend other { .host = "other.server.com"; .port = "80"; } sub vcl_recv { if(req.http.host ~ "^www."){ set req.backend= default; } else { set req.backend = other; } }
  • 73. www.example.com example.com Default backend Other backend
  • 74. Grace  mode sub vcl_recv { if (req.backend.healthy) { set req.grace = 1s; } else { set req.grace = 10s; } } Keep  reading  from  cache,   even  when  expired
  • 75. Mul*ple  backends:  health  checks backend default { .host = "default.server.com"; .port = "80"; .probe = { .url = "/"; .timeout = 50 ms; .interval = 1s; .window = 2; .threshold = 2; } }
  • 76. Mul*ple  backends:  health  checks backend other { .host = "other.server.com"; .port = "80"; .probe = { .url = "/"; .timeout = 50 ms; .interval = 1s; .window = 2; .threshold = 2; } }
  • 77. Mul*ple  backends:  health  checks sub vcl_recv { if (req.restarts == 0) { set req.backend = default; } else { set req.backend = other; } return(pass); } sub vcl_error { if (obj.status == 503 && req.restarts < 4) { restart; } }
  • 78. Default backend Other backend
  • 79. Default backend Other backend
  • 80. Loadbalancing  via  directors director back round-robin { {.backend = default;} {.backend = other;} } sub vcl_recv { set req.backend = back; return(pass); }
  • 81. 50% 50% Default backend Other backend
  • 82. Loadbalancing  via  directors director back random { {.backend = default; .weight=1;} {.backend = other; .weight=2;} } sub vcl_recv { set req.backend = back; return(pass); }
  • 83. 33% 66% Default backend Other backend
  • 84. Purging acl purge_acl { "localhost"; "1.2.3.4"; "some.host.ext"; } sub vcl_recv { if (req.request == "PURGE") { if (!client.ip ~ purge_acl) { error 405 "Not allowed."; } purge_url(req.url); error 200 "Purged."; } return(lookup); } curl  -­‐X  PURGE  hZp://yoursite.com/yourpage
  • 85. Edge  Side  Includes:  the  final  piece  of  the  puzzle
  • 86. header.php menu.php main.php footer.php
  • 87. <html> <body>     <table>       <tr>         <td colspan="2" > <?php include('header.php') ?> </td>       </tr>       <tr>         <td><?php include('menu.php') ?></td>         <td><?php include('main.php') ?></td>       </tr>             <tr>         <td colspan="2" > <?php include('footer.php') ?> </td>       </tr>           </table>   </body> </html>
  • 88. No  caching TTL  10s header.php TTL  2s menu.php main.php footer.php TTL  5s
  • 89. <html> <body> <table> <tr> <td colspan="2" > <esi:include src="/header.php" /> </td> </tr> <tr> <td><esi:include src="/menu.php" /></td> <td><esi:include src="/main.php" /></td> </tr> <tr> <td colspan="2" > <esi:include src="/footer.php" /> </td> </tr> </table> </body>
  • 92. ... protected function _getRequestHeader() { if($this->_requestHeader === null || $this- >_requestHeader === false){    return false;   }           $request = $this->_frontController->getRequest();   if($request->getHeader($this->_requestHeader) === false){       return false;   } else {       return true;   } } protected function _getResponseHeader() {   if($this->_responseHeader !== null && $this- >_responseHeader !== false){   header($this->_responseHeader);   } } ...
  • 93. ... protected function _dispatch($controller,$action) { $request = new Zend_Controller_Request_Simple ($action, $controller);     $response = new Zend_Controller_Response_Http();     $dispatcher = $this->_frontController->getDispatcher();     $dispatcher->dispatch($request, $response);     return $response->getBody(); } protected function _buildEsi($controller,$action) { $router = $this->_frontController->getRouter();   $url = $router->assemble(array('controller'=> $controller,'action'=>$action));    return "<esi:include src="{$url}"/>"; } }
  • 94. <html> <body> <table>   <tr>    <td colspan="2" > <?php echo $this->esi('index',‘header’) ?> </td>   </tr>   <tr>   <td><?php echo $this->esi('index',‘menu’) ?></td>    <td><?php echo $this->esi('index',‘main’) ?></td>   </tr>         <tr>    <td colspan="2" > <?php echo $this->esi('index',‘footer’) ?> </td>   </tr>        </table>
  • 95. sub vcl_recv { if(req.url == "/header.php") { return (pass); } if(req.url ~ "^/(footer|main|menu).php$") { return (lookup); } } sub vcl_fetch { if (beresp.http.esi-enabled == "1") { esi; unset beresp.http.esi-enabled; } if(req.url == "/footer.php") { set beresp.ttl = 5s; } if(req.url == "/menu.php") { set beresp.ttl = 10s; } if(req.url == "/main.php") { set beresp.ttl = 2s; } }
  • 96.
  • 97.
  • 98. Q&A