Hello, I suspect that this is an elementary question but maybe I don’t understand how to search for it. I am a programmer, but having a small company and we can’t afford yet a system administrator, so I play this role as well with my limited practice on it.

Currently we use CentOS 5.10 but I suspect the answer should also apply in other versions or distributions. We use a really small PHP core framework , less than 100kb , and we run many applications and sites using that and few of them with really heavy traffic. The question is how to load that folder to memory and not to read those files every time?. Also I understand that when we change those files we should execute a command to get the new contents to memory.

I tend to believe that this is has to do with the system and not the web server, so I suspect that wouldn’t mind when the web server restarts, I am right on that or should I do something more?

Thank you for your time, I understand that this must be something very basic but I have to play this role of system administrator until we have the money to hire one, of course I am not, I am a programmer.

Recommended Answers

All 6 Replies

The operating system should automatically cache those files in memory when read. IE, you should not have to deal with this! The caveat is whether or not you have sufficient RAM to cache these files. 100K is not much these days.

FWIW, upgrading from CentOS 5.x to 6.x will provide MAJOR performance improvements, especially in file caching.

Thank you rubberman for your quick and , easy for me , response, that the OS will cache those files automatic for me. We will upgrade to a new CentOS version soon (6.4) . I would like to understand how this automatically caching is done , the OS is reading a file signature and if it is the same with the one having a memory load’s it from there ? … I am asking because in the rare times we change the core (those files in memory) , those should change in memory as well. If the OS is asking the file for a signature everytime is not a great practice , I could have a command telling the OS not to do so and load it from memory until I say otherwise. As said I am not system administration and I am asking only what sounds logical to me.

Rubberman, as usual, is correct.
One of the most important things you can do to make your cache more efficient is to make sure there is plenty of RAM in the server. To make the most efficient use of real memory, Linux automatically uses all free RAM for buffer cache.

Here is a site that will give you a good idea of what a cache buffer is used for and how a linux system uses it to make it more effecient.
The Buffer Cache

An alternative is to create a ram disc big enough to hold those files, and on boot up copy the php file directory there after the ram disc is created (you can do this in /etc/rc.local). Then you point your php to that directory with the include_path environment variable when it starts up, or you can use the php function set_include_path($path) function in your code.

commented: Clean and clear +6

Thank you rubberman and rch1231. Although I have not idea (yet) what a ramdisk is , how to create and manage it , it sounds exactly what I was looking for. I have to do some reading and experiments locally before to do it in the production server. Thank you for the solution.

Fair enough. Holler again if you hit a roadblock. Remember, the man pages, like Google, are your friends! :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.