Desmond Hume
Desmond Hume

Reputation: 8627

Does Linux cache (small) files to optimize I/O?

My scripts need to read a small file, about 10 bytes, on every HTTP request processed by PHP (PHP-FPM), so I wonder whether the file will be cached by the OS (in my case Ubuntu) to avoid disk I/O. Or should I avoid it?

Upvotes: 0

Views: 248

Answers (2)

tly_alex
tly_alex

Reputation: 113

The answer to your question is:

  1. Yes, it will be cached.

  2. It depends on yourself.

The following question would be very helpful.

Does the Linux filesystem cache files efficiently?

Upvotes: 0

DusteD
DusteD

Reputation: 1410

Yes. If you start a program like htop and observe the yellow part of the memory usage, this is the amount of memory currently being used for disk cache. However, accessing the file will result in a disk-write to update the access time of that file, this can be disabled by adding the "noatime" option to the relevant partition line in /etc/fstab

Upvotes: 3

Related Questions