traffic control in apache

19
Traffic Control in Apache Jed Reynolds Blog.Bitratchet.com Where in your web site do you need traffic control?

Upload: garfield-jonathon

Post on 03-Jan-2016

66 views

Category:

Documents


0 download

DESCRIPTION

Traffic Control in Apache. Jed Reynolds Blog.Bitratchet.com Where in your web site do you need traffic control?. Handling Traffic Efficiently. Right and Wrong Traffic Reduce redundant traffic Eliminate unwanted traffic Protect your dynamic content Caching and tiered delivery. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Traffic Control in Apache

Traffic Control in Apache

Jed Reynolds Blog.Bitratchet.com

Where in your web site do you need traffic control?

Page 2: Traffic Control in Apache

Handling Traffic Efficiently

Right and Wrong Traffic Reduce redundant traffic Eliminate unwanted traffic Protect your dynamic content

Caching and tiered delivery

Page 3: Traffic Control in Apache

Spectrum of Traffic Control

DNS

Content Delivery Network (CDN)

Proxies and load balancers

Application v static content servers Application server File system and disk

Page 4: Traffic Control in Apache

Right Traffic: URI Stability

The URLs our site has might be precious The location on disk might be moved

20,000 sub directories 10,000 files

Google and Sitemaps

Page 5: Traffic Control in Apache

Redirects v Rewrites

Redirect sends a HTTP header, Location: Rewrites are server or application configurations

Page 6: Traffic Control in Apache

Redirects with mod_alias

Redirect permanent ^/xml/ < uri http://xml.news.com/ < header

RedirectMatch permanent ^/xml/(.*)\.xml http://xml.news.com/$1.xml

Page 7: Traffic Control in Apache

Rewrites with mod_alias

Alias /newspaper < uri /home/newspaper < disk

AliasMatch /(newspaper)/(*\.htm) /home/$1/today/$2

Page 8: Traffic Control in Apache

Redirects with mod_rewrite

RewriteCond HTTP_HOST ^(.*)\.news.org$RewriteRule ^(.*)$ < uri http://%1.news.com/$1? < header [R=301,L] < rules

Page 9: Traffic Control in Apache

Rewrites with mod_rewrite

RewriteRule /date/(.*) < uri /home/day/$1/index.htm < disk [L] < rule

Page 10: Traffic Control in Apache

Avoid Combinations

Order of operations:

1) <Directory>2) <DirectoryMatch>3) <Files>,<FilesMatch> <<

rewrites

4) <Location>,<LocationMatch> << aliases

5) <VirtualHost> << repeat the above order inside VH’s after global scope

Page 11: Traffic Control in Apache

Rewrite Scripts

Might be easier to write Possible performance or memory concerns What can you best maintain?

Page 12: Traffic Control in Apache

Reducing Redundant Traffic with your Headers

Cache-Control: max-age=3600, must-revalidate

Expires: Fri, 30 Oct 1998 14:19:41 GMT

Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT

ETag: "3e86-410-3596fbbc"

Etags encourage freshest content Encourage client caching

Page 13: Traffic Control in Apache

Extend Expires with mod_expires

<LocationMatch "/stuff/*">ExpiresActive onExpiresDefault "access plus 1 hour"</Location>

Page 14: Traffic Control in Apache

Disable Etags

Mtime Inode File size

Header unset EtagFileETag none

Page 15: Traffic Control in Apache

Encourage 304 responses

Apache is good with file content File content is fast Scripts should detect If-Modified-Since Scripts should send 304 Not Modified PHP Cache_Lite

Page 16: Traffic Control in Apache

Banning Traffic with <Directory>

<Directory /home/web>Order Allow,DenyDeny from 10.10.10.10</Directory>

Page 17: Traffic Control in Apache

Banning Traffic with mod_rewrite

RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot.*RewriteCond %{REMOTE_ADDR} ^123\.45\.67\.[8-9]$RewriteRule ^/news/.+ < uri - < placeholder [F] < rule

Page 18: Traffic Control in Apache

Vastly More Traffic

Multiple servers, but where? Load balancer mod_proxy HA Proxy Reverse Proxy Caching Squid CDNs

Page 19: Traffic Control in Apache

Thank you

Jed Reynolds has been a programmer analyst since 1996 and enjoys bicycling and his Pentax K10D

blog.bitratchet.com @jed_reynolds [email protected]