remove web calls and scale your site like crazy !

Download Remove web calls and scale your site like crazy !

If you can't read please download the document

Upload: wim-godden

Post on 20-Jun-2015

54.486 views

Category:

Technology


0 download

DESCRIPTION

Although tools like Varnish can improve performance and scalability for static sites, when user-specific content is needed, a hit to the PHP/Ruby/Python/.Net backend is still required, causing scalability issues. We'll look at a brand-new Nginx module which implements an ultra-fast and scalable solution to solve this problem, changing the way you think about designing sites with user-specific content.

TRANSCRIPT

  • 1. Remove PHP calls&scale your site like crazy ! Wim Godden Cu.be Solutions

2. Who am I ? Wim Godden (@wimgtr) Owner of Cu.be Solutions (http://cu.be) PHP developer since 1997 Developer of OpenX Zend Certified Engineer Zend Framework Certified Engineer MySQL Certified Developer Speaker at PHP and Open Source conferences 3. Who are you ? Developers ? System/network engineers ? Managers ? 4. Were at a PHP conference... and Im going to show you how to use less PHP 5. To understand the presentUnderstand the past 6. The Stone AgeNew blog post by : caveman003 7. Pre-PHP : draw it and make html 8. The Egyptian Era 9. Old-school PHP : rebuild-every-time 10. The Industrial Revolution 11. PHP : lets cache 12. Extra ! Extra ! 13. PHP : dynamic content in static content 14. The Modern Era 15. PHP : multiple webservers 16. PHP : push updates to cache 17. Today 18. Adding reverse proxy caching 19. Website X with ESI HeaderLatest news Article content pageNavigationPage content 20. Website X with ESI Header (TTL = 2h)Latest news Article content pageNavigation(TTL = 1h)Page content 21. Website X with ESI Header (TTL = 2h)Latest news (TTL = 2m) Article content pageNavigation(TTL = 1h) Page content (TTL = 30m) 22. Going to /page/id/732 23. A simple benchmark 2KByte JPEG Apache 2.24210 IIS 7.5 3960 Varnish 3.0 11400 24. A dynamically generated, but static page Apache 2.2 + PHP (3 DB queries) 18 IIS 7.5 + .Net (3 DB queries) 16 Varnish 3.0 11400 25. Varnish - what can/cant be cached ? Can :Static pagesImages, js, cssStatic parts of pages that dont change often (ESI) Cant :POST requestsVery large files (its not a file server !)Requests with Set-CookieUser-specific content 26. ESI no caching on user-specific content ? Logged in as : Wim Godden TTL = 0s ?5 messagesTTL=1hTTL = 5min 27. Nginx Web server Reverse proxy Lightweight, fast 12.3% of all Websites 28. Nginx No threads, event-driven Uses epoll / kqueue Low memory footprint 10000 active connections = normal 29. ESI on NginxLogged in as : Wim Godden 5 messagesMenu NEWS 30. ESI on Nginx ttl="1h" /> 31. Requesting /page (1st time) Nginx13Shared memory/page 2 4 /page 32. Requesting /page ESI subrequests (1st time)Nginx 1 23/menu/news/top (in ESI session) 33. Requesting /page (next time)Nginx 1 Shared memory /page2/page/menu/news/top (in ESI session) 34. New message is sent... POST /sendo ... se i ntt (..e rt .) insDB top (in ESI session) 35. Advantages No repeated GET hits to webserver anymore ! At login : POST warm up the cache ! No repeated hits for user-specific content Not even for non-specific content 36. News addedaddnews() method o ... sei ntt (.. e rt .)ins DB Memcache key /news 37. Advantages No repeated GET hits to webserver anymore ! At login : POST warm up the cache ! No repeated hits for user-specific content Not even for non-specific contentNo TTLs for non-specific contentImagine doing it for the bid status on Ebay items ;-) 38. How many Memcache requests ? Logged in as : Wim Godden5 messages ttl="1h" /> 39. ESI implementation Part of the ESI 1.0 spec Only relevant features implemented Extension for dynamic session support 40. ESI code samples

41. ESI code samples 42. Why Nginx ? Native Memcache support Excellent and superfast subrequest systemIncluding parallel subrequests Handles thousands of connections per workerWith minimal memory footprint Integrates with php-fpmPerformance gain (5 - 15%)Additional features (chroot, slow request log, offline processing, ...)Graceful rolling upgrades 43. Whats the result ? 44. Figures Second customer :No. of web servers : 72 8No. of db servers : 15 4Total : 87 12 (86% reduction !) Third customer :No. of total servers : +/- 1350Expected reduction : 1350 300Expected savings : 1.6 Million (6.7M zoty) per year 45. Why is it so much faster ? 46. A real example : vBulletin 47. A real example : vBulletin 18 16 14 12 10 Standard installMemcached 8Nginx + ESI + memcached 6 4 2 0 DB LoadWeb Load Max load 48. Availability Good news :It will become Open SourceIts solid : stable at 2 customers, being installed at 2 more Bad news :First customer holds copyrightsOnce changes for customer 3 + 4 are backported for customer 1 Open Source release Binaries : Dec 2012 Jan 2013 Source : Jan-Feb 2013 (on Github !) 49. So... 50. Questions ? 51. Questions ? 52. Contact Twitter @wimgtr Web http://techblog.wimgodden.be Slideshttp://www.slideshare.net/wimg [email protected] rate my talk : http://joind.in/7184 53. Thanks !Please rate my talk : http://joind.in/7184