1. Surviving a Plane Crash
a NU.nl case-study
Peter C. Verhage
June 12th 2009
2. 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
21. 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
abstract class Snippet {
public function __construct($params);
protected function getParam();
• so a lot like a controller action protected function renderView($name, $params);
public abstract function render();
public function getPath();
...
• but more re-usable }
21
25. 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
31. 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
32. 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
34. 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