<p>I have two troubleshooting suggestions to document here based on recent experiences with <strong>sluggish control panels</strong>:</p>

<ol>
<li><p>Check the /config/general.php file to ensure <code>'devMode' =&gt; true</code> 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.  </p></li>
<li><p>Rename the <code>/public_html/cpresources</code> directory to <code>cpresources-bk</code> and let it be automatically recreated by Craft. If there are issues, revert the name change... if no issues, delete the backed up directory. <a href="https://docs.craftcms.com/v3/installation.html#step-2-set-the-file-permissions" rel="nofollow noreferrer">Ensure the directory has the correct permissions</a>. 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.</p></li>
</ol>

CC BY-SA 4.0
2020-04-16T21:32:00.753Z
2020-04-19T21:05:48.133Z
2020-04-19T21:05:48.133Z
Anna_MediaGirl
<p>So something is definitely wrong; you should be seeing response times of around <code>300-500ms</code> or so. What I'd suggest doing is profiling things on the Craft side as per the <a href="https://nystudio107.com/blog/profiling-your-website-with-craft-cms-3s-debug-toolbar" rel="nofollow noreferrer">Profiling your Website with Craft CMS 3’s Debug Toolbar</a> article.</p>

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

<p>If you find that it's slow on the Craft end of things, you may consider making sure that you are properly utilizing the <a href="https://nystudio107.com/blog/the-craft-cache-tag-in-depth" rel="nofollow noreferrer">cache tag</a></p>

CC BY-SA 4.0
2018-05-13T18:47:48.480Z
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
CC BY-SA 4.0
2018-05-13T19:18:49.170Z
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](https://nystudio107.com/blog/web-hosting-for-agencies-freelancers) & [Web Hosting with ArcusTech’s Nevin Lyne](https://devmode.fm/episodes/web-hosting-with-arcustechs-nevin-lyne)
andrew.welch
CC BY-SA 4.0
2018-05-13T19:37:38.930Z
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
CC BY-SA 4.0
2018-05-13T19:59:38.467Z
How are the response times on the frontend?
andrew.welch
CC BY-SA 4.0
2018-05-13T22:21:04.170Z
Localhost (MAMP) 310ms, VM 2050ms. Test done on default commerce 2 templates index.html.
krizajb
CC BY-SA 4.0
2018-05-14T02:06:13.790Z
Yeah something for sure is not right with that server setup imo.
andrew.welch
CC BY-SA 4.0
2018-05-13T18:30:22.250Z
2018-05-13T18:30:22.250Z
andrew.welch
<p>I had the same issue.
In my case the problem was the Volumes configuration in Docker.
Make sure Nginx/Apache has access to the Volume that Craft and web resources are stored: e.g /var/www/ ,in case you are running PHP and Apache in two different containers.</p>
<p>Something like:</p>
<pre><code>nginx:

        volumes:
            - ./craft/app:/var/www/web:cached

php:

        volumes:
            - ./craft/app:/var/www/web:cached

</code></pre>
<p>in your docker-compose file will solve your problem if that's the case.</p>

CC BY-SA 4.0
2021-02-19T14:35:06.933Z
2021-02-19T14:35:06.933Z
Peiman Shokouhian
<p>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:</p>

<ul>
<li><a href="http://craftcms/admin/dashboard" rel="nofollow noreferrer">http://craftcms/admin/dashboard</a> takes 2.6s to load. (500ms on localhost MAMP)</li>
<li><a href="http://craftcms/admin/settings" rel="nofollow noreferrer">http://craftcms/admin/settings</a> takes 3s to load (350ms on localhost MAMP).</li>
</ul>

<p>I've tried the following stuff:</p>

<ul>
<li>assigned php <code>memory_limit</code> to 512M in <code>php.ini</code></li>
<li>connecting to MySQL using <code>127.0.0.1</code> instead of <code>localhost</code> (<code>.env</code>)</li>
<li>set <code>HostnameLookup Off</code> in apache <code>httpd.conf</code></li>
<li>set <code>ServerName 10.10.0.20</code> in apache <code>httpd.conf</code> </li>
<li>accessing the page via <code>10.10.0.20</code> instead of virtual host <code>craftcms</code></li>
<li>removed usage of <code>.htaccess</code> file following this <a href="https://nystudio107.com/blog/stop-using-htaccess-files-no-really" rel="nofollow noreferrer">guide</a></li>
<li>unloaded unnecessary apache modules</li>
<li>disabling cgi apache module</li>
</ul>

<p>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?</p>

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

<p>craftcms.conf:</p>

<pre><code>&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;
</code></pre>

<p>Update: </p>

<p>After disabling unnecessary apache modules responses are a lot faster. I also tried using worker and even MPM, changes in timings were neglectable. </p>

<p>Update2:</p>

<p>Craft3 debug toolbar shows the following critical timings when loading settings page:</p>

<ul>
<li>11:43:00.140  1098.4 ms   craft\web\twig\Template::display    settings</li>
<li>11:43:00.154  1083.8 ms   craft\web\twig\Template::display    →_layouts/cp</li>
<li>11:43:00.374  863.6 ms    craft\web\twig\Template::display    →→_layouts/basecp</li>
<li>11:43:00.375  862.4 ms    craft\web\twig\Template::display    →→→_layouts/base</li>
</ul>

<p>This is output of same data on localhost:</p>

<ul>
<li>11:52:46.713  124.0 ms    craft\web\twig\Template::display    settings</li>
<li>11:52:46.716  121.4 ms    craft\web\twig\Template::display    →_layouts/cp</li>
<li>11:52:46.743  94.4 ms craft\web\twig\Template::display    →→_layouts/basecp</li>
<li>11:52:46.743  93.9 ms craft\web\twig\Template::display    →→→_layouts/base</li>
</ul>

<p>The difference in timings is quite big.</p>

CC BY-SA 4.0
2021-02-10T02:47:36.137Z
krizajb - did you ever solve this problem? I am experiencing the exact same thing when deploying to an Azure App Service Linux app. The slowness for me seems to stem from the twig rendering.
Doug Hill
CC BY-SA 4.0
2021-02-11T08:21:54.850Z
Unfortunately no, this is my vagrant setup that is causing the issue: https://github.com/krizajb/vagrant-lamp-centos I haven't tried Annas solution.
krizajb
<performance>
Slow performance/Long response times
# Slow performance/Long response times

(Asked by: username_0 on 2018-05-13)

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:

    DocumentRoot "/opt/webroot/craftcms/web/"
    ServerName craftcms
    ErrorLog "/var/log/httpd/craftcms-error_log"
    CustomLog "/var/log/httpd/craftcms-access_log" combined

    
        Options FollowSymLinks
        AllowOverride None 

        ## Removes index.php from Craft URLs ##
        
            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]
        
    


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.

