📜 ⬆️ ⬇️

Apache Traffic Server - unique caching proxy for CDN

image

Once there was an idea to launch a Russian-language version of a popular American website. After some thought, it was decided to implement a fully interactive scheme like examplesite.com -> examplesite.com and get the machine to do as much work as possible.

Some study and experiments with various proxy servers led to an interesting product - Apache Traffic Server , which I want to tell you about.

Traffic Server was originally created by Inktomi Corporation, which was purchased by Yahoo! in 2002. For a long time, the product has been actively commercially used both inside Yahoo !, and on some very large sites. Since 2009, the project has opened the source codes and transferred them to the Apache incubator, and in April 2010 Apache Traffic Server appeared.
')
Details on comparing ATS with other caching and balancing servers can be found here .

I can only briefly say that the ATS architecture exceeds such deserved counterparts as Ngnix, HAproxy and Squid in scalability, while each of the listed products is specialized, while ATS can do more (except perhaps Squid, which can do even more, but an order of magnitude slower ). Serious application? Need to try!

ATS installation
Due to its novelty, the project documentation leaves much to be desired. The abundance of configuration directives, the terrifying heap of files in etc /, the unfinished wiki and the lack of a step-by-step manual at first scared. But then I found a wonderful presentation by Tom Melendez of Yahoo! and everything fell into place.

Further adjustments were made on Centos 5.5 x64.

Step 1. Download the ATS distribution.
[root@Srv1 ~]# wget www.sai.msu.su/apache//trafficserver/trafficserver-2.1.5-unstable.tar.bz2

Step 2. Check availability of necessary libraries.
[root@Srv1 ~]# yum list autoconf automake libtool gcc-c++ glibc-devel openssl-devel tcl-devel expat-devel db4-devel pcre-devel

Step 3. Most likely you will have to install some packages, in my case it took tcl-devel and pcre-devel. Without this step, the compilation will fail. For users of Debian-based distributions, the set of components is slightly different and is described in the README file.

Step 4. Unpack the archive and navigate to the directory
[root@Srv1 ~]# tar -xjf trafficserver-2.1.5-unstable.tar.bz2
[root@Srv1 ~]# cd trafficserver-2.1.5-unstable


Step 5. Compile.
By default, prefix == "/ usr / local" which is enough for tests.
[root@Srv1 trafficserver-2.1.5-unstable]# ./configure [--prefix=PREFIX]
[root@Srv1 trafficserver-2.1.5-unstable]# make install


ATS Setup
Let me remind you of the main commandment of Tom Melendez: “I AM REALLY LAZY!”
Now I will describe the settings for performing our task.

Step 1. Open /usr/local/etc/trafficserver/records.config
CONFIG proxy.config.proxy_name STRING examplesite-ru.com
CONFIG proxy.config.http.server_port INT 80
CONFIG proxy.config.reverse_proxy.enabled INT 1


Step 2. /usr/local/etc/trafficserver/remap.config
map examplesite-ru.com/ examplesite.com/
reverse_map examplesite.com/ examplesite-ru.com/


Step 3. Out of pure curiosity, look at /usr/local/etc/trafficserver/storage.config
And we see that lazy Tom added a small piece of a disk of 256 MB sufficient for tests: var/trafficserver 256M

Run ATS
Service starts by command
[root@Srv1 ~]# /usr/local/bin/trafficserver

Configuration updated command
[root@Srv1 ~]# /usr/local/bin/traffic_line -x

Bingo!
As you can see to start really need a minimum of effort.

My test server is made from the smallest Intel-based Atom 525 computer, which is connected to the Internet via a channel at a speed of 1 Mbps. My test site has a home page about 85 KB in size. It generates a unique Session ID at each call (this always introduces TeleportPro-type sites and various proxies into the rocking chair).

It is easy to calculate that a normal non-caching reverse proxy will spend only about 0.7 seconds to download the page, then 0.7 seconds to return the page, as well as time to “proxify” the content.

In the case of ATS, the additional delay when the page is fully loaded is a circle for significantly less than 1 second, and the processor load is simply imperceptible. Alternately, launching the download site directly and through ATS, I noticed that quite often the proxy gives the page faster than the original! As you can see, 8 years of operation on Yahoo servers in the role of CDN were not in vain.

Back to top
The idea of ​​creating a site mirror will not surprise anyone, but in my plans it should be supplemented with an automated system for translating texts and graphics into Russian using ... (so far only questions in this place). Such a system can be connected using
HTTP transformation plugin .

Source: https://habr.com/ru/post/113728/


All Articles