SlideShare a Scribd company logo
Debugging varnish
Varnish
Debugging
Martin Blix Grydeland
Senior Developer
WHO AM I?
VCL debugging
VCL debugging
● Code not reached, wrong logic or expectations
● varnishlog is the answer
● varnishncsa is not
varnishlog
$ varnishlog -g request
- Begin req 459063 rxreq
- Timestamp Start: 1474493939.499338 0.000000 0.000000
- Timestamp Req: 1474493939.499338 0.000000 0.000000
- ReqStart 1.2.3.4 38780
- ReqMethod GET
- ReqURL /
- ReqProtocol HTTP/1.1
- ReqHeader Host: example.com
- ReqHeader Accept: */*
- ReqHeader Accept-Encoding: gzip
- ReqHeader User-Agent: Mozilla/5.0 (X11; Linux x86_64) ...
- ReqHeader Connection: close
- ReqHeader X-Forwarded-For: 1.2.3.4
- VCL_call RECV
- VCL_return hash
- VCL_call HASH
- VCL_return lookup
- VCL_call MISS
...
varnishlog examples
● [5-9]xx responses:
o varnishlog -q 'RespStatus >= 500'
● Misses:
o varnishlog -q 'VCL_call ~ MISS'
● Timing details:
o varnishlog -i Timestamp
● Requests taking more than 5 seconds:
Transactions
Session
Request
Request BeReq
ESI-SubReq
BeReq
-g <session|request|vxid|raw>
The grouping of the log
records.
The default is to group by vxid.
Debugging with varnishlog
● man vsl
● printf debugging (std.log / std.syslog)
● Enable tracing (param.set vsl_mask +VCL_trace)
● Reproduce with varnishtest
Timestamps
Timestamp - Timing information
Contains timing information for the Varnish worker threads.
The format is:
%s: %f %f %f
| | | |
| | | +- Time since last timestamp
| | +---- Time since start of work unit
| +------- Absolute time of event
+----------- Event label
Timestamped events
Requests:
Start The start of request processing (first byte received or restart).
Req Complete client request received.
ReqBody Client request body processed (discarded, cached or passed to the backend).
Waitinglist Came off waitinglist.
Fetch Fetch processing finished (completely fetched or ready for streaming).
Process Processing finished, ready to deliver the client response.
Resp Delivery of response to the client finished.
Restart Client request is being restarted.
Backend requests:
Start Start of the backend fetch processing.
Bereq Backend request sent.
Beresp Backend response headers received.
BerespBody Backend response body received.
Retry Backend request is being retried.
Error Backend request failed to vcl_backend_error.
varnishtest - example
varnishtest "Hello world"
server s1 {
rxreq
expect req.http.msg == "hello"
txresp -body "world"
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
set req.http.msg = "hello";
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.body == "world"
} -run
[vagrant@centos-7-amd64 ~]$ varnishtest -v example.vtc
…
**** s1 0.4 EXPECT req.http.msg (hello) == "hello" match
…
*** c1 0.4 expect
**** c1 0.4 EXPECT resp.status (200) == "200" match
*** c1 0.4 expect
**** c1 0.4 EXPECT resp.body (world) == "world" match
…
# top TEST example.vtc passed (1.494)
support@
https://github.com/varnish/varnishgather
● Reduce round trip time
● Versions
● varnishlog
● varnishstat
● VCL
● varnishadm panic.show
● syslog
DON'T PANIC
Stability
● Crash, panic or something else
● Check varnishadm panic.show and syslog
● File a bug or get your hands dirty
Getting your hands dirty
● Not for the faint of heart
● The panic dump
● Install debugging symbols and allow coredumps
● thread apply all bt full
● My approach: backtracking
○ Defensive programming
THE END

More Related Content

PDF
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
PDF
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
KEY
VCLをTDDで書いてデプロイする
PPTX
Who Broke My Crypto
PDF
Solving some of the scalability problems at booking.com
PDF
Load Balancing with Nginx
PDF
What is new in Go 1.8
PDF
Eduardo Silva - monkey http-server everywhere
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
VCLをTDDで書いてデプロイする
Who Broke My Crypto
Solving some of the scalability problems at booking.com
Load Balancing with Nginx
What is new in Go 1.8
Eduardo Silva - monkey http-server everywhere

What's hot (20)

PDF
Secure Communications with VisualWorks - CSTUC 2006
PDF
T.Pollak y C.Yaconi - Prey
PDF
NginX - good practices, tips and advanced techniques
PDF
Kubernetes at Datadog Scale
PDF
Service discovery like a pro (presented at reversimX)
PDF
Benchmarking for HTTP/2
PDF
Network Programming With Anyevent
PDF
Nginx + PHP
PDF
Perl Instruments
PDF
Trevor McDonald - Nagios XI Under The Hood
PDF
Chap 19 web
PDF
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
PDF
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
ODP
Nmap Scripting Engine and http-enumeration
PDF
17937858 squid-server - [the-xp.blogspot.com]
PDF
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...
PDF
Janice Singh - Writing Custom Nagios Plugins
PDF
Importance of linux system fundamental in technical documentation reading
PDF
OSMC 2014: Monitoring VoIP Systems | Sebastian Damm
PDF
Varnish SSL / TLS
Secure Communications with VisualWorks - CSTUC 2006
T.Pollak y C.Yaconi - Prey
NginX - good practices, tips and advanced techniques
Kubernetes at Datadog Scale
Service discovery like a pro (presented at reversimX)
Benchmarking for HTTP/2
Network Programming With Anyevent
Nginx + PHP
Perl Instruments
Trevor McDonald - Nagios XI Under The Hood
Chap 19 web
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Nessus scan report using microsoft patchs scan policy - Tareq Hanaysha
Nmap Scripting Engine and http-enumeration
17937858 squid-server - [the-xp.blogspot.com]
Help, my browser is leaking! Exploring XSLeaks attacks and defenses - Tom Van...
Janice Singh - Writing Custom Nagios Plugins
Importance of linux system fundamental in technical documentation reading
OSMC 2014: Monitoring VoIP Systems | Sebastian Damm
Varnish SSL / TLS
Ad

Viewers also liked (20)

PDF
E-commerce use case
PDF
Lightning fast with Varnish
PDF
A Novel Algorithm for Acoustic and Visual Classifiers Decision Fusion in Audi...
PPTX
Varnish TLS
PDF
Varnish cache en ocho pasos
PDF
انظمه التحكم ف الابواب
PDF
VCL - the logic and logistics
PPTX
PDF
3582_0001
PDF
De idea a implementación con Varnish Plus
DOCX
Secretarias, la mano derecha del poder.
PDF
SCOPE Certificate
PDF
De idea a implementación con Varnish Plus
PPTX
Նոր Տարին և Սուրբ Ծնունդը Ընտանիքով
PDF
Access control
PDF
VCL - the logic and logistics
PDF
Multi skilling Electriacl
PDF
Secure content caching
PDF
Using PatSeer to search and analyze patents in Switchgear Technology
E-commerce use case
Lightning fast with Varnish
A Novel Algorithm for Acoustic and Visual Classifiers Decision Fusion in Audi...
Varnish TLS
Varnish cache en ocho pasos
انظمه التحكم ف الابواب
VCL - the logic and logistics
3582_0001
De idea a implementación con Varnish Plus
Secretarias, la mano derecha del poder.
SCOPE Certificate
De idea a implementación con Varnish Plus
Նոր Տարին և Սուրբ Ծնունդը Ընտանիքով
Access control
VCL - the logic and logistics
Multi skilling Electriacl
Secure content caching
Using PatSeer to search and analyze patents in Switchgear Technology
Ad

Similar to Debugging varnish (20)

PDF
HTTP logging with varnishlog (Brussels PHP 2022)
PDF
Debugging your varnish instance
PDF
HTTP logging met Varnishlog - PHPWVL 2022
PDF
The Subtle Art Of Cache Invalidation (FOSSingapore 2024)
KEY
Varnish @ Velocity Ignite
PDF
Varnish presentation for the Symfony Zaragoza user group
PDF
Varnish Cache 4.0 / Redpill Linpro breakfast in Oslo
ODP
PHP London Dec 2013 - Varnish - The 9 circles of hell
PDF
Supercharging Content Delivery with Varnish
PDF
Varnish Cache
PPTX
Varnish
PDF
Haproxy - zastosowania
PPT
Nginx internals
ODP
Varnish qconsp 2011
PPTX
Learn nginx in 90mins
PDF
VUG5: Varnish at Opera Software
PDF
Apache httpd reverse proxy and Tomcat
PDF
Go 1.8 'new' networking features
KEY
HTTP logging with varnishlog (Brussels PHP 2022)
Debugging your varnish instance
HTTP logging met Varnishlog - PHPWVL 2022
The Subtle Art Of Cache Invalidation (FOSSingapore 2024)
Varnish @ Velocity Ignite
Varnish presentation for the Symfony Zaragoza user group
Varnish Cache 4.0 / Redpill Linpro breakfast in Oslo
PHP London Dec 2013 - Varnish - The 9 circles of hell
Supercharging Content Delivery with Varnish
Varnish Cache
Varnish
Haproxy - zastosowania
Nginx internals
Varnish qconsp 2011
Learn nginx in 90mins
VUG5: Varnish at Opera Software
Apache httpd reverse proxy and Tomcat
Go 1.8 'new' networking features

More from Varnish Software (20)

PDF
Ask Me Anything on authentication & authorisation in Varnish
PDF
Boozt.com Use Case
PPTX
Akamai connector for varnish
PPTX
Varnish High Availability
PDF
PostNord: Copy On Write
PPTX
Varnish extend
PDF
Streaming with Varnish
PPTX
Edgestash
PPTX
What is new in varnish plus
PDF
Varnish Extend demo
PDF
Varnish extend introduction
PDF
Cedexis introduction
PDF
Microservices
PDF
Varnishtest
PDF
Varnish plus con paywall avanzado en la voz de galicia
PDF
Detalles técnicos e impacto de negocio de varnish plus
PDF
Debugging forensics
PDF
SFR use case
PDF
Kering use case
PDF
Handelsbanken use case
Ask Me Anything on authentication & authorisation in Varnish
Boozt.com Use Case
Akamai connector for varnish
Varnish High Availability
PostNord: Copy On Write
Varnish extend
Streaming with Varnish
Edgestash
What is new in varnish plus
Varnish Extend demo
Varnish extend introduction
Cedexis introduction
Microservices
Varnishtest
Varnish plus con paywall avanzado en la voz de galicia
Detalles técnicos e impacto de negocio de varnish plus
Debugging forensics
SFR use case
Kering use case
Handelsbanken use case

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Machine Learning_overview_presentation.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
Spectroscopy.pptx food analysis technology
Machine Learning_overview_presentation.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Debugging varnish

  • 3. Martin Blix Grydeland Senior Developer WHO AM I?
  • 5. VCL debugging ● Code not reached, wrong logic or expectations ● varnishlog is the answer ● varnishncsa is not
  • 6. varnishlog $ varnishlog -g request - Begin req 459063 rxreq - Timestamp Start: 1474493939.499338 0.000000 0.000000 - Timestamp Req: 1474493939.499338 0.000000 0.000000 - ReqStart 1.2.3.4 38780 - ReqMethod GET - ReqURL / - ReqProtocol HTTP/1.1 - ReqHeader Host: example.com - ReqHeader Accept: */* - ReqHeader Accept-Encoding: gzip - ReqHeader User-Agent: Mozilla/5.0 (X11; Linux x86_64) ... - ReqHeader Connection: close - ReqHeader X-Forwarded-For: 1.2.3.4 - VCL_call RECV - VCL_return hash - VCL_call HASH - VCL_return lookup - VCL_call MISS ...
  • 7. varnishlog examples ● [5-9]xx responses: o varnishlog -q 'RespStatus >= 500' ● Misses: o varnishlog -q 'VCL_call ~ MISS' ● Timing details: o varnishlog -i Timestamp ● Requests taking more than 5 seconds:
  • 8. Transactions Session Request Request BeReq ESI-SubReq BeReq -g <session|request|vxid|raw> The grouping of the log records. The default is to group by vxid.
  • 9. Debugging with varnishlog ● man vsl ● printf debugging (std.log / std.syslog) ● Enable tracing (param.set vsl_mask +VCL_trace) ● Reproduce with varnishtest
  • 10. Timestamps Timestamp - Timing information Contains timing information for the Varnish worker threads. The format is: %s: %f %f %f | | | | | | | +- Time since last timestamp | | +---- Time since start of work unit | +------- Absolute time of event +----------- Event label
  • 11. Timestamped events Requests: Start The start of request processing (first byte received or restart). Req Complete client request received. ReqBody Client request body processed (discarded, cached or passed to the backend). Waitinglist Came off waitinglist. Fetch Fetch processing finished (completely fetched or ready for streaming). Process Processing finished, ready to deliver the client response. Resp Delivery of response to the client finished. Restart Client request is being restarted. Backend requests: Start Start of the backend fetch processing. Bereq Backend request sent. Beresp Backend response headers received. BerespBody Backend response body received. Retry Backend request is being retried. Error Backend request failed to vcl_backend_error.
  • 12. varnishtest - example varnishtest "Hello world" server s1 { rxreq expect req.http.msg == "hello" txresp -body "world" } -start varnish v1 -vcl+backend { sub vcl_recv { set req.http.msg = "hello"; } } -start client c1 { txreq rxresp expect resp.status == 200 expect resp.body == "world" } -run [vagrant@centos-7-amd64 ~]$ varnishtest -v example.vtc … **** s1 0.4 EXPECT req.http.msg (hello) == "hello" match … *** c1 0.4 expect **** c1 0.4 EXPECT resp.status (200) == "200" match *** c1 0.4 expect **** c1 0.4 EXPECT resp.body (world) == "world" match … # top TEST example.vtc passed (1.494)
  • 14. https://github.com/varnish/varnishgather ● Reduce round trip time ● Versions ● varnishlog ● varnishstat ● VCL ● varnishadm panic.show ● syslog
  • 16. Stability ● Crash, panic or something else ● Check varnishadm panic.show and syslog ● File a bug or get your hands dirty
  • 17. Getting your hands dirty ● Not for the faint of heart ● The panic dump ● Install debugging symbols and allow coredumps ● thread apply all bt full ● My approach: backtracking ○ Defensive programming