SlideShare una empresa de Scribd logo
1 de 20
varnish
• HTTP accelerator
 • reverse proxy
 • cache
• very fast
 • very much faster than squid
• open source
Outsources tasks

• architecture relies on kernel functions
• threads
 • massively multithreaded
 • part event driven
• mmap
mmap
• maps the store into memory
 • (or alternatively use jemalloc)
   • (makes kswapd use 100% cpu -- bad
      linux)
• madvise(MADV_RANDOM)
• writev directly from mapped memory
4725 SessionOpen c xxx.xxx.xxx.xxx 1441 :80
                                                  mmap logfile
 4774 ReqEnd      - 0 1245712664.794090033 1245712664.794090033 0.003499746 0.000000000 0.000000000
 4774 StatSess - xxx.xxx.xxx.xxx 1442 0 1 0 0 0 0 0 0
 4749 SessionOpen c xxx.xxx.xxx.xxx 2748 :80
10216 ReqStart c xxx.xxx.xxx.xxx 51324 1570384079
10216 RxRequest c GET
10216 RxURL        c /runescape/images/4/4c/Defence_cape.gif
10216 RxProtocol c HTTP/1.1
10216 RxHeader c Accept: */*
10216 RxHeader c Referer: http://runescape.wikia.com/wiki/Defence_cape
10216 RxHeader c Accept-Language: en-gb
10216 RxHeader c UA-CPU: x86
10216 RxHeader c Accept-Encoding: gzip, deflate
10216 RxHeader c User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; FunWebProducts; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET




                                                     • log all headers
CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
10216 RxHeader c Host: images3.wikia.nocookie.net
10216 RxHeader c Connection: Keep-Alive
10216 VCL_call c recv
10216 VCL_acl      c NO_MATCH SJC



                                                     • mmap logfile mlocked! (start as root)
10216 VCL_acl      c MATCH LON xxx.xxx.xxx.xxx
10216 VCL_return c lookup
10216 VCL_call c hash
10216 VCL_return c hash
10216 Hit       c 1216457642



                                                     • ringbuffer
10216 VCL_call c hit
10216 VCL_return c deliver
10216 Length      c 1851
10216 VCL_call c deliver
10216 VCL_acl      c NO_MATCH LON



                                                     • put it on tmpfs since kernel is
10216 VCL_acl      c NO_MATCH SJC
10216 VCL_acl      c NO_MATCH IOWA
10216 VCL_return c deliver
10216 TxProtocol c HTTP/1.1


                                                             retarded
10216 TxStatus c 200
10216 TxResponse c OK
10216 TxHeader c Cache-Control: max-age=30
10216 TxHeader c Content-Type: image/gif
10216 TxHeader c ETag: "209654623"
10216 TxHeader c Last-Modified: Thu, 12 Mar 2009 04:58:56 GMT
10216 TxHeader c Server: lighttpd/1.4.18
10216 TxHeader c Content-Length: 1851
61+09:08:16                                                             varnish9
Hitrate ratio:  10    16   16
Hitrate avg: 0.9274 0.9286 0.9286

 1554133248         377.00       293.05 Client connections accepted
 3978072764         867.00       750.11 Client requests received
 3614483333         801.00       681.55 Cache hits
   11639361         0.00        2.19 Cache hits for pass
  325788549         61.00        61.43 Cache misses
  182821195         19.00        34.47 Backend connections success



                                                                      varnishstat
     25954      0.00         0.00 Backend connections failures
  175872686         19.00        33.16 Backend connections reuses
  176615269         14.00        33.30 Backend connections recycles
     35452        .         . N struct sess_mem
     52444        .         . N struct sess
    2605151         .        . N struct object
    2532375         .        . N struct objecthead
    5293878         .        . N struct smf
     48126        .         . N small free smf
     33357        .         . N large free smf
       93     .           . N struct vbe_conn
      1427      .          . N struct bereq
      2000      .          . N worker threads
      2000     0.00          0.00 N worker threads created
      6447     0.00          0.00 N overflowed work requests
     13496      0.00         0.00 N dropped work requests
       19     .           . N backends
  163660934           .        . N expired objects
 1101311441             .       . N LRU moved objects
      2034     0.00          0.00 HTTP header overflows
 2296939595         419.00       433.12 Objects sent with write
 1554124359         368.00       293.05 Total Sessions
 3978485680         863.00       750.19 Total Requests
varnishhist




| cache hit
# cache miss
MEMLOCK=90000
DAEMON_OPTS="-a :80 
   -T localhost:6082 
   -s file,/var/lib/varnish,140GB
    -f /etc/varnish/wikia.vcl 
    -u varnish 
    -g users 
    -p obj_workspace=4096 
    -p sess_workspace=131072 
    -p listen_depth=8192 
    -p ping_interval=2 
    -p log_hashstring=off 
    -h classic,250007 
    -p thread_pool_max=8000 
    -p lru_interval=60 
    -p esi_syntax=0x00000003 
    -p sess_timeout=10 
    -p thread_pools=8 
    -p thread_pool_min=500 
    -p shm_workspace=32768 
    -p srcaddr_ttl=0
    -p thread_pool_add_delay=1"
MEMLOCK=90000
DAEMON_OPTS="-a :80 
   -T localhost:6082 
   -s file,/var/lib/varnish,140GB
    -f /etc/varnish/wikia.vcl 
    -u varnish 
    -g users 
    -p obj_workspace=4096 
    -p sess_workspace=131072 
    -p listen_depth=8192 
    -p ping_interval=2 
    -p log_hashstring=off 
    -h classic,250007 
    -p thread_pool_max=8000 
    -p lru_interval=60 
    -p esi_syntax=0x00000003 
    -p sess_timeout=10 
    -p thread_pools=8 
    -p thread_pool_min=500 
    -p shm_workspace=32768 
    -p srcaddr_ttl=0
    -p thread_pool_add_delay=1"
vcl

• Configuration language
• Transcoded into C
• Compiled
• Dynamically loaded
 • So you can embed assembly code :)
https://svn.wikia-code.com/utils/varnishhtcpd/wikia.vcl
sub vcl_recv {

     # normalize Accept-Encoding to reduce vary
     if (req.http.Accept-Encoding) {
       if (req.http.User-Agent ~ "MSIE 6") {
         unset req.http.Accept-Encoding;
       } elsif (req.http.Accept-Encoding ~ "gzip") {
         set req.http.Accept-Encoding = "gzip";
       } elsif (req.http.Accept-Encoding ~ "deflate") {
         set req.http.Accept-Encoding = "deflate";
       } else {
         unset req.http.Accept-Encoding;
       }
     }
     # clean out requests sent via curls -X mode and LWP
     if (req.url ~ "^http://") {
       set req.url = regsub(req.url, "http://[^/]*","");
     }

#only care about some cookies
  set req.http.X-Orig-Cookie = req.http.Cookie;
  if(req.http.Cookie ~ "(session|UserID|UserName|Token|LoggedOut)") {
    # dont do anything, the user is logged in
  } else {
    # dont care about any other cookies
    unset req.http.Cookie;
  }

     if(server.ip ~ SJC) {
         set req.backend = wikia;
     } else {
       if (server.ip ~ LON) {
           set req.backend = london_to_iowa;
       } else {
           set req.backend = origin_html_sjc;
       }
 }
     set req.grace = 3600s;
     lookup;

}
sub vcl_pipe {
  # do the right XFF processing
  set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
  set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", ", ");
  set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", client.ip);
  set bereq.http.Cookie = req.http.X-Orig-Cookie;
  set bereq.http.connection = "close";
}

sub vcl_hit {
  if (req.request == "PURGE") {
    set obj.ttl = 1s;
    set obj.grace = 5s;
    error 200 "Purged.";
  }
}

sub vcl_miss {

    if (req.request == "PURGE") {
      error 404 "Not purged";
    }

    set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
    set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", ", ");
    set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", client.ip);

    # for nef needs to be generic
    set bereq.http.Cookie = req.http.X-Orig-Cookie;

}
# if there isnt an expiry
   if (!resp.status == 304) {
     C{
        char *cache = VRT_GetHdr(sp, HDR_REQ, "016cache-control:");
        char date[40];
        int max_age;
        int want_equals = 0;
        if(cache) {

     while(*cache != '0') {

        if (want_equals && *cache == '=') {

          cache++;

          max_age = strtoul(cache, 0, 0);

          break;

        }


         if (*cache == 'm' && !memcmp(cache, "max-age", 7)) {

           cache += 7;

           want_equals = 1;

           continue;

         }

         cache++;

        }

        if (max_age) {

           TIM_format(TIM_real() + max_age, date);

           VRT_SetHdr(sp, HDR_RESP, "010Expires:", date, vrt_magic_string_end);

        }
           }
        }C
             #;
    }

    deliver;
}
tips
• noatime
• ext2 (need a journal for your cache?)
• no swap
• tmpfs for logfile
• raid0
• force a few second ttl to save the backend
• SSDs!
wikia

• 4 datacenters
• built our own CDN        mbit for lost finale
• rapid invalidations
• rabbitmq for invalids
• backend independant of
  traffic spikes
• Intel MLC SSDs           london datacenter
more info
• varnish.projects.linpro.no
• #varnish on irc.linpro.no
• http://varnish.projects.linpro.no/wiki/
  ArchitectNotes
• https://svn.wikia-code.com/utils/
  varnishhtcpd/wikia.vcl

Más contenido relacionado

La actualidad más candente

Introduction to Stacki at Atlanta Meetup February 2016
Introduction to Stacki at Atlanta Meetup February 2016Introduction to Stacki at Atlanta Meetup February 2016
Introduction to Stacki at Atlanta Meetup February 2016StackIQ
 
Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016StackIQ
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeSveta Smirnova
 
Varnish Web Accelerator
Varnish Web AcceleratorVarnish Web Accelerator
Varnish Web AcceleratorRahul Ghose
 
What is new in BIND 9.11?
What is new in BIND 9.11?What is new in BIND 9.11?
What is new in BIND 9.11?Men and Mice
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkRiyaj Shamsudeen
 
VUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareVUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareCosimo Streppone
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017Antonios Giannopoulos
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareSage Computing Services
 
Oracle 10g Performance: chapter 09 enqueues
Oracle 10g Performance: chapter 09 enqueuesOracle 10g Performance: chapter 09 enqueues
Oracle 10g Performance: chapter 09 enqueuesKyle Hailey
 
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Frederic Descamps
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...Miguel Lavalle
 
How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaCosimo Streppone
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applicationsTier1 app
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesRiyaj Shamsudeen
 
Designate Installation Workshop
Designate Installation WorkshopDesignate Installation Workshop
Designate Installation WorkshopGraham Hayes
 
Percona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL AdministrationPercona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL AdministrationMydbops
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 

La actualidad más candente (20)

Redo internals ppt
Redo internals pptRedo internals ppt
Redo internals ppt
 
Introduction to Stacki at Atlanta Meetup February 2016
Introduction to Stacki at Atlanta Meetup February 2016Introduction to Stacki at Atlanta Meetup February 2016
Introduction to Stacki at Atlanta Meetup February 2016
 
Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016Salesforce at Stacki Atlanta Meetup February 2016
Salesforce at Stacki Atlanta Meetup February 2016
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-Tree
 
Varnish Web Accelerator
Varnish Web AcceleratorVarnish Web Accelerator
Varnish Web Accelerator
 
What is new in BIND 9.11?
What is new in BIND 9.11?What is new in BIND 9.11?
What is new in BIND 9.11?
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 
VUG5: Varnish at Opera Software
VUG5: Varnish at Opera SoftwareVUG5: Varnish at Opera Software
VUG5: Varnish at Opera Software
 
Varnish 4 cool features
Varnish 4 cool featuresVarnish 4 cool features
Varnish 4 cool features
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning Nightmare
 
Oracle 10g Performance: chapter 09 enqueues
Oracle 10g Performance: chapter 09 enqueuesOracle 10g Performance: chapter 09 enqueues
Oracle 10g Performance: chapter 09 enqueues
 
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016Advanced percona xtra db cluster in a nutshell... la suite plsc2016
Advanced percona xtra db cluster in a nutshell... la suite plsc2016
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...
 
How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at Opera
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issues
 
Designate Installation Workshop
Designate Installation WorkshopDesignate Installation Workshop
Designate Installation Workshop
 
Percona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL AdministrationPercona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL Administration
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 

Destacado

Apache Cassandra Training,Apache Cassandra Training in Bangalore india
Apache Cassandra Training,Apache Cassandra Training in Bangalore indiaApache Cassandra Training,Apache Cassandra Training in Bangalore india
Apache Cassandra Training,Apache Cassandra Training in Bangalore indiasharepointexpert
 
Webinar Cassandra Anti-Patterns
Webinar Cassandra Anti-PatternsWebinar Cassandra Anti-Patterns
Webinar Cassandra Anti-PatternsChristopher Batey
 
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...Amazon Web Services
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web CacheProdigyView
 
Apache Cassandra Developer Training Slide Deck
Apache Cassandra Developer Training Slide DeckApache Cassandra Developer Training Slide Deck
Apache Cassandra Developer Training Slide DeckDataStax Academy
 
Just use SSDs, really really.
Just use SSDs, really really.Just use SSDs, really really.
Just use SSDs, really really.Artur Bergman
 
Full-Stack Development
Full-Stack DevelopmentFull-Stack Development
Full-Stack DevelopmentDhilipsiva DS
 
Proxy Caches and Web Application Security
Proxy Caches and Web Application SecurityProxy Caches and Web Application Security
Proxy Caches and Web Application Security Tim Bass
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) Sascha Sambale
 
The Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLThe Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLAshnikbiz
 
Reverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishReverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishEl Mahdi Benzekri
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014Simona Clapan
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of EverythingCharbel Zeaiter
 

Destacado (17)

Apache Cassandra Training,Apache Cassandra Training in Bangalore india
Apache Cassandra Training,Apache Cassandra Training in Bangalore indiaApache Cassandra Training,Apache Cassandra Training in Bangalore india
Apache Cassandra Training,Apache Cassandra Training in Bangalore india
 
Webinar Cassandra Anti-Patterns
Webinar Cassandra Anti-PatternsWebinar Cassandra Anti-Patterns
Webinar Cassandra Anti-Patterns
 
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...
(WEB204) Speeding Up Your Site's Performance with a Web Cache | AWS re:Invent...
 
Understanding Web Cache
Understanding Web CacheUnderstanding Web Cache
Understanding Web Cache
 
Apache Cassandra Developer Training Slide Deck
Apache Cassandra Developer Training Slide DeckApache Cassandra Developer Training Slide Deck
Apache Cassandra Developer Training Slide Deck
 
Just use SSDs, really really.
Just use SSDs, really really.Just use SSDs, really really.
Just use SSDs, really really.
 
PostgreSQL Query Cache - "pqc"
PostgreSQL Query Cache - "pqc"PostgreSQL Query Cache - "pqc"
PostgreSQL Query Cache - "pqc"
 
Full-Stack Development
Full-Stack DevelopmentFull-Stack Development
Full-Stack Development
 
Web Proxy Server
Web Proxy ServerWeb Proxy Server
Web Proxy Server
 
Proxy Caches and Web Application Security
Proxy Caches and Web Application SecurityProxy Caches and Web Application Security
Proxy Caches and Web Application Security
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
 
The Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLThe Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQL
 
Proxy Server
Proxy ServerProxy Server
Proxy Server
 
Reverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishReverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and Varnish
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
 

Similar a Varnish @ Velocity Ignite

Varnish in action pbc10
Varnish in action pbc10Varnish in action pbc10
Varnish in action pbc10Combell NV
 
Varnish in action phpuk11
Varnish in action phpuk11Varnish in action phpuk11
Varnish in action phpuk11Combell NV
 
Debugging linux issues with eBPF
Debugging linux issues with eBPFDebugging linux issues with eBPF
Debugging linux issues with eBPFIvan Babrou
 
Varnish in action phpday2011
Varnish in action phpday2011Varnish in action phpday2011
Varnish in action phpday2011Combell NV
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in floridaSisimon Soman
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Ontico
 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorialEueung Mulyana
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part IIIAlkin Tezuysal
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨flyinweb
 
Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com confluent
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterAndrey Kudryavtsev
 
Fundamentals of Physical Memory Analysis
Fundamentals of Physical Memory AnalysisFundamentals of Physical Memory Analysis
Fundamentals of Physical Memory AnalysisDmitry Vostokov
 
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPROIDEA
 
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicHow to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicCircling Cycle
 

Similar a Varnish @ Velocity Ignite (20)

Varnish in action pbc10
Varnish in action pbc10Varnish in action pbc10
Varnish in action pbc10
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Varnish in action phpuk11
Varnish in action phpuk11Varnish in action phpuk11
Varnish in action phpuk11
 
Debugging linux issues with eBPF
Debugging linux issues with eBPFDebugging linux issues with eBPF
Debugging linux issues with eBPF
 
Varnish in action phpday2011
Varnish in action phpday2011Varnish in action phpday2011
Varnish in action phpday2011
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
Windows kernel debugging workshop in florida
Windows kernel debugging   workshop in floridaWindows kernel debugging   workshop in florida
Windows kernel debugging workshop in florida
 
Quic illustrated
Quic illustratedQuic illustrated
Quic illustrated
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Open stack pike-devstack-tutorial
Open stack pike-devstack-tutorialOpen stack pike-devstack-tutorial
Open stack pike-devstack-tutorial
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part III
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Fundamentals of Physical Memory Analysis
Fundamentals of Physical Memory AnalysisFundamentals of Physical Memory Analysis
Fundamentals of Physical Memory Analysis
 
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
 
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicHow to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
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...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Varnish @ Velocity Ignite

  • 2. • HTTP accelerator • reverse proxy • cache • very fast • very much faster than squid • open source
  • 3. Outsources tasks • architecture relies on kernel functions • threads • massively multithreaded • part event driven • mmap
  • 4. mmap • maps the store into memory • (or alternatively use jemalloc) • (makes kswapd use 100% cpu -- bad linux) • madvise(MADV_RANDOM) • writev directly from mapped memory
  • 5. 4725 SessionOpen c xxx.xxx.xxx.xxx 1441 :80 mmap logfile 4774 ReqEnd - 0 1245712664.794090033 1245712664.794090033 0.003499746 0.000000000 0.000000000 4774 StatSess - xxx.xxx.xxx.xxx 1442 0 1 0 0 0 0 0 0 4749 SessionOpen c xxx.xxx.xxx.xxx 2748 :80 10216 ReqStart c xxx.xxx.xxx.xxx 51324 1570384079 10216 RxRequest c GET 10216 RxURL c /runescape/images/4/4c/Defence_cape.gif 10216 RxProtocol c HTTP/1.1 10216 RxHeader c Accept: */* 10216 RxHeader c Referer: http://runescape.wikia.com/wiki/Defence_cape 10216 RxHeader c Accept-Language: en-gb 10216 RxHeader c UA-CPU: x86 10216 RxHeader c Accept-Encoding: gzip, deflate 10216 RxHeader c User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; FunWebProducts; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET • log all headers CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0) 10216 RxHeader c Host: images3.wikia.nocookie.net 10216 RxHeader c Connection: Keep-Alive 10216 VCL_call c recv 10216 VCL_acl c NO_MATCH SJC • mmap logfile mlocked! (start as root) 10216 VCL_acl c MATCH LON xxx.xxx.xxx.xxx 10216 VCL_return c lookup 10216 VCL_call c hash 10216 VCL_return c hash 10216 Hit c 1216457642 • ringbuffer 10216 VCL_call c hit 10216 VCL_return c deliver 10216 Length c 1851 10216 VCL_call c deliver 10216 VCL_acl c NO_MATCH LON • put it on tmpfs since kernel is 10216 VCL_acl c NO_MATCH SJC 10216 VCL_acl c NO_MATCH IOWA 10216 VCL_return c deliver 10216 TxProtocol c HTTP/1.1 retarded 10216 TxStatus c 200 10216 TxResponse c OK 10216 TxHeader c Cache-Control: max-age=30 10216 TxHeader c Content-Type: image/gif 10216 TxHeader c ETag: "209654623" 10216 TxHeader c Last-Modified: Thu, 12 Mar 2009 04:58:56 GMT 10216 TxHeader c Server: lighttpd/1.4.18 10216 TxHeader c Content-Length: 1851
  • 6. 61+09:08:16 varnish9 Hitrate ratio: 10 16 16 Hitrate avg: 0.9274 0.9286 0.9286 1554133248 377.00 293.05 Client connections accepted 3978072764 867.00 750.11 Client requests received 3614483333 801.00 681.55 Cache hits 11639361 0.00 2.19 Cache hits for pass 325788549 61.00 61.43 Cache misses 182821195 19.00 34.47 Backend connections success varnishstat 25954 0.00 0.00 Backend connections failures 175872686 19.00 33.16 Backend connections reuses 176615269 14.00 33.30 Backend connections recycles 35452 . . N struct sess_mem 52444 . . N struct sess 2605151 . . N struct object 2532375 . . N struct objecthead 5293878 . . N struct smf 48126 . . N small free smf 33357 . . N large free smf 93 . . N struct vbe_conn 1427 . . N struct bereq 2000 . . N worker threads 2000 0.00 0.00 N worker threads created 6447 0.00 0.00 N overflowed work requests 13496 0.00 0.00 N dropped work requests 19 . . N backends 163660934 . . N expired objects 1101311441 . . N LRU moved objects 2034 0.00 0.00 HTTP header overflows 2296939595 419.00 433.12 Objects sent with write 1554124359 368.00 293.05 Total Sessions 3978485680 863.00 750.19 Total Requests
  • 8. MEMLOCK=90000 DAEMON_OPTS="-a :80 -T localhost:6082 -s file,/var/lib/varnish,140GB -f /etc/varnish/wikia.vcl -u varnish -g users -p obj_workspace=4096 -p sess_workspace=131072 -p listen_depth=8192 -p ping_interval=2 -p log_hashstring=off -h classic,250007 -p thread_pool_max=8000 -p lru_interval=60 -p esi_syntax=0x00000003 -p sess_timeout=10 -p thread_pools=8 -p thread_pool_min=500 -p shm_workspace=32768 -p srcaddr_ttl=0 -p thread_pool_add_delay=1"
  • 9. MEMLOCK=90000 DAEMON_OPTS="-a :80 -T localhost:6082 -s file,/var/lib/varnish,140GB -f /etc/varnish/wikia.vcl -u varnish -g users -p obj_workspace=4096 -p sess_workspace=131072 -p listen_depth=8192 -p ping_interval=2 -p log_hashstring=off -h classic,250007 -p thread_pool_max=8000 -p lru_interval=60 -p esi_syntax=0x00000003 -p sess_timeout=10 -p thread_pools=8 -p thread_pool_min=500 -p shm_workspace=32768 -p srcaddr_ttl=0 -p thread_pool_add_delay=1"
  • 10. vcl • Configuration language • Transcoded into C • Compiled • Dynamically loaded • So you can embed assembly code :)
  • 11. https://svn.wikia-code.com/utils/varnishhtcpd/wikia.vcl sub vcl_recv { # normalize Accept-Encoding to reduce vary if (req.http.Accept-Encoding) { if (req.http.User-Agent ~ "MSIE 6") { unset req.http.Accept-Encoding; } elsif (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; } elsif (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { unset req.http.Accept-Encoding; } } # clean out requests sent via curls -X mode and LWP if (req.url ~ "^http://") { set req.url = regsub(req.url, "http://[^/]*",""); } #only care about some cookies set req.http.X-Orig-Cookie = req.http.Cookie; if(req.http.Cookie ~ "(session|UserID|UserName|Token|LoggedOut)") { # dont do anything, the user is logged in } else { # dont care about any other cookies unset req.http.Cookie; } if(server.ip ~ SJC) { set req.backend = wikia; } else { if (server.ip ~ LON) { set req.backend = london_to_iowa; } else { set req.backend = origin_html_sjc; } } set req.grace = 3600s; lookup; }
  • 12. sub vcl_pipe { # do the right XFF processing set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For; set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", ", "); set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", client.ip); set bereq.http.Cookie = req.http.X-Orig-Cookie; set bereq.http.connection = "close"; } sub vcl_hit { if (req.request == "PURGE") { set obj.ttl = 1s; set obj.grace = 5s; error 200 "Purged."; } } sub vcl_miss { if (req.request == "PURGE") { error 404 "Not purged"; } set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For; set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", ", "); set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", client.ip); # for nef needs to be generic set bereq.http.Cookie = req.http.X-Orig-Cookie; }
  • 13. # if there isnt an expiry if (!resp.status == 304) { C{ char *cache = VRT_GetHdr(sp, HDR_REQ, "016cache-control:"); char date[40]; int max_age; int want_equals = 0; if(cache) { while(*cache != '0') { if (want_equals && *cache == '=') { cache++; max_age = strtoul(cache, 0, 0); break; } if (*cache == 'm' && !memcmp(cache, "max-age", 7)) { cache += 7; want_equals = 1; continue; } cache++; } if (max_age) { TIM_format(TIM_real() + max_age, date); VRT_SetHdr(sp, HDR_RESP, "010Expires:", date, vrt_magic_string_end); } } }C #; } deliver; }
  • 14. tips • noatime • ext2 (need a journal for your cache?) • no swap • tmpfs for logfile • raid0 • force a few second ttl to save the backend • SSDs!
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. wikia • 4 datacenters • built our own CDN mbit for lost finale • rapid invalidations • rabbitmq for invalids • backend independant of traffic spikes • Intel MLC SSDs london datacenter
  • 20. more info • varnish.projects.linpro.no • #varnish on irc.linpro.no • http://varnish.projects.linpro.no/wiki/ ArchitectNotes • https://svn.wikia-code.com/utils/ varnishhtcpd/wikia.vcl