1 / 19

Traffic Control in Apache

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.

Télécharger la présentation

Traffic Control in Apache

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Handling Traffic Efficiently • Right and Wrong Traffic • Reduce redundant traffic • Eliminate unwanted traffic • Protect your dynamic content • Caching and tiered delivery

  3. Spectrum of Traffic Control • DNS • Content Delivery Network (CDN) • Proxies and load balancers • Application v static content servers • Application server • File system and disk

  4. 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

  5. Redirects v Rewrites • Redirect sends a HTTP header, Location: • Rewrites are server or application configurations

  6. Redirects with mod_alias • Redirect permanent • ^/xml/ < uri • http://xml.news.com/ < header • RedirectMatch permanent • ^/xml/(.*)\.xml • http://xml.news.com/$1.xml

  7. Rewrites with mod_alias • Alias • /newspaper < uri • /home/newspaper < disk • AliasMatch • /(newspaper)/(*\.htm) • /home/$1/today/$2

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

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

  10. Avoid Combinations • Order of operations: • <Directory> • <DirectoryMatch> • <Files>,<FilesMatch><< rewrites • <Location>,<LocationMatch><< aliases • <VirtualHost><< repeat the above order inside VH’s after global scope

  11. Rewrite Scripts • Might be easier to write • Possible performance or memory concerns • What can you best maintain?

  12. 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

  13. Extend Expires with mod_expires <LocationMatch "/stuff/*"> ExpiresActive on ExpiresDefault "access plus 1 hour" </Location>

  14. Disable Etags • Mtime • Inode • File size Header unset Etag FileETag none

  15. 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

  16. Banning Traffic with <Directory> • <Directory /home/web> • Order Allow,Deny • Deny from 10.10.10.10 • </Directory>

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

  18. Vastly More Traffic • Multiple servers, but where? • Load balancer • mod_proxy • HA Proxy • Reverse Proxy Caching • Squid • CDNs

  19. Thank you • Jed Reynolds has been a programmer analyst since 1996 and enjoys bicycling and his Pentax K10D • blog.bitratchet.com • @jed_reynolds • jed@bitratchet.com

More Related