34
Surviving Slashdot: How to plan for the deluge.

Surviving Slashdot

  • View
    2.373

  • Download
    0

Embed Size (px)

DESCRIPTION

Technical presentation from 2005 about how to make your web site survive slashdot/digg style mega load.

Citation preview

Page 1: Surviving Slashdot

Surviving Slashdot:

How to plan for the deluge.

Page 2: Surviving Slashdot

Magnatune’s architecture:

linux/apache/mysql/php

Page 3: Surviving Slashdot

What happened when Slashdot hit.

Page 4: Surviving Slashdot

1. Thousands of Apache processes

Page 5: Surviving Slashdot

2. Http Servers unresponsive

Page 6: Surviving Slashdot

3. Http Audio Streaming not fast enough for real

time

Page 7: Surviving Slashdot

Analysis & Solutions

Page 8: Surviving Slashdot

Why is Yahoo so “snappy” ?

Page 9: Surviving Slashdot

By default, Web browsers ask for every image on every page

with “If-Modified-Since”.

Page 10: Surviving Slashdot

Ironically, lots of small graphics on a web page is the least efficient use

of HTTP.

Page 11: Surviving Slashdot

What if you could make browsers not ask for

images that are unchanging?

Page 12: Surviving Slashdot

Trick #1:

use “Expires” HTTP header on static graphics:

Expires: Thu, 15 Apr 2010 20:00:00 GMT

Page 13: Surviving Slashdot

I did this by hacking the C source code to my

HTTP server.

Page 14: Surviving Slashdot

Is there a fast Apache way to add an Expires: header when returning

GIF/JPEGs?

Page 15: Surviving Slashdot

next problem...

Page 16: Surviving Slashdot

In many cases, HTTP performance is

constrained by the receiver, not the sender.

Page 17: Surviving Slashdot

Large files take a long time to be downloaded

by the requestor.

Page 18: Surviving Slashdot

Each download uses up an Apache process.

Page 19: Surviving Slashdot

Apache Bench shows great large-file performance.

Page 20: Surviving Slashdot

But Apache Bench isn’t a useful metric with large files in the real world.

Page 21: Surviving Slashdot

The problem is the “fork” based

architecture of Apache.

Page 22: Surviving Slashdot

Thread-based HTTP servers have the same

problem.

Page 23: Surviving Slashdot

Apache has an experimental “async” mode -- this may be a solution in the future.

Page 24: Surviving Slashdot

Trick #2:

Use a dedicated async-based HTTP server for

large files.

Page 25: Surviving Slashdot

next problem...

Page 26: Surviving Slashdot

PHP is handy.

But PHP is slow.

Page 27: Surviving Slashdot

Apache BenchSpeed tests:

PHP: 9 pages/secHTML: 250 pages/sec

Page 28: Surviving Slashdot

Trick #3:

Statically cache most PHP pages into HTML.

Page 29: Surviving Slashdot

Use Apache “MultiViews”

option.

Page 30: Surviving Slashdot

URLs shouldn’t include .php or .html

Page 31: Surviving Slashdot

ie:

http://x.com/mypage

could be PHP or HTML, doesn’t matter.

Page 32: Surviving Slashdot

Have a script regularly HTTP GET most PHP files, save as HTML and

delete the PHP.

Page 33: Surviving Slashdot

Yields a 25x speed increase.

Page 34: Surviving Slashdot

end