0

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?

Desmond Hume
  • 8,037
  • 14
  • 65
  • 112
  • 1
    Yes. Although, you might want to consider copying it to a [tmpfs](http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/) or ramfs instead. – Elliott Frisch Nov 30 '13 at 19:28

2 Answers2

3

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

DusteD
  • 1,400
  • 10
  • 14
0

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?

Community
  • 1
  • 1
tly_alex
  • 103
  • 1
  • 9