Lost in Translation:varnishlog, varnishtest(VUG7)

3,323 views
3,216 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,323
On SlideShare
0
From Embeds
0
Number of Embeds
2,517
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Lost in Translation:varnishlog, varnishtest(VUG7)

  1. 1. Copyright © GREE, Inc. All Rights Reserved.Copyright © GREE, Inc. All Rights Reserved.Lost in Translation:varnishlog, varnishtest~The Story of a Successful Migration~GREE, inc.Shohei TanakaVarnish User Group Meeting 7Friday, May 31st 2013
  2. 2. Copyright © GREE, Inc. All Rights Reserved.Who am IShohei Tanaka (@xcir)- Call me iwana-chan- GREE, inc.- Joined 2013/01~- Tokyo, Japan- Activities at varnish project- VMOD author- ldap, redirect, parsereq, awsrest and more..- Wrote Japanese Varnish guidebook- Other- blog http://blog.xcir.net/- github http://github.com/xcir/
  3. 3. Copyright © GREE, Inc. All Rights Reserved.Migration from legacy systemFinished without any downtime- Platform downtime was not an option- Domain / backend has more than a hundred columns- Very high- Traffic- Connection/sec- Request/sec- Many target device types- PC- Smartphone- Mobile phone (No support for keep-alive)
  4. 4. Copyright © GREE, Inc. All Rights Reserved.New systemServer layout- 3 layer model- Use Hash director- Objects wont beduplicatedacross L2 pool- ImageOperation- Apache + Varnish- Create thumbs- mod_small_light- Generate barcode(QR)- GREE original
  5. 5. Copyright © GREE, Inc. All Rights Reserved.New systemVCL layout- Common settings- Same for all server roles- Security, ACL, Normalize....- Individual server role settings- Backend, Rewrite...- Divide action by- Type (categorized domain)- Domain (cant categorize)
  6. 6. Copyright © GREE, Inc. All Rights Reserved.Why Varnish?GREE had never used it- VCL- Very powerful DSL- Fits into existing system- Healthcheck- Varnishtest- Can define the behavior of the server, client, varnish.- Useful tools- varnishncsa and varnishlog are very useful- libvarnishapi can connect to VSL easily- And I love Varnish ;-)
  7. 7. Copyright © GREE, Inc. All Rights Reserved.Testing, Testing, Testing!We used varnishtest- Different package for common and server roles- Unit tests for common settings- Integration tests for common + server role
  8. 8. Copyright © GREE, Inc. All Rights Reserved.varnishtest(failed log)I love it, but its difficult to read
  9. 9. Copyright © GREE, Inc. All Rights Reserved.varnishtest(failed log)I love it, but its difficult to read
  10. 10. Copyright © GREE, Inc. All Rights Reserved.vtctrans.pyHuman readable ;)- Sort by- Event- Error output- Header and expected result- Macro definehttps://github.com/xcir/vtctrans
  11. 11. Copyright © GREE, Inc. All Rights Reserved.ScreenshotEventvarnishtestvtctrans
  12. 12. Copyright © GREE, Inc. All Rights Reserved.ScreenshotEventvarnishtestvtctrans
  13. 13. Copyright © GREE, Inc. All Rights Reserved.ScreenshotMacro listvarnishtestvtctrans
  14. 14. Copyright © GREE, Inc. All Rights Reserved.ScreenshotMacro listvarnishtestvtctrans
  15. 15. Copyright © GREE, Inc. All Rights Reserved.ScreenshotHeader and expected resultvtctrans varnishtest
  16. 16. Copyright © GREE, Inc. All Rights Reserved.ScreenshotHeader and expected resultvtctrans varnishtest
  17. 17. Copyright © GREE, Inc. All Rights Reserved.Performance tuningMeasure, dont guess- Nevertheless, capacity planning is important :)- runtime parameters- server specs, placement- fault tolerance (keep service up even when a rack fails)- Measure with production servers, its the most importantthing- Useful commands- varnishncsa -m "txstatus:^[45]"- varnishstat- varnishhist -m "rxheader:Host: foo"- varnishlog -m "rxurl:/foo/bar"- Used varnishncsa and varnishlog alot
  18. 18. Copyright © GREE, Inc. All Rights Reserved.varnishlogugly
  19. 19. Copyright © GREE, Inc. All Rights Reserved.vsltrans.py(old:vltrans.php)beautiful!- Sort by- Error output- VCL action- variable- hash and vary- can use multiple -m optionhttps://github.com/xcir/vsltrans
  20. 20. Copyright © GREE, Inc. All Rights Reserved.ScreenshotGeneral, Error, Hash, Vary infovsltransand more...varnishlog
  21. 21. Copyright © GREE, Inc. All Rights Reserved.ScreenshotGeneral, Error, Hash, Vary infovsltransand more...varnishlog
  22. 22. Copyright © GREE, Inc. All Rights Reserved.ScreenshotActionvsltransvarnishlog
  23. 23. Copyright © GREE, Inc. All Rights Reserved.ScreenshotActionvsltransvarnishlog
  24. 24. Copyright © GREE, Inc. All Rights Reserved.ScreenshotVariablevsltransvarnishlog
  25. 25. Copyright © GREE, Inc. All Rights Reserved.ScreenshotVariablevsltransvarnishlog
  26. 26. Copyright © GREE, Inc. All Rights Reserved.More measurements- By different host- Cache hit rate- Transfer size per sec- Request per sec- By directory (specify depth)- Cache hit rate- Transfer size per sec- Request per sec- And more...
  27. 27. Copyright © GREE, Inc. All Rights Reserved.Why do we need a detailedmeasurements?- Hit rate is summarized by default- Different costs for different objects- Dynamic object: high cost- Static object: low cost- Its necessary to separate results by object cost- Need to consider system cost instead of justVarnish hit rate- However you cannot do this with just the defaultcommandsThats where libvarnishapi comes in
  28. 28. Copyright © GREE, Inc. All Rights Reserved.libvarnishapi.so- VSL access is easy with libvarnishapi- uses varnishlog, varnishncsa- Used Python ctypes and it proved to be very simple to use- Sample codehttps://github.com/xcir/python-varnishapi
  29. 29. Copyright © GREE, Inc. All Rights Reserved.python-varnishapi sample- VSL data output sample- Made it slightly more readable ;)
  30. 30. Copyright © GREE, Inc. All Rights Reserved.python-varnishapi sample
  31. 31. Copyright © GREE, Inc. All Rights Reserved.python-varnishapi sample
  32. 32. Copyright © GREE, Inc. All Rights Reserved.libvarnishapi: very easy to useHack on with libvarnishapi and Varnish!Better than making a measuring toolfrom scratch
  33. 33. Copyright © GREE, Inc. All Rights Reserved.Thank you for yourattention!Any Questions?@xcirhttp://blog.xcir.net/https://github.com/xcir/vtctranshttps://github.com/xcir/vsltranshttps://github.com/xcir/python-varnishapi

×