I’m creating a test web infrastructure. It contains an Nginx reverse proxy, three WordPress containers, and one Apache + PHP container.
Each web container has its website stored as a bind mount.
When I tried to access the WordPress installation page, I encountered a problem. The page in the first container loads quickly (<1.5 seconds), but the other two containers take >6 seconds.
To try and find the source of the problem, I created a basic .php page in the two slower containers. The PHP page loads instantly. Furthermore, I ran this command on all three containers:
time php -r "file_get_contents('http://127.0.0.1');"
The fast container executed the command in 1 second, while the two slower ones took approximately 6 seconds.
Due to my limited experience, I don’t understand how to resolve this issue.
If you are using the same Docker image and you bind mount a data folder from the same filesystem, it must be something that the two slower wordpress instances are doing not necessarily related to Docker containers. For example as far as I remember, Worpdress can run some “cron jobs” through PHP when someone sends a request to load a page. If anything like that is happening, you can get slower response.
Have you measured accessing the filesystem in those containers? You should get the same speed in all containers. If not, there is also a difference in the filesystems