Remove web calls and scale your site like crazy !
Upcoming SlideShare
Loading in...5
×
 

Remove web calls and scale your site like crazy !

on

  • 9,842 views

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 ...

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.

Statistics

Views

Total Views
9,842
Views on SlideShare
9,802
Embed Views
40

Actions

Likes
4
Downloads
6
Comments
1

6 Embeds 40

http://www.php-talks.com 26
http://lanyrd.com 7
http://www.linkedin.com 4
https://si0.twimg.com 1
http://feedly.com 1
http://www.feedspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • The            setup            in            the            video            no            longer            works.           
    And            all            other            links            in            comment            are            fake            too.           
    But            luckily,            we            found            a            working            one            here (copy paste link in browser) :            www.goo.gl/i7K0s4
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Remove web calls and scale your site like crazy ! Remove web calls and scale your site like crazy ! Presentation Transcript

    • Remove PHP calls &scale your site like crazy ! Wim Godden Cu.be Solutions
    • 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
    • Who are you ? Developers ? System/network engineers ? Managers ?
    • Were at a PHP conference... … and Im going to show you how to use less PHP
    • To understand the present Understand the past
    • The Stone Age New blog post by : caveman003
    • Pre-PHP : draw it and make html
    • The Egyptian Era
    • Old-school PHP : rebuild-every-time
    • The Industrial Revolution
    • PHP : lets cache
    • Extra ! Extra !
    • PHP : dynamic content in static content
    • The Modern Era
    • PHP : multiple webservers
    • PHP : push updates to cache
    • Today
    • Adding reverse proxy caching
    • Website X with ESI Header Latest news Article content page Navigation Page content
    • Website X with ESI Header (TTL = 2h) Latest news Article content page Navigation (TTL = 1h) Page content
    • Website X with ESI Header (TTL = 2h) Latest news (TTL = 2m) Article content page Navigation (TTL = 1h) Page content (TTL = 30m)
    • Going to /page/id/732 <esi:include src="/header"/> <esi:include src="/nav"/> <esi:include src="/latest-news"/> <esi:include src="/article/id/732"/>
    • A simple benchmark – 2KByte JPEG Apache 2.2 4210 IIS 7.5 3960 Varnish 3.0 11400
    • 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
    • Varnish - what can/cant be cached ? Can : Static pages Images, js, css Static parts of pages that dont change often (ESI) Cant : POST requests Very large files (its not a file server !) Requests with Set-Cookie User-specific content
    • ESI → no caching on user-specific content ? Logged in as : Wim Godden TTL = 0s ? 5 messages TTL=1h TTL = 5min
    • Nginx Web server Reverse proxy Lightweight, fast 12.3% of all Websites
    • Nginx No threads, event-driven Uses epoll / kqueue Low memory footprint 10000 active connections = normal
    • ESI on Nginx Logged in as : Wim Godden 5 messages Menu NEWS
    • ESI on Nginx <esi:include src="/top" session="1" ttl="1h" /> <esi:include src="/menu" <esi:include src="/news" ttl="5m" /> ttl="1h" />
    • Requesting /page (1st time) Nginx 1 3 Shared memory /page 2 4 /page
    • Requesting /page ESI subrequests (1st time) Nginx 1 2 3 /menu /news /top (in ESI session)
    • Requesting /page (next time) Nginx 1 Shared memory /page 2 /page /menu /news /top (in ESI session)
    • New message is sent... POST /send o ... se i nt t (.. e rt .) ins DB top (in ESI session)
    • 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
    • News added addnews() method o ... se i nt t (.. e rt .) ins DB Memcache key /news
    • 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 No TTLs for non-specific content Imagine doing it for the bid status on Ebay items ;-)
    • How many Memcache requests ? Logged in as : Wim Godden <esi:include src="/top" session="1" ttl="1h" /> 5 messages <esi:include src="/menu" <esi:include src="/news" ttl="5m" /> ttl="1h" />
    • ESI implementation Part of the ESI 1.0 spec Only relevant features implemented Extension for dynamic session support
    • ESI code samples <esi:choose> <esi:when test="$(ESISESSION{isAdmin})==true"> <esi:include src="admin-buttons" alt="/admin-buttons.php" /> </esi:when> <esi:otherwise> <div id="justauser"> <esi:include src="user-buttons" alt="/user-buttons.php" /> </div> </esi:otherwise> </esi:choose>
    • ESI code samples<esi:foreach items="message" collection="$(ESIGLOBAL{thread_ + $(QUERY_STRING{threadId})})"> <esi:include src="thread-message" alt="/thread/message.php" /></esi:foreach>
    • Why Nginx ? Native Memcache support Excellent and superfast subrequest system Including parallel subrequests Handles thousands of connections per worker With minimal memory footprint Integrates with php-fpm Performance gain (5 - 15%) Additional features (chroot, slow request log, offline processing, ...) Graceful rolling upgrades
    • Whats the result ?
    • Figures Second customer : No. of web servers : 72 → 8 No. of db servers : 15 → 4 Total : 87 → 12 (86% reduction !) Third customer : No. of total servers : +/- 1350 Expected reduction : 1350 → 300 Expected savings : €1.6 Million (6.7M złoty) per year
    • Why is it so much faster ?
    • A real example : vBulletin
    • A real example : vBulletin 18 16 14 12 10 Standard install Memcached 8 Nginx + ESI + memcached 6 4 2 0 DB Load Web Load Max load
    • Availability Good news : It will become Open Source Its solid : stable at 2 customers, being installed at 2 more Bad news : First customer holds copyrights Once changes for customer 3 + 4 are backported for customer 1 → Open Source release Binaries : Dec 2012 – Jan 2013 Source : Jan-Feb 2013 (on Github !)
    • So...
    • Questions ?
    • Questions ?
    • Contact Twitter @wimgtr Web http://techblog.wimgodden.be Slides http://www.slideshare.net/wimg E-mail wim.godden@cu.be Please rate my talk : http://joind.in/7184
    • Thanks !Please rate my talk : http://joind.in/7184