Slow performance/Long response times 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 in php.ini
connecting to MySQL using 127.0.0.1 instead of localhost (.env)
set HostnameLookup Off in apache httpd.conf
set ServerName 10.10.0.20 in apache httpd.conf 
accessing the page via 10.10.0.20 instead of virtual host craftcms
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:

&lt;VirtualHost *:80&gt;
    DocumentRoot "/opt/webroot/craftcms/web/"
    ServerName craftcms
    ErrorLog "/var/log/httpd/craftcms-error_log"
    CustomLog "/var/log/httpd/craftcms-access_log" combined

    &lt;Directory "/opt/webroot/craftcms/web/"&gt;
        Options FollowSymLinks
        AllowOverride None 

        ## Removes index.php from Craft URLs ##
        &lt;IfModule mod_rewrite.c&gt;
            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]
        &lt;/IfModule&gt;
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;


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.
So something is definitely wrong; you should be seeing response times of around 300-500ms or so. What I'd suggest doing is profiling things on the Craft side as per the Profiling your Website with Craft CMS 3’s Debug Toolbar article.

You'll at least be able to see exactly what the bottlenecks are from a Craft perspective, and then see how much overhead is being added by the webserver.

If you find that it's slow on the Craft end of things, you may consider making sure that you are properly utilizing the cache tag