SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
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 ?
We're at a PHP conference...




    … and I'm 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 : let's 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/can't be cached ?
 Can :
    Static pages
    Images, js, css
    Static parts of pages that don't change often (ESI)
 Can't :
    POST requests
    Very large files (it's 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
What's 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
    It's 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

Más contenido relacionado

La actualidad más candente

EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxrtCamp
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebPeter Lubbers
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJSHüseyin BABAL
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaJames Falkner
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)WordCamp Cape Town
 
Pushing the web — WebSockets
Pushing the web — WebSocketsPushing the web — WebSockets
Pushing the web — WebSocketsRoland M
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS IntroNgoc Dao
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Otto Kekäläinen
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integrationOleksandr Semenov
 
Using WebSockets with ColdFusion
Using WebSockets with ColdFusionUsing WebSockets with ColdFusion
Using WebSockets with ColdFusioncfjedimaster
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisYork Tsai
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersSeravo
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsNaresh Chintalcheru
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overviewallenmeng
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beersjorgecarabias
 

La actualidad más candente (20)

Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Websockets and SockJS, Real time chatting
Websockets and SockJS, Real time chattingWebsockets and SockJS, Real time chatting
Websockets and SockJS, Real time chatting
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
Pushing the web — WebSockets
Pushing the web — WebSocketsPushing the web — WebSockets
Pushing the web — WebSockets
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
 
Using WebSockets with ColdFusion
Using WebSockets with ColdFusionUsing WebSockets with ColdFusion
Using WebSockets with ColdFusion
 
Intro to WebSockets
Intro to WebSocketsIntro to WebSockets
Intro to WebSockets
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and Redis
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
Html 5 boot camp
Html 5 boot campHtml 5 boot camp
Html 5 boot camp
 
Websocket protocol overview
Websocket protocol overviewWebsocket protocol overview
Websocket protocol overview
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
 

Destacado

Nginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteNginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteWim Godden
 
Caching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersCaching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the typeWim Godden
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Wim Godden
 

Destacado (7)

Nginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your siteNginx and friends - putting a turbo button on your site
Nginx and friends - putting a turbo button on your site
 
Caching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4DevelopersCaching and tuning fun for high scalability @ 4Developers
Caching and tuning fun for high scalability @ 4Developers
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
From typing the test to testing the type
From typing the test to testing the typeFrom typing the test to testing the type
From typing the test to testing the type
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
 

Similar a Remove web calls and scale your site like crazy !

Remove php calls and scale your site like crazy !
Remove php calls and scale your site like crazy !Remove php calls and scale your site like crazy !
Remove php calls and scale your site like crazy !Wim Godden
 
When dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWhen dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWim Godden
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWim Godden
 
When dynamic becomes static
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes staticWim Godden
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWim Godden
 
When dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWhen dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWim Godden
 
When dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWhen dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWim Godden
 
How it's made - MyGet (CloudBurst)
How it's made - MyGet (CloudBurst)How it's made - MyGet (CloudBurst)
How it's made - MyGet (CloudBurst)Maarten Balliauw
 
How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)Kaliop-slide
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESIKit Chan
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
07 response-headers
07 response-headers07 response-headers
07 response-headershanichandra
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup PerformanceGreg Whalin
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Scaling Django Apps using AWS Elastic Beanstalk
Scaling Django Apps using AWS Elastic BeanstalkScaling Django Apps using AWS Elastic Beanstalk
Scaling Django Apps using AWS Elastic BeanstalkLushen Wu
 
PHP Benelux 2017 - Caching The Right Way
PHP Benelux 2017 -  Caching The Right WayPHP Benelux 2017 -  Caching The Right Way
PHP Benelux 2017 - Caching The Right WayAndré Rømcke
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 

Similar a Remove web calls and scale your site like crazy ! (20)

Remove php calls and scale your site like crazy !
Remove php calls and scale your site like crazy !Remove php calls and scale your site like crazy !
Remove php calls and scale your site like crazy !
 
When dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWhen dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniques
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniques
 
When dynamic becomes static
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes static
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniques
 
When dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniquesWhen dynamic becomes static : the next step in web caching techniques
When dynamic becomes static : the next step in web caching techniques
 
When dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniquesWhen dynamic becomes static - the next step in web caching techniques
When dynamic becomes static - the next step in web caching techniques
 
How it's made - MyGet (CloudBurst)
How it's made - MyGet (CloudBurst)How it's made - MyGet (CloudBurst)
How it's made - MyGet (CloudBurst)
 
How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)How to deploy & optimize eZ Publish (2014)
How to deploy & optimize eZ Publish (2014)
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Life on the Edge with ESI
Life on the Edge with ESILife on the Edge with ESI
Life on the Edge with ESI
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
07 response-headers
07 response-headers07 response-headers
07 response-headers
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Scaling Django Apps using AWS Elastic Beanstalk
Scaling Django Apps using AWS Elastic BeanstalkScaling Django Apps using AWS Elastic Beanstalk
Scaling Django Apps using AWS Elastic Beanstalk
 
PHP Benelux 2017 - Caching The Right Way
PHP Benelux 2017 -  Caching The Right WayPHP Benelux 2017 -  Caching The Right Way
PHP Benelux 2017 - Caching The Right Way
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 

Más de Wim Godden

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to lifeWim Godden
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8Wim Godden
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to lifeWim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.xWim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.xWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 

Más de Wim Godden (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 

Último

March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch TuesdayIvanti
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.IPLOOK Networks
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Muhammad Tiham Siddiqui
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FESTBillieHyde
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1DianaGray10
 
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdf
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdfQ4 2023 Quarterly Investor Presentation - FINAL - v1.pdf
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdfTejal81
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInThousandEyes
 
AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024Brian Pichman
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2DianaGray10
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applicationsnooralam814309
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024Brian Pichman
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationKnoldus Inc.
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTxtailishbaloch
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxNeo4j
 
Flow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameFlow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameKapil Thakar
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechProduct School
 

Último (20)

March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FEST
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1
 
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdf
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdfQ4 2023 Quarterly Investor Presentation - FINAL - v1.pdf
Q4 2023 Quarterly Investor Presentation - FINAL - v1.pdf
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
 
AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applications
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its application
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
 
Flow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First FrameFlow Control | Block Size | ST Min | First Frame
Flow Control | Block Size | ST Min | First Frame
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
 

Remove web calls and scale your site like crazy !

  • 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. We're at a PHP conference... … and I'm going to show you how to use less PHP
  • 5. To understand the present Understand the past
  • 6. The Stone Age New blog post by : caveman003
  • 7. Pre-PHP : draw it and make html
  • 9. Old-school PHP : 'rebuild-every-time'
  • 11. PHP : let's cache
  • 13. PHP : dynamic content in static content
  • 15. PHP : multiple webservers
  • 16. PHP : push updates to cache
  • 17. Today
  • 19. Website X with ESI Header Latest news Article content page Navigation Page content
  • 20. Website X with ESI Header (TTL = 2h) Latest news Article content page Navigation (TTL = 1h) Page content
  • 21. Website X with ESI Header (TTL = 2h) Latest news (TTL = 2m) Article content page Navigation (TTL = 1h) Page content (TTL = 30m)
  • 22. Going to /page/id/732 <esi:include src="/header"/> <esi:include src="/nav"/> <esi:include src="/latest-news"/> <esi:include src="/article/id/732"/>
  • 23. A simple benchmark – 2KByte JPEG Apache 2.2 4210 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/can't be cached ? Can : Static pages Images, js, css Static parts of pages that don't change often (ESI) Can't : POST requests Very large files (it's not a file server !) Requests with Set-Cookie User-specific content
  • 26. ESI → no caching on user-specific content ? Logged in as : Wim Godden TTL = 0s ? 5 messages TTL=1h TTL = 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 Nginx Logged in as : Wim Godden 5 messages Menu NEWS
  • 30. ESI on Nginx <esi:include src="/top" session="1" ttl="1h" /> <esi:include src="/menu" <esi:include src="/news" ttl="5m" /> ttl="1h" />
  • 31. Requesting /page (1st time) Nginx 1 3 Shared memory /page 2 4 /page
  • 32. Requesting /page ESI subrequests (1st time) Nginx 1 2 3 /menu /news /top (in ESI session)
  • 33. Requesting /page (next time) Nginx 1 Shared memory /page 2 /page /menu /news /top (in ESI session)
  • 34. New message is sent... POST /send o ... se i nt t (.. e rt .) ins DB 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 added addnews() method o ... se i nt t (.. 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 content No TTLs for non-specific content Imagine doing it for the bid status on Ebay items ;-)
  • 38. 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" />
  • 39. ESI implementation Part of the ESI 1.0 spec Only relevant features implemented Extension for dynamic session support
  • 40. 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>
  • 41. ESI code samples <esi:foreach items="message" collection="$(ESIGLOBAL{'thread_' + $(QUERY_STRING{'threadId'})})"> <esi:include src="thread-message" alt="/thread/message.php" /> </esi:foreach>
  • 42. 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
  • 44. 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
  • 45. Why is it so much faster ?
  • 46. A real example : vBulletin
  • 47. 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
  • 48. Availability Good news : It will become Open Source It's 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 !)
  • 49. So...
  • 52. 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
  • 53. Thanks ! Please rate my talk : http://joind.in/7184