Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Hi guys, this thread is for tips, answers and discussion about performance (CouchCMS, Mysql, Php, VPS). Ask and share anything related.

Rule #1
If you ever need to show/use only page titles and page names (k_page_title, k_page_name, k_page_id, k_page_foldername.. etc.. ) without all the rest info from page's editables - use skip_custom_fields='1' in cms:pages, because it will significantly reduce the number of queries CouchCMS sends to backend.


Rule #2
Always specify your limit in cms:pages if it can be over 1000 pages. Example: limit='5000'. CouchCMS prevents running loops indefinitely.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
First thing is cost of hosting.

Things that directly influence how much we pay:

  1. Number of visitors
  2. Amount of cloned pages
  3. Information in various looks on one page

With 100 visitors a week, 100 blog posts with archives & categories in sidebar, with related posts in footer - please stop reading this thread. Everybody has clients like this and okay shared hosting costs $2 - $10 per year. CouchCMS delivers flawlessly.

Tips in this thread apply to projects with hosting costs from $10 per month. It's because with deep tweaking couchcms can run on much cheaper hosting plan. It should be noticeable to go from $50 to $20 (or $10 to $2). It's also fun and good for the planet.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Sometimes tweaking performance is a must, not because of $$, but to make something possible on the website.

Sample task for developer is to create sidebar:
  1. show list of states in country + count companies in each state AND
  2. show for each state list of sub-states with count of companies in it.

In the end we have > 20 states and > 450 substates.
It looks like this:
Image 046.png
list-of-states
Image 046.png (12.66 KiB) Viewed 3275 times


Reference query with cms:pages has following params:
Page generated in: 17.147 sec Queries: 608 -> my(dev) VM, CPU 70%, host: powersaver
Page generated in: 24.808 sec Queries: 608 -> my(dev) VM, CPU 70%, host: powersaver -> cold run
Page generated in: 1.655 sec Queries: 611 -> production server


Yeah, production server (PrS) screams! But.. with anything more than a couple of visitors 1.6 sec on production server will turn into really slow page load (which has other elements too).

Reference query looks like below, where I take each state and then each substate of that state. Notice the use of #1 rule: skip_custom_fields='1'.

Rule#1
If you ever need to show/use only page titles and page names without all the rest info from page's editables - use skip_custom_fields, because it will reduce the number of queries CouchCMS sends to backend.


Limit=unlimited is my invention, where I set <cms:set unlimited='10000000' scope='global' />. It is important to know that CouchCMS never lists more than 1000 pages if limit is not specified in your code. Maybe @KK thinks that this is an impossible number for you, my friends, :lol: but it of course helps to prevent some nasty code to loop indefinitely.
Rule #2
Always specify your limit in cms:pages if it can be over 1000 pages.


Finally, reference query:
Code: Select all
<cms:pages masterpage='data/states.php' aggregate_by="admin/firma.php::firmastate_rel" 
         custom_field="k_rel_count>0" skip_custom_fields='1' limit=unlimited
         orderby='page_name' order='asc' return_sql='0' >

  <li>
     <a class="list-group-item" href="<cms:embed code=link_for_location />">
      <cms:show k_page_title />
      <span class="text-muted text-regular pull-right"><cms:show k_rel_count /></span>
     </a>
    
     <cms:pages masterpage='data/substates.php' aggregate_by="admin/firma.php::firmasub_rel"
            custom_field="k_rel_count>0 | state_rel=id(<cms:show k_page_id />)"
            skip_custom_fields='1' paginate='0' orderby='page_name' order='asc' return_sql='0'>
        <cms:if k_paginated_top ><ul></cms:if>
    
        <li>
         <a class="list-group-item" href="<cms:embed code=link_for_location />">
            <cms:show k_page_title />
            <span class="text-muted text-regular pull-right"><cms:show k_rel_count /></span>
         </a>
        </li>
       
        <cms:if k_paginated_bottom ></ul></cms:if>
     </cms:pages>
  </li>

</cms:pages>


This is a very good query, based on the fact that each company (firma) is related to 1 state and 1 substate with editable type='relation' in template with companies. So with aggregate_by I count all companies. More details about this parameter in this topic viewtopic.php?f=5&t=8581&p=16352&hilit=cms%3Aquery+query#p16352

Later I will publish this query rewritten with cms:query with details why it can speed up things at least 1.5x, making following stat possible:
Page generated in: 7.597 sec Queries: 44 -> my VM, CPU 70%, host: powersaver
Page generated in: 10.943 sec Queries: 44 -> my VM, CPU 70%, host: powersaver, cold run after restart
Page generated in: 1.107 sec Queries: 47 -> server
GOAL: 0.3s

This is much better, more than twice faster on my local VM and 1.5x faster on PrS. Stay tuned.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Guys! I want a lot of joy to share with you one of my Couch test.
Please see what happens with the speed time for Couch page load if you have PHP version 7

I changed my version 5.6 to 7 because Anton told me that this has great significance!
This is a revolution!

Attachments

Again 50% faster!
This time the test in admin page ...

Attachments

I am happy you found it helpful :) Come for more advices :D Welcome.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: Hi guys, this thread is for tips, answers and discussion about performance (CouchCMS, Mysql, Php, VPS). Ask and share anything related.

Ok, although it's an old thread!

I have a site at https://covinasunriserotary.com which is REALLY SLOW. Analysis at webpagetest.org rates it "F" in performance. Although there could be considerable optimization done in the site, the major problem appears to be initial page load time - about 6 - 9 seconds! I'm a relative newb to Couch, but I believe it's a problem in the server assembling the Couch page. If I analyze https://covinasunriserotary.com/test.php (not a Couch page) it load instantaneously. I understand there is database access and other dirty work that needs to be done before a page is delivered, but this is really poor. What can I do to analyze the issue further and then improve it?

Another issue on pages like my articles.php where I have several blog articles listed along with an image for each one:
The images are loaded to the gallery at about 1900x1200 size, then the html on that page has size parameters to display them in thumbnail size. I understand this is not great as the entire large file is actually loaded in the page. What techniques are there that I can use to load small thumbnail images in this case? THANKS!
Hey, thanks for your interest in making site faster :)
First, we need to measure time which Couch takes to process the code and generate html. I think there was a topic about measuring with code sample, I will find it later today if you want.

Next, images can be loaded as is in backend, but have width-height, enforce_max parameters set. Also you can add unlimitef number of associated editables of type thumbnail of various w-h sizes and upon uploading, those will be generated by cms.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Adding onto Trendoman response above, which is a large factor - my analysis of the site in question is that the main page took 5 seconds waiting before downloading - before the browser even started downloading those larger images it had a 5 seconds wait time for some reason.

I would suggest two things:
1) Turning on couch cache will remove this issue outside of super-admin user (normal end-users). It will cache the entire couch-output version of each page and serve those already produced HTML pages to users instead of generating the pages through couch each and every time a user visits the site. The cache is updated when you edit a page or add a page.

2) There must be some underlying code that is hanging and causing this, perhaps an extremely large query, or some strange loop in your template that's causing the page to hang for 5 seconds before finishing its generation! 5 seconds is a very long time for couch to generate a page
Image
9 posts Page 1 of 1