**Tags:** performance

> **Comments:**
> **username_1**: username_0 - did you ever solve this problem? I am experiencing the exact same thing when deploying to an Azure App Service Linux app. The slowness for me seems to stem from the twig rendering.  
> **username_0**: Unfortunately no, this is my vagrant setup that is causing the issue: https://github.com/username_0/vagrant-lamp-centos I haven't tried Annas solution.  

---

## 3 answers

### Answer by username_2 on 2020-04-16. Score: 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](https://docs.craftcms.com/v3/installation.html#step-2-set-the-file-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.


---

### Answer by username_3 on 2018-05-13. Score: 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](https://nystudio107.com/blog/profiling-your-website-with-craft-cms-3s-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](https://nystudio107.com/blog/the-craft-cache-tag-in-depth)

> **Comments:**
> **username_0**: 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.  
> **username_3**: 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](https://nystudio107.com/blog/web-hosting-for-agencies-freelancers) & [Web Hosting with ArcusTech’s Nevin Lyne](https://devmode.fm/episodes/web-hosting-with-arcustechs-nevin-lyne)  
> **username_0**: 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.  
> **username_3**: How are the response times on the frontend?  
> **username_0**: Localhost (MAMP) 310ms, VM 2050ms. Test done on default commerce 2 templates index.html.  
> **username_3**: Yeah something for sure is not right with that server setup imo.  

---

### Answer by username_4 on 2021-02-19. Score: 1

I had the same issue.
In my case the problem was the Volumes configuration in Docker.
Make sure Nginx/Apache has access to the Volume that Craft and web resources are stored: e.g /var/www/ ,in case you are running PHP and Apache in two different containers.
Something like:
nginx:

        volumes:
            - ./craft/app:/var/www/web:cached

php:

        volumes:
            - ./craft/app:/var/www/web:cached


in your docker-compose file will solve your problem if that's the case.


---

