I am running Craft CMS 3 and Commerce 2 on a virtual machine composed of Centos 7, Apache 2.4, PHP 7.2 and MySQL 5.7.22. It seems almost impossible working with the control panel with such huge response times:
- http://craftcms/admin/dashboard takes 2.6s to load. (500ms on localhost MAMP)
- http://craftcms/admin/settings takes 3s to load (350ms on localhost MAMP).
I've tried the following stuff:
- assigned php
memory_limit
to 512M inphp.ini
- connecting to MySQL using
127.0.0.1
instead oflocalhost
(.env
) - set
HostnameLookup Off
in apachehttpd.conf
- set
ServerName 10.10.0.20
in apachehttpd.conf
- accessing the page via
10.10.0.20
instead of virtual hostcraftcms
- removed usage of
.htaccess
file following this guide - unloaded unnecessary apache modules
- disabling cgi apache module
Looking at the network statistic the TTFB takes 4.28s and whole page loads in 5.01s. I am assuming it's the configuration issue since when running MAMP on windows everything responds a lot quicker. Any ideas what I should be looking at or is this performance as intended?
What strikes me the most is that phpmyadmin responds very quickly. I tried running a standalone (non-Craft) page with and without PHP. Page with PHP loaded cca 20ms longer. I would assume PHP doesn't cause mentioned problems.
craftcms.conf:
<VirtualHost *:80>
DocumentRoot "/opt/webroot/craftcms/web/"
ServerName craftcms
ErrorLog "/var/log/httpd/craftcms-error_log"
CustomLog "/var/log/httpd/craftcms-access_log" combined
<Directory "/opt/webroot/craftcms/web/">
Options FollowSymLinks
AllowOverride None
## Removes index.php from Craft URLs ##
<IfModule mod_rewrite.c>
RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule ^(.+) /index.php?p=$1 [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
Update:
After disabling unnecessary apache modules responses are a lot faster. I also tried using worker and even MPM, changes in timings were neglectable.
Update2:
Craft3 debug toolbar shows the following critical timings when loading settings page:
- 11:43:00.140 1098.4 ms craft\web\twig\Template::display settings
- 11:43:00.154 1083.8 ms craft\web\twig\Template::display →_layouts/cp
- 11:43:00.374 863.6 ms craft\web\twig\Template::display →→_layouts/basecp
- 11:43:00.375 862.4 ms craft\web\twig\Template::display →→→_layouts/base
This is output of same data on localhost:
- 11:52:46.713 124.0 ms craft\web\twig\Template::display settings
- 11:52:46.716 121.4 ms craft\web\twig\Template::display →_layouts/cp
- 11:52:46.743 94.4 ms craft\web\twig\Template::display →→_layouts/basecp
- 11:52:46.743 93.9 ms craft\web\twig\Template::display →→→_layouts/base
The difference in timings is quite big.