Performance surprise

There has been lot of talk about performance with kirby. I have recently found out about one neat thing about cashing.

I have small VPS running ubuntu with few websites on there, recently ive noticed this on my VPS. This is htop showing memory usage - the green is 227MB of ram vps is currently using. I wondered what is the yellow.

It turns out is OS memory cache - i asked around some linux people and it seems that its linux being awesome cashing files that i read from disk often (if there is enough spare ram). Yes that means PHP scripts and .md files kirby has to read.

I had no idea linux does this.

Kirby still has to generate requested html files if you dont have some cashing turned on but its whole lot faster than reading from disk. And if you have even the simple file cashing turned on - that cashed page will probably get to the ram and will be served blazingly fast.

3 Likes

PHP also has a thing called OPcache which holds the precompiled bytecode of the files in memory. This spares your machine from loading the files and compiling them for each request. OPcache is enabled for most PHP setups so chances are that Linux doesn’t even need to cache the files :wink:

1 Like

I wouldnt be so sure about OPcache enabled by default (i dont think it is). Also it just cashes php files and its usualy not that big to hold bigger sites (you dont want to allocate too much memory to it because that memory cant be used by other processes).

But yeah, the point is filebased CMS can be very very fast with just little cashing setup.