Download - Surviving a Plane Crash, a NU.nl case-study
![Page 1: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/1.jpg)
Peter C. VerhageJune 12th 2009
Surviving a Plane Crasha NU.nl case-study
![Page 2: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/2.jpg)
Surviving a Plane Crash
NU.nl
• most popular Dutch news website
• 10th anniversary
• 4.5 million unique visitors each month
• 7-15 million page views each day
Me
The plane crash
• 20.2 million page views
• 1.83 Gbit/s traffic
2
![Page 3: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/3.jpg)
Surviving a Plane Crash
CMS
Front-end
Performance
QA
3
![Page 4: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/4.jpg)
CMS
4
![Page 5: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/5.jpg)
CMS
100% custom
PHP 5.1 / MySQL 5
ATK framework
• in-house developed
• Open Source (LGPL)
• specializes in CMS-like applications
Prototype / Scriptaculous
5
![Page 6: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/6.jpg)
CMS
6
vs
![Page 7: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/7.jpg)
CMS
7
![Page 8: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/8.jpg)
CMS
8
![Page 9: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/9.jpg)
CMS
9
![Page 10: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/10.jpg)
CMS
10
![Page 11: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/11.jpg)
CMS
11
![Page 12: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/12.jpg)
Front-end
12
![Page 13: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/13.jpg)
Front-end
Multiple sites (NU, NUvideo, NUfoto, NUsport, ...)
CodeIgniter framework
• PHP 4 :(
• lightweight MVC
• extensible
Extensions
• Snippets
• Globalization (i18n / l10n)
• Code sharing between sites
13
![Page 14: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/14.jpg)
Front-endSnippets
14
![Page 15: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/15.jpg)
Front-end: Snippets
15
![Page 16: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/16.jpg)
Front-end: Snippets
16
header
![Page 17: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/17.jpg)
Front-end: Snippets
17
navigation
![Page 18: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/18.jpg)
Front-end: Snippets
18
sidebar
![Page 19: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/19.jpg)
Front-end: Snippets
19
other news
![Page 20: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/20.jpg)
Front-end: Snippets
20
article
![Page 21: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/21.jpg)
Front-end: Snippets
snippets
• are like ZF partials, but more powerful
• contain logic that doesn’t belong in the template / view
• have full access to the model
• render a view for their result
• so a lot like a controller action
• but more re-usable
21
abstract class Snippet { public function __construct($params); protected function getParam(); protected function renderView($name, $params); public abstract function render(); public function getPath(); ...}
![Page 22: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/22.jpg)
Front-endGlobalization
22
![Page 23: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/23.jpg)
Front-end: Globalization
Dnews.de; german version of NU.nl
Same code base, different configuration
Default CodeIgniter globalization not sufficient
Custom globalization consists of:
• translations
• template overrides
• snippet overrides
• css / javascript overrides
• routing overrides
23
![Page 24: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/24.jpg)
Front-endCode Sharing
24
![Page 25: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/25.jpg)
Front-end: Code Sharing
Good developers are lazy developers
Lazy developers are good developers
Avoid code duplication
Each site has its own code base
One shared code base
Class not found in site code base? → Try shared code base
Small variations can be tweaked in the site configuration
25
![Page 26: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/26.jpg)
Performance
26
![Page 27: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/27.jpg)
Performance
Static HTML
Going more dynamic
A Layer of Varnish
Hardware setup
27
![Page 28: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/28.jpg)
PerformanceStatic HTML
28
![Page 29: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/29.jpg)
Performance: Static HTML
Nothing beats static HTML
Snippets; the problem
Task Scheduler
Degradation
29
![Page 30: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/30.jpg)
PerformanceGoing more dynamic
30
![Page 31: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/31.jpg)
Performance: Going more dynamic
NUfoto / NUvideo
Lists ordered by date
Problem
• latest photo / video is pushed on top
• pagination continuously changes
Solution
• use a proxy server
• use Memcache
• generate HTML for first few pages
31
![Page 32: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/32.jpg)
Performance: Going more dynamic
Showing the logged in user
Problem
• every page is customized for the user
Solution
• set cookie with display data
• use JavaScript to inject
• don’t cache real user specific pages
• never trust the cookie!
32
![Page 33: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/33.jpg)
PerformanceA Layer of Varnish
33
![Page 34: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/34.jpg)
Performance: A Layer of Varnish
Open Source reverse proxy server
Serves from memory
Blazingly fast
Snippets; the solution → ESI
• Edge Side Includes (W3C standard)
• In-memory
• Remember Snippet::getPath()?
• Example:<esi:include src=”/includes/site/sections/algemeen.html”/>
34
![Page 35: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/35.jpg)
PerformanceHardware setup
35
![Page 36: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/36.jpg)
Performance: Hardware setup
2 back-end servers (apache / master db), only 1 active
4 front-end servers (apache / slave db)
4 front-end Varnish proxy servers
4 media Varnish proxy servers
Juniper load balancers
36
![Page 37: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/37.jpg)
Questions ?
37
![Page 39: Surviving a Plane Crash, a NU.nl case-study](https://reader036.vdocument.in/reader036/viewer/2022062704/555f1340d8b42a5c388b530a/html5/thumbnails/39.jpg)
Links & sources
39
http://www.nu.nlhttp://www.nufoto.nlhttp://www.nuvideo.nlhttp://www.nusport.nlhttp://www.dnews.de
http://www.atk-framework.comhttp://www.codeigniter.comhttp://varnish.projects.linpro.no