Why syncing files inside a container makes the application faster


This is a strange issue I have been looking at for a few days now. Wondering if anyone can help me with the reason.

I have a e-commerce website running in Kubernetes. For improved performance the core php files are copied from network storage into a ramdisk (tmpfs).

The ramdisk is a hostpath, I have an init container that will fill the ramdisk before the php container comes online and uses it.

Before I set up the init container I was doing this manually, logging into the php container and rsync’ing from the network storage to the ramdisk.

Now this is the interesting part…

When I manually rsync the files on the php container into the ramdisk the application is around 2-3 seconds quicker to load than when the ramdisk is filed via the init container.

Why? I imagine that this is something to do with file cache inside the container? However why would it make such a big difference to performance if the files are in a ramdisk and that pod is accessing them? Why does running an rsync inside the container make the site 2-3 seconds faster?

Is there any logic I am missing here?

Cluster information:
Kubernetes version: 1.17.12-gke.1504
Cloud being used: GKE
Host OS: Ubuntu