SlideShare a Scribd company logo
1 of 78
Download to read offline
When dynamic becomes static 
(the next step in web caching techniques) 
Wim Godden 
Cu.be Solutions 
@wimgtr
Disclaimer 
The next step 
As in : what you will be doing in the future 
Not as in : go home and run it ;-) 
Language of choice : PHP 
But : think Perl, Python, Ruby, Java, .Net, …
Who am I ? 
Wim Godden (@wimgtr)
Where I'm from
Where I'm from
Where I'm from
Where I'm from
Where I'm from
Where I'm from
My town
My town
Belgium – the traffic
Who am I ? 
Wim Godden (@wimgtr) 
Founder of Cu.be Solutions (http://cu.be) 
Open Source developer since 1997 
Developer of OpenX, PHPCompatibility, PHPConsistent, ... 
Speaker at Open Source conferences
Who are you ? 
Developers ? 
System/network engineers ? 
Managers ?
To understand the present 
Understand the past
The Stone Age 
New blog post by : caveman003
Pre-dynamic : draw it and make html
The Egyptian Era
Old-school dynamic : 'rebuild-every-time'
The Industrial Revolution
Dynamic : let's cache
Extra ! Extra !
Dynamic content in static content
The Modern Era
More load, more webservers
Pushing updates to cache
Today
Adding reverse proxy caching
Typical website structure 
Header 
Latest news 
Article content page 
Page content 
Navigation
Caching blocks with individual TTLs 
Top header 
(TTL = 2h) 
Latest news 
Article content page 
Page content 
Navigation 
(TTL = 1h)
Caching blocks with individual TTLs 
Top header 
(TTL = 2h) 
Latest news (TTL = 2m) 
Article content page 
Page content (TTL = 30m) 
Navigation 
(TTL = 1h)
ESI – how it works 
GET /page GET /page
ESI – how it works 
GET /page GET /page 
<html> 
... 
<esi:include src="/top"/> 
<esi:include src="/nav"/> 
<div id=”something”> 
<esi:include src="/latest-news"/> 
</div> 
<esi:include src="/article/id/732"/> 
... 
</html>
ESI – how it works 
GET /top 
<div id=”top-part”> 
<a href=”/login”>Login</a> 
</div>
ESI – how it works 
GET /page GET /page 
<html> 
... 
<esi:include src="/top"/> 
<esi:include src="/nav"/> 
<div id=”something”> 
<esi:include src="/latest-news"/> 
</div> 
<esi:include src="/article/id/732"/> 
... 
</html>
ESI – how it works 
GET /page GET /page 
<html> 
... 
<div id=”top-part”> 
<a href=”/login”>Login</a> 
</div> 
<esi:include src="/nav"/> 
<div id=”something”> 
<esi:include src="/latest-news"/> 
</div> 
<esi:include src="/article/id/732"/> 
... 
</html>
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 
5 messages 
TTL = 0s ? 
TTL=1h TTL = 5min
Error... does not compute !
Back in 2010
No more backend 
GET /page 
DB
No more backend 
GET /page
Nginx 
Web server 
Reverse proxy 
Lightweight, fast 
Low memory footprint 
14.54% of all Websites
Nginx 
No threads, event-driven 
Uses epoll / kqueue 
20000 active connections = normal 
20000 req/sec = normal
ESI on Nginx 
Logged in as : Wim Godden 
5 messages 
Menu NEWS
ESI SLIC on Nginx 
Logged in as : Wim Godden 
5 messages 
Menu NEWS
Requesting /page (1st time) 
Nginx 
Shared memory 
1 
2 
3 
4 
/page 
/page
Requesting /page SLIC subrequests (1st time) 
Nginx 
1 
2 
3 
/menu 
/news 
/top (with session cookie) 
/menu 
/news 
/top (in SLIC session)
Requesting /page (next time) 
Nginx 
Shared memory 1 
2 
/page 
/page 
/menu 
/news 
/top (in SLIC session)
SLIC on Nginx 
<slic:include key="top" src="/top" session="true" /> 
<slic:include key="news" src="/news" /> 
<slic:include 
key="menu" 
src="/menu" /> 
Logged in as : Wim Godden 
5 messages ???
New message is sent... 
POST /send 
DB 
insert into... 
set(...) 
top (in SLIC 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 
DB 
insert into... 
set(...) 
Memcache key /news
How many Memcached requests ? 
Logged in as : Wim Godden 
5 messages 
<slic:include key="top" src="/top" session="true" /> 
<slic:include key="news" src="/news" /> 
<slic:include 
key="menu" 
src="/menu" />
First release : ESI 
Part of the ESI 1.0 spec 
Only relevant features implemented 
Extension for dynamic session support 
But : unavailable for copyright reasons
Rebuilt from scratch : SLIC 
Control structures : if/else, switch/case, foreach 
Variable handling 
Strings : concatenation, substring, … 
Exception handling, header manipulation, … 
JSON support !
SLIC code samples 
You are logged in as : <slic:session_var("person_name") /> 
You are logged in as : <@s("person_name") />
SLIC code samples 
<slic:switch var="session_var('isAdmin')"> 
<slic:case value="1"> 
<slic:include key="admin-buttons" src="/admin-buttons.php" /> 
</slic:case> 
<slic:default> 
<div id="just-a-user"> 
<slic:include key="user-buttons" src="/user-buttons.php" /> 
</div> 
</slic:default> 
</slic:switch>
SLIC code samples 
<slic:foreach item="messageId" src="global_var('thread' + query_var('threadId'))"> 
<slic:include key="'thread-message_' + messageId" 
src="'/thread/message.php?id=' + messageId" /> 
</slic:foreach>
Approaches – full block 
Logged in as : Wim Godden 
<p id=”LoggedInAs”> 
You are logged in as : <slic:session_var("person_name") /> 
</p> 
<p id=”MessageCount”> 
You have 5 messages 
</p> 
5 messages 
<slic:include key="top" src="/top" session="true" /> 
top_31
Approaches – individual variables 
Logged in as : Wim Godden 
<p id=”LoggedInAs”> 
You are logged in as : <slic:session_var("person_name") /> 
</p> 
<p id=”MessageCount”> 
You have <slic:session_var(“messages”) /> messages 
</p> 
5 messages 
<slic:include key="top" src="/top" session="true" />
Approaches – JSON 
Logged in as : Wim Godden 
5 messages 
<slic:include key="top" src="/top" session="true" /> 
<p id=”LoggedInAs”> 
You are logged in as : <slic:session_var("userData").person_name /> 
</p> 
<p id=”MessageCount”> 
You have <slic:session_var(“userData”).message_count /> messages 
</p>
Identifying the user 
In Nginx configuration : 
slic_session_cookie <name> → Defined by language (or configurable) 
slic_session_identifier <string> → Defined by you 
Example for PHP : 
slic_session_cookie PHPSESSID 
slic_session_identifier UserID
Identifying the user 
Cookie : 
PHPSESSID = 
jpsidc1po35sq9q3og4f3hi6e2 
Nginx + SLIC 
4g3e2t UserID_jpsidc1po35sq9q3og4f3hi6e2
Retrieving user specific content 
Nginx + SLIC 
get userData_432 
Cookie : 
PHPSESSID = 
jpsidc1po35sq9q3og4f3hi6e2
Why Nginx ? 
Native Memcached support 
Excellent and superfast subrequest system 
Including parallel subrequests 
Handles thousands of connections per worker 
With minimal memory footprint 
Integrates with php-fpm 
Additional features (chroot, slow request log, offline processing, ...) 
Graceful rolling upgrades
What's the result ?
Figures 
2nd customer : 
No. of web servers : 72 → 8 
No. of db servers : 15 → 4 
Total : 87 → 12 (86% reduction !) 
Last customer : 
No. of total servers : +/- 1350 
Expected reduction : 1350 → 380 
Expected savings : €1.5 Million per year
Why is it so much faster ?
A real example : vBulletin
A real example : vBulletin 
Post 
isAdmin session variable 
isModerator session variable
A real example : vBulletin 
DB Server Load Web Server Load Max Requests/sec (1 = 282) 
35 
30 
25 
20 
15 
10 
5 
0 
Standard install 
With Memcached 
Nginx + SCL + memcached
Code changes 
Required 
Template conversion 
Push-to-DB → Push-to-DB + Push-to-Cache 
Choice : 
If user is logged in → push updates to cache 
If user is not logged in → warm up cache on login
Availability 
Good news : 
It will become Open Source 
The concept is solid : ESI version stable at 4 customers 
Bad news : 
First customer holds copyrights 
Total rebuild 
→ Open Source release 
No current projects, so spare time 
Anyone feel like sponsoring ? 
Beta : October ! 
Stable : January
So...
Questions ?
Questions ?
Contact 
Twitter @wimgtr 
Web http://techblog.wimgodden.be 
Slides http://www.slideshare.net/wimg 
E-mail wim.godden@cu.be

More Related Content

What's hot

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introductionParth Joshi
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressOtto Kekäläinen
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsOtto Kekäläinen
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress DevelopmentAdam Tomat
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimizationStevie T
 
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
 
Front end performance tip
Front end performance tipFront end performance tip
Front end performance tipSteve Yu
 
Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...Droidcon Eastern Europe
 
Cache Rules Everything Around Me
Cache Rules Everything Around MeCache Rules Everything Around Me
Cache Rules Everything Around MeRussell Heimlich
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsSiarhei Barysiuk
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHPSeravo
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontendtkramar
 
Introduction to Yesod
Introduction to YesodIntroduction to Yesod
Introduction to Yesodbobjlong
 
HTML5 Web Messaging
HTML5 Web MessagingHTML5 Web Messaging
HTML5 Web MessagingMike Taylor
 

What's hot (19)

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPress
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress plugins
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimization
 
Front End Performance
Front End PerformanceFront End Performance
Front End Performance
 
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
 
Front end performance tip
Front end performance tipFront end performance tip
Front end performance tip
 
Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...
 
Cache Rules Everything Around Me
Cache Rules Everything Around MeCache Rules Everything Around Me
Cache Rules Everything Around Me
 
Php with mysql ppt
Php with mysql pptPhp with mysql ppt
Php with mysql ppt
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
 
Introduction to Yesod
Introduction to YesodIntroduction to Yesod
Introduction to Yesod
 
HTML5 Web Messaging
HTML5 Web MessagingHTML5 Web Messaging
HTML5 Web Messaging
 

Similar to 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 techniquesWim Godden
 
When dynamic becomes static
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes staticWim Godden
 
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
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes staticWim Godden
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup PerformanceGreg Whalin
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon praguehernanibf
 
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
 
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
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishKaliop-slide
 
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
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budgetDavid Lukac
 
Remove web calls and scale your site like crazy !
Remove web calls and scale your site like crazy !Remove web calls and scale your site like crazy !
Remove web calls and scale your site like crazy !Wim Godden
 

Similar to When dynamic becomes static : the next step in web caching techniques (20)

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
 
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
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes static
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon prague
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
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
 
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
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ Publish
 
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)
 
Introduccion a HTML5
Introduccion a HTML5Introduccion a HTML5
Introduccion a HTML5
 
html5
html5html5
html5
 
Please dont touch-3.6-jsday
Please dont touch-3.6-jsdayPlease dont touch-3.6-jsday
Please dont touch-3.6-jsday
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budget
 
Optimizing wp
Optimizing wpOptimizing wp
Optimizing wp
 
Remove web calls and scale your site like crazy !
Remove web calls and scale your site like crazy !Remove web calls and scale your site like crazy !
Remove web calls and scale your site like crazy !
 

More from 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
 

More from 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
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

When dynamic becomes static : the next step in web caching techniques

  • 1. When dynamic becomes static (the next step in web caching techniques) Wim Godden Cu.be Solutions @wimgtr
  • 2. Disclaimer The next step As in : what you will be doing in the future Not as in : go home and run it ;-) Language of choice : PHP But : think Perl, Python, Ruby, Java, .Net, …
  • 3. Who am I ? Wim Godden (@wimgtr)
  • 12. Belgium – the traffic
  • 13. Who am I ? Wim Godden (@wimgtr) Founder of Cu.be Solutions (http://cu.be) Open Source developer since 1997 Developer of OpenX, PHPCompatibility, PHPConsistent, ... Speaker at Open Source conferences
  • 14. Who are you ? Developers ? System/network engineers ? Managers ?
  • 15. To understand the present Understand the past
  • 16. The Stone Age New blog post by : caveman003
  • 17. Pre-dynamic : draw it and make html
  • 19. Old-school dynamic : 'rebuild-every-time'
  • 23. Dynamic content in static content
  • 25. More load, more webservers
  • 27. Today
  • 29. Typical website structure Header Latest news Article content page Page content Navigation
  • 30. Caching blocks with individual TTLs Top header (TTL = 2h) Latest news Article content page Page content Navigation (TTL = 1h)
  • 31. Caching blocks with individual TTLs Top header (TTL = 2h) Latest news (TTL = 2m) Article content page Page content (TTL = 30m) Navigation (TTL = 1h)
  • 32. ESI – how it works GET /page GET /page
  • 33. ESI – how it works GET /page GET /page <html> ... <esi:include src="/top"/> <esi:include src="/nav"/> <div id=”something”> <esi:include src="/latest-news"/> </div> <esi:include src="/article/id/732"/> ... </html>
  • 34. ESI – how it works GET /top <div id=”top-part”> <a href=”/login”>Login</a> </div>
  • 35. ESI – how it works GET /page GET /page <html> ... <esi:include src="/top"/> <esi:include src="/nav"/> <div id=”something”> <esi:include src="/latest-news"/> </div> <esi:include src="/article/id/732"/> ... </html>
  • 36. ESI – how it works GET /page GET /page <html> ... <div id=”top-part”> <a href=”/login”>Login</a> </div> <esi:include src="/nav"/> <div id=”something”> <esi:include src="/latest-news"/> </div> <esi:include src="/article/id/732"/> ... </html>
  • 37. 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
  • 38. ESI → no caching on user-specific content ? Logged in as : Wim Godden 5 messages TTL = 0s ? TTL=1h TTL = 5min
  • 39. Error... does not compute !
  • 41. No more backend GET /page DB
  • 42. No more backend GET /page
  • 43. Nginx Web server Reverse proxy Lightweight, fast Low memory footprint 14.54% of all Websites
  • 44. Nginx No threads, event-driven Uses epoll / kqueue 20000 active connections = normal 20000 req/sec = normal
  • 45. ESI on Nginx Logged in as : Wim Godden 5 messages Menu NEWS
  • 46. ESI SLIC on Nginx Logged in as : Wim Godden 5 messages Menu NEWS
  • 47. Requesting /page (1st time) Nginx Shared memory 1 2 3 4 /page /page
  • 48. Requesting /page SLIC subrequests (1st time) Nginx 1 2 3 /menu /news /top (with session cookie) /menu /news /top (in SLIC session)
  • 49. Requesting /page (next time) Nginx Shared memory 1 2 /page /page /menu /news /top (in SLIC session)
  • 50. SLIC on Nginx <slic:include key="top" src="/top" session="true" /> <slic:include key="news" src="/news" /> <slic:include key="menu" src="/menu" /> Logged in as : Wim Godden 5 messages ???
  • 51. New message is sent... POST /send DB insert into... set(...) top (in SLIC session)
  • 52. 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
  • 53. News added addnews() method DB insert into... set(...) Memcache key /news
  • 54. How many Memcached requests ? Logged in as : Wim Godden 5 messages <slic:include key="top" src="/top" session="true" /> <slic:include key="news" src="/news" /> <slic:include key="menu" src="/menu" />
  • 55. First release : ESI Part of the ESI 1.0 spec Only relevant features implemented Extension for dynamic session support But : unavailable for copyright reasons
  • 56. Rebuilt from scratch : SLIC Control structures : if/else, switch/case, foreach Variable handling Strings : concatenation, substring, … Exception handling, header manipulation, … JSON support !
  • 57. SLIC code samples You are logged in as : <slic:session_var("person_name") /> You are logged in as : <@s("person_name") />
  • 58. SLIC code samples <slic:switch var="session_var('isAdmin')"> <slic:case value="1"> <slic:include key="admin-buttons" src="/admin-buttons.php" /> </slic:case> <slic:default> <div id="just-a-user"> <slic:include key="user-buttons" src="/user-buttons.php" /> </div> </slic:default> </slic:switch>
  • 59. SLIC code samples <slic:foreach item="messageId" src="global_var('thread' + query_var('threadId'))"> <slic:include key="'thread-message_' + messageId" src="'/thread/message.php?id=' + messageId" /> </slic:foreach>
  • 60. Approaches – full block Logged in as : Wim Godden <p id=”LoggedInAs”> You are logged in as : <slic:session_var("person_name") /> </p> <p id=”MessageCount”> You have 5 messages </p> 5 messages <slic:include key="top" src="/top" session="true" /> top_31
  • 61. Approaches – individual variables Logged in as : Wim Godden <p id=”LoggedInAs”> You are logged in as : <slic:session_var("person_name") /> </p> <p id=”MessageCount”> You have <slic:session_var(“messages”) /> messages </p> 5 messages <slic:include key="top" src="/top" session="true" />
  • 62. Approaches – JSON Logged in as : Wim Godden 5 messages <slic:include key="top" src="/top" session="true" /> <p id=”LoggedInAs”> You are logged in as : <slic:session_var("userData").person_name /> </p> <p id=”MessageCount”> You have <slic:session_var(“userData”).message_count /> messages </p>
  • 63. Identifying the user In Nginx configuration : slic_session_cookie <name> → Defined by language (or configurable) slic_session_identifier <string> → Defined by you Example for PHP : slic_session_cookie PHPSESSID slic_session_identifier UserID
  • 64. Identifying the user Cookie : PHPSESSID = jpsidc1po35sq9q3og4f3hi6e2 Nginx + SLIC 4g3e2t UserID_jpsidc1po35sq9q3og4f3hi6e2
  • 65. Retrieving user specific content Nginx + SLIC get userData_432 Cookie : PHPSESSID = jpsidc1po35sq9q3og4f3hi6e2
  • 66. Why Nginx ? Native Memcached support Excellent and superfast subrequest system Including parallel subrequests Handles thousands of connections per worker With minimal memory footprint Integrates with php-fpm Additional features (chroot, slow request log, offline processing, ...) Graceful rolling upgrades
  • 68. Figures 2nd customer : No. of web servers : 72 → 8 No. of db servers : 15 → 4 Total : 87 → 12 (86% reduction !) Last customer : No. of total servers : +/- 1350 Expected reduction : 1350 → 380 Expected savings : €1.5 Million per year
  • 69. Why is it so much faster ?
  • 70. A real example : vBulletin
  • 71. A real example : vBulletin Post isAdmin session variable isModerator session variable
  • 72. A real example : vBulletin DB Server Load Web Server Load Max Requests/sec (1 = 282) 35 30 25 20 15 10 5 0 Standard install With Memcached Nginx + SCL + memcached
  • 73. Code changes Required Template conversion Push-to-DB → Push-to-DB + Push-to-Cache Choice : If user is logged in → push updates to cache If user is not logged in → warm up cache on login
  • 74. Availability Good news : It will become Open Source The concept is solid : ESI version stable at 4 customers Bad news : First customer holds copyrights Total rebuild → Open Source release No current projects, so spare time Anyone feel like sponsoring ? Beta : October ! Stable : January
  • 75. So...
  • 78. Contact Twitter @wimgtr Web http://techblog.wimgodden.be Slides http://www.slideshare.net/wimg E-mail wim.godden@cu.be