1

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:

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:

<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.

2

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

| improve this answer | |
  • Caching comes in handy when crafting your page right? Profiling of settings page shows that all db queries execute in 1ms or less, so MySQL connection works nice. I'll update the question with other details. – krizajb May 13 '18 at 18:47
  • Right, caching is something you to do help with scalability. To me, it sounds like something is not configured properly with this server. I just spin up and provision servers with Forge so the baseline setup is a known, working quantity. More: How Agencies & Freelancers Should Do Web Hosting & Web Hosting with ArcusTech’s Nevin Lyne – andrew.welch May 13 '18 at 19:18
  • Well at least now I know that connection to the db isn't an issue nor is the php. Plus now I know what are normal respond times when using control panel. – krizajb May 13 '18 at 19:37
  • How are the response times on the frontend? – andrew.welch May 13 '18 at 19:59
  • Localhost (MAMP) 310ms, VM 2050ms. Test done on default commerce 2 templates index.html. – krizajb May 13 '18 at 22:21
2

I have two troubleshooting suggestions to document here based on recent experiences with sluggish control panels:

  1. Check the /config/general.php file to ensure 'devMode' => true IS NOT enabled for the environment. This fixed symptoms where the control panel was slower than normal (~4 seconds) and CPU usage on the hosting account was extremely high.

  2. Rename the /public_html/cpresources directory to cpresources-bk and let it be automatically recreated by Craft. If there are issues, revert the name change... if no issues, delete the backed up directory. Ensure the directory has the correct permissions. This fixed issues where control panel page loads were very slow (~10 seconds) and Dev Tools network tab showed CSS and JS files loading very slowly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.