trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Which cache algorithm is used for disk cache of ATS and how to decide an object to be cached by disk or RAM in ATS?

Open ddkkpp opened this issue 7 months ago • 7 comments

Version: 8.0.3 The docs of ATS does not introduce how the disk cache admits and evicts objects. Also, When an object is received, how ATS decides whether the disk or the RAM caches it? Are the two type of cache work independently?

By the way , I'm looking for somewhere to discuss the usage details of ATS. I already subscribed [email protected], and sent email to [email protected], but the reply is helpless.

Image

I also log in slack with my email address, but I'm not dmitted to join the traffic-server channel.

ddkkpp avatar May 21 '25 04:05 ddkkpp

Probably https://docs.trafficserver.apache.org/developer-guide/cache-architecture/architecture.en.html would be what you are looking for.

The docs of ATS does not introduce how the disk cache admits and evicts objects.

  • Think of the disk cache as a circular buffer. Roughly, as it gets objects to cache, it writes it at the current spot on the circle. Eg, once the disk is full, a new object will overwrite an existing one. (There is a setting to help keep frequent accessed docs in cache -- if a requested object is about to be overwritten, it can be kept.)

Also, When an object is received, how ATS decides whether the disk or the RAM caches it? Are the two type of cache work independently? First an object is written to disk cache. If it's seen frequently enough, it gets promoted to RAM cache.

mlibbey avatar May 21 '25 16:05 mlibbey

Thanks for your careful answer. But I'm confused of the log. I request the same object "http://127.0.0.1:9000/1" for 4 times consecutively. The "cwr" field in the log file shows "FIN" (indicating cache write successful), "FIN", "-", and "-" respectively, and the "chm" field in the log file shows "MISS", "MISS", "HIT", and "HIT_RAM" respectively. Why the first request results in successful caching write but the second request still misses the cache?

Image

ddkkpp avatar May 22 '25 03:05 ddkkpp

could you show the response headers both from origin and from ats? eg,

curl -sD- -o/dev/null "http://127.0.0.1:9000/1"
curl -sD- -o/dev/null "http://$origin/1"

mlibbey avatar May 22 '25 22:05 mlibbey

ATS listens at port 6000, and origin listens at port 9000. "Curl -sD" prints nothing, while curl -v prints something. Also, when I curl -sD from ats, the log file of ATS does not present new lines. Responses from port 6000 (ATS) are:

Image Responses from port 9000 (origin) are:

Image They seem to be the same.

ddkkpp avatar May 26 '25 02:05 ddkkpp

Curls’ -D (dump headers) needs a dash after to display on screen.

I’d start with adding cache headers on the origin— Cache-Control or Expires.

mlibbey avatar May 26 '25 15:05 mlibbey

Thanks much! I first adds the Cache control and Expire headers, which doesn't work. Later I change the disk cache location from "/var/cache/ats_storage" to "/opt/ts/var/trafficserver", and the second request can hit the cache successfully. By the way, does ATS provides available interface to design customized disk cache algorithm?

ddkkpp avatar May 27 '25 15:05 ddkkpp

By the way, does ATS provides available interface to design customized disk cache algorithm?

No, ATS does not provide any such configuration.

bneradt avatar Jun 02 '25 22:06 bneradt