Apache Traffic Server


Published on

Overview of Apache Traffic Server

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • In other words: It is finished when either you don’t need me or someone else is doing it. Also, turn work that is laborious non-lousy
  • Not to say that those companies are using it (I don’t know if they are), but they employ committer to the project
  • Try to use the latest and greatest in dev until your first release. As it will front your site and likely handle you all of your incoming traffic it is a critical part of your infrastructure and you want the latest features and bug fixes. Due to its criticality, It has been my experience that people are reluctant to upgrade once it is live as it “just works”.
  • For storage, I say “if” you’re using caching. Understand that you really might not need to do this. In Y! US News we run it in proxy mode only and have had no traffic issues as of late. For the US Elections of 2008, we had a small “blip”, while other news and media organizations went down. Our “blip” was caused by keep-alives that were set too high unnecessarily. We adjusted this and were fine afterwards.
  • A client browser sends an HTTP request addressed to a host called www.host.com on port 80. Traffic Server receives the request because it is acting as the origin server (the origin server’s advertised hostname resolves to Traffic Server). Traffic Server locates a map rule in the remap.config file and remaps the request to the specified origin server (realhost.com). Traffic Server opens an HTTP connection to the origin server. If the request is a cache hit and the content is fresh, then Traffic Server sends the requested object to the client from the cache. Otherwise, Traffic Server obtains the requested object from the origin server, sends the object to the client, and saves a copy in its cache.
  • http://trafficserver.apache.org/docs/v2/admin/cache.htm
  • http://trafficserver.apache.org/docs/v2/admin/http.htm
  • This table is much to large to go into details, but it shows that there are a number of features to take into consideration when choosing an intermediary. This is not a complete list in any way, it is merely an example of what features you might want to consider for your proxy choices.
  • http://en.wikipedia.org/wiki/Edge_Side_Includes http://www.w3.org/TR/esi-lang
  • http://www.w3.org/TR/esi-lang
  • http://trafficserver.apache.org/docs/v2/admin/ http://ostatic.com/blog/guest-post-yahoos-cloud-team-open-sources-traffic-server https://cwiki.apache.org/confluence/display/TS/RoadMap http://www.oscon.com/oscon2010/public/schedule/detail/13878
  • Apache Traffic Server

    1. 1. Increase uptime and performance with Apache Traffic Server Tom Melendez, Yahoo!
    2. 2. About Tom <ul><li>Did Infrastructure development at Y! News for 3 years; have since moved on to do non-infra Hadoop stuff </li></ul><ul><li>General philosophy: My job isn’t done until I’m not doing it anymore </li></ul><ul><li>What I’ve learned: If Devs want to be happy, make Ops happy. Making Ops happy will ultimately make the business happy. </li></ul><ul><li>Primary motivation in life: I only do the fun stuff. </li></ul>
    3. 3. Agenda <ul><li>What </li></ul><ul><li>Who </li></ul><ul><li>Where and When: The Internet. Now. </li></ul><ul><li>Why/How </li></ul>
    4. 4. What <ul><li>Very efficient caching proxy. </li></ul><ul><li>Multi-threaded, event driven </li></ul><ul><li>I’ve seen it handle 30k rps per box (quad-core) without issue </li></ul><ul><li>I’ve seen lab data quoting 300k+ rps per box </li></ul><ul><li>Delivers 400 terabytes of data per day at Y! </li></ul><ul><li>Probably a configuration that can help your app. </li></ul>
    5. 5. Who (plus some history) <ul><li>Open-Sourced by Yahoo! in November 2009 </li></ul><ul><ul><li>Yahoo! received it with Inktomi acquistion </li></ul></ul><ul><ul><li>Yahoo! currently has a team of engs on it </li></ul></ul><ul><ul><li>We use it all over the place </li></ul></ul><ul><li>Apache TLP </li></ul><ul><ul><li>Core committers from Yahoo!, Google, Akamai and elsewhere </li></ul></ul>
    6. 6. Where and When <ul><li>The internet. </li></ul><ul><li>Now. </li></ul>
    7. 7. Why? <ul><li>You want to build a CDN </li></ul><ul><li>You want a reverse proxy </li></ul><ul><li>You want a forward proxy </li></ul><ul><li>You want good response for your worldwide customers </li></ul><ul><li>If you’re like me, you don’t want to do a lot of work.  </li></ul>
    8. 8. How? - Requirements <ul><li>Well, you need to be able to compile the source. (So, Linux, OSX or Solaris) </li></ul><ul><li>There are also instructions for installing on EC2 as well as AMIs available </li></ul>
    9. 9. How - installation <ul><li>./configure && make && make install </li></ul><ul><ul><li>Depending on your time to market, please consider working with the developer release, otherwise use stable </li></ul></ul><ul><li>Start it up </li></ul><ul><ul><li>sudo /usr/local/trafficserver start </li></ul></ul><ul><li>But you’ll probably want to configure it first.  </li></ul>
    10. 10. How - executables <ul><li>Processes: </li></ul><ul><li>traffic_server – handles the transactions </li></ul><ul><li>traffic_manager – manages the traffic server </li></ul><ul><li>traffic_cop – health check for the above </li></ul><ul><li>Tools: </li></ul><ul><li>traffic_line – gets stats and (re)read config </li></ul>
    11. 11. How – the config files <ul><li>bypass.config - static bypass rules that Traffic Server uses in transparent proxy caching mode. </li></ul><ul><li>cache.config - how Traffic Server caches web objects. </li></ul><ul><li>congestion.config - enables you to configure Traffic Server to stop forwarding HTTP requests to origin servers when they become congested, </li></ul><ul><li>filter.config - enables you to deny or allow particular requests and strip header information from client requests. </li></ul><ul><li>hosting.config - assign cache partitions to specific origin servers </li></ul><ul><li>icp.config - defines ICP peers (parent and sibling caches). </li></ul><ul><li>ip_allow.config - controls client access to the Traffic Server proxy cache. </li></ul>
    12. 12. How – the config files <ul><li>logs.config - formats traditional custom transaction log files. </li></ul><ul><li>log_hosts.config - log transactions for different origin servers in sep. files </li></ul><ul><li>logs_xml.config - defines the custom log file formats, filters, and processing options. </li></ul><ul><li>parent.config - identifies the parent proxies </li></ul><ul><li>partition.config - enables you to manage your cache space by creating partitions </li></ul><ul><li>records.config - list of configurable variables used by the Traffic Server software. </li></ul>
    13. 13. How – the config files <ul><li>remap.config - contains mapping rules that Traffic Server uses to perform various actions. </li></ul><ul><li>splitdns.config - file enables you to specify the DNS server that Traffic Server should use for resolving hosts under specific conditions. </li></ul><ul><li>ssl_multicert.config - configure Traffic Server to use multiple SSL server certificates with the SSL termination option. </li></ul><ul><li>storage.config - lists all the files, directories, and/or hard disk partitions that make up the Traffic Server cache. </li></ul><ul><li>update.config - how Traffic Server performs a scheduled update of specific local cache content. </li></ul>
    14. 14. How - configuration <ul><li>There are a lot of configuration files </li></ul><ul><li>I know what you must be thinking…. </li></ul>
    15. 15. This is too complicated.
    16. 16. But remember… <ul><li>I’m really lazy. </li></ul>
    17. 17. How - configuration <ul><li>Never fear. You primarily deal with this one (routing rules): remap.config </li></ul><ul><li>You’ll tune this one when you’re first setting it up (system vars): records.config </li></ul><ul><li>If you’re using caching, you’ll set up this one: storage.config </li></ul>
    18. 18. How – config – Reverse Proxy <ul><li>ATS acts as the origin server </li></ul><ul><li>IMO, this is the major use case </li></ul><ul><li>ATS can front one more more websites </li></ul>
    19. 19. How – config – Reverse Proxy <ul><li>records.config: </li></ul><ul><li>CONFIG proxy.config.proxy_name STRING <hostname> </li></ul><ul><li>CONFIG proxy.config.http.server_port INT 80 </li></ul><ul><li>CONFIG proxy.config.reverse_proxy.enabled INT 1 </li></ul><ul><li>Depending on what you’re in front of: </li></ul><ul><li>CONFIG proxy.config.http.keep_alive_no_activity_timeout_in INT 60 </li></ul><ul><li>CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 1 </li></ul><ul><li>CONFIG proxy.config.http.transaction_no_activity_timeout_in INT 15 </li></ul><ul><li>CONFIG proxy.config.http.transaction_no_activity_timeout_out INT 30 </li></ul><ul><li>CONFIG proxy.config.cache.ram_cache.size LLONG 1332735284 </li></ul>
    20. 20. How – config – Reverse Proxy <ul><li>storage.config </li></ul><ul><li>/dev/raw_sdb 1078000000 </li></ul><ul><li>NOTE: To use RAW disk you must use the '/usr/bin/raw' program to bind a raw device to a an existing block device. </li></ul>
    21. 21. How – config – Reverse Proxy <ul><li>remap.config </li></ul><ul><li>map http://www.example.com http://realsite.example.com </li></ul><ul><li>Now, reload traffic server: </li></ul><ul><li>sudo /usr/local/bin/traffic_line -x </li></ul>
    22. 22. How - quick notes about cache <ul><li>You can purge objects from the cache with PURGE curl -X PURGE -v http://example.com/remove_me.jpg </li></ul><ul><li>There is a UI to inspect and modify the cache. You can enable it with: CONFIG proxy.config.http_ui_enabled INT 1 </li></ul><ul><li>(I came to learn very recently that the UI won’t be supported, so if you really want it, make a case for it) </li></ul>
    23. 23. How – config – General Proxy <ul><li>Forward Proxy </li></ul><ul><li>Your FEs make requests to APIs (yours and partners/external) </li></ul><ul><li>You don’t need to keep a sep proxy technology around (i.e. Squid), ATS does this too. </li></ul>
    24. 24. How – config – General Proxy <ul><li>You can do all the cool cache stuff </li></ul><ul><ul><li>configuration for computation for object freshness </li></ul></ul><ul><ul><li>Push content into the cache </li></ul></ul><ul><ul><li>Pin contents in the cache for specific periods </li></ul></ul><ul><ul><li>Ignore no-cache headers </li></ul></ul><ul><li>Translation of Squid directives to ATS: https://cwiki.apache.org/confluence/display/TS/SquidConfigTranslation </li></ul>
    25. 25. But, but, but…. <ul><li>“ Well, I don’t expect lots of traffic” </li></ul><ul><li>“ I already have VIPs/Load Balancers” </li></ul><ul><li>“ Do I really need a proxy server?” </li></ul><ul><li>“ Is this yet another thing I need Ops for?” </li></ul>
    26. 26. How – Usage <ul><li>Even if you can handle your traffic: </li></ul><ul><ul><li>change origin servers without changing DNS </li></ul></ul><ul><ul><li>redirect different URL paths, or rewrite URLs altogether </li></ul></ul><ul><ul><li>send traffic cross-colo during upgrades, for testing, etc. </li></ul></ul><ul><ul><li>use minimal server installations across the world, just put ATS there and have DNS resolution point there. </li></ul></ul>
    27. 27. Extending How - Plugins <ul><li>You can extend the functionality of ATS with plugins </li></ul><ul><li>There are plugins available (forthcoming) by Yahoo! </li></ul><ul><li>You can build your own plugins and there is lots of documentation available. </li></ul><ul><li>You are STRONGLY encouraged to contribute back! </li></ul>
    28. 28. Extending How - Plugins
    29. 29. Example functionality of plugins <ul><li>Modify the response </li></ul><ul><li>Do a db lookup based on a header </li></ul><ul><li>append or remove query string params or headers before they are sent to the origin server </li></ul><ul><li>Respect custom headers </li></ul><ul><li>More advanced URL rewriting (more than regex) </li></ul>
    30. 30. Ok, nothing is that easy <ul><li>Obviously, create the remap.config and rules </li></ul><ul><li>You may want to create your own plugins (probably not) </li></ul><ul><li>Code changes </li></ul><ul><ul><li>If you plan on using the cache, your cache control headers should be configurable (you should be doing this anyway) </li></ul></ul><ul><li>Process changes </li></ul><ul><ul><li>Ops should own YTS, dev might need to set it up </li></ul></ul><ul><ul><li>QA needs to have YTS in their env; devs should have one too </li></ul></ul><ul><li>Ops changes </li></ul><ul><ul><li>If you don’t have monitoring, this would be a good time to add it. </li></ul></ul>
    31. 31. Competitors <ul><li>There are plenty of Open Source competitors </li></ul><ul><li>Not easy to make an apples-to-apples comparison </li></ul><ul><li>I don’t have any benchmarks </li></ul><ul><li>Look for the features you want and an active community. </li></ul>
    32. 32. Competitors: A stolen slide, probably not up-to-date! ATS HAproxy nginx Squid Varnish mod_proxy Worker Threads Y N N N Y Y Multi-Process N Y Y N Y Y Event-driven Y Y Y Y N N? Plugin APIs Y N Y part Y Y Forward Proxy Y N N Y N Y Reverse Proxy Y Y Y Y Y Y Transp. Proxy Y Y N Y N N Load Balancer part Y Y Y Y Y Cache Y N Y Y Y Y ESI soon N N Y Y N ICP Y N N Y N N Keep-Alive Y N Y Y Y Y SSL Y N Y Y N Y
    33. 33. What is ESI? <ul><li>“ Edge Side Includes” </li></ul><ul><li>Think SSI on the “Edge” </li></ul><ul><li>Example in your markup (taken from Wikipedia) </li></ul><ul><ul><li><esi:include src=&quot;http://example.com/1.html&quot; alt=&quot;http://bak.example.com/2.html&quot; onerror=&quot;continue&quot;/> </li></ul></ul><ul><li>(Something to think about – ESI will change your development processes, testing, etc.) </li></ul>
    34. 34. ESI <ul><li>Another Example </li></ul><ul><li><esi:try> </li></ul><ul><li><esi:attempt> </li></ul><ul><li><esi:comment text=&quot;Include an ad&quot;/> </li></ul><ul><li><esi:include src=&quot;http://www.example.com/ad1.html&quot;/> </li></ul><ul><li></esi:attempt> </li></ul><ul><li><esi:except> </li></ul><ul><li><esi:comment text=&quot;Just write some HTML instead&quot;/> </li></ul><ul><li><a href=www.akamai.com>www.example.com</a> </li></ul><ul><li></esi:except> </li></ul><ul><li></esi:try> </li></ul><ul><li>Read the spec at: http://www.w3.org/TR/esi-lang </li></ul>
    35. 35. Questions? <ul><li>http://trafficserver.apache.org/docs/v2/admin/ </li></ul><ul><li>http://ostatic.com/blog/guest-post-yahoos-cloud-team-open-sources-traffic-server </li></ul><ul><li>https://cwiki.apache.org/confluence/display/TS/RoadMap </li></ul><ul><li>http://www.oscon.com/oscon2010/public/schedule/detail/13878 </li></ul>
    36. 36. Questions for the Audience (you!) <ul><li>I have some of my own: </li></ul><ul><ul><li>Developing in something other than PHP? </li></ul></ul><ul><ul><li>Anyone moving away from PHP? If so, why? </li></ul></ul><ul><ul><li>Big challenges you’re facing right now? </li></ul></ul><ul><ul><li>Frameworks/CMSes – not a lot of talk about them this year </li></ul></ul><ul><ul><li>What technology changes are you investing in? </li></ul></ul><ul><ul><li>Are you doing unit/functional/perf testing regularly? </li></ul></ul>