Ghost Performance Degradation

  • What’s your URL? - https://datascientyst.com/

  • What version of Ghost are you using? latest - 5.20

  • How was Ghost installed and configured - Digital Ocean, CloudFlare as CDN

  • What Node version, database, OS & browser are you using?
    Ubuntu 20.04, node - v16.18.0, mysql

  • What errors or information do you see in the console? - no errors

  • What steps could someone else take to reproduce the issue you’re having? - test performance

Testing Desktop performance with:

https://pagespeed.web.dev/

Example page:

Problem:
Reduce initial server response time

Server is:

2 GB / 2 CPU AMD Premium

The score was much better few months ago. It seems dropped after:

  • adding more content
  • enable membership
  • enable comments

There are 2 similar sites but with small difference:
no comments, cache everything 99 score, 50 posts

no members, cache everything 84 score, 600 posts

members, cache standard, 60 - 70 score, 240 posts

  1. How can I identify/debug/investigate the problem?
  2. What are the optimal Ghost requirements for RAM, CPU?
  3. Is paid ghost option for improving performance?

P.S. CloudFlare topic - https://community.cloudflare.com/t/lcp-issue-longer-than-2-5s-speed-index-8-5-s/429393/5

The server response time does seem long. Adding in CF complicates things and makes it harder to tell if the problem is on CF’s side or Ghost’s.

With that in mind, have you tried totally disabling CF services and seeing what the server response time is? That would at least help hone in on the issue.

2 Likes

At that moment I tried to increase CPU from 1 to 2 but there is issue on Digital Ocean side.

So with CF:

CF on Pause:

These are the CF settings:

Thanks for following up. It doesn’t seem like the culprit is CF.

Since you mentioned that you recently enabled members/comments, what happens if you temporarily turn those off? Do you see a change in performance?

My other suggestion would be to restart Ghost and see if that improves your performance.

1 Like

Thank you for helping on this.

So results:

disable comments didn’t do any difference.

Disable of members do difference of 10 15 score and improve:

Reduce initial server response time

P.S. I’ve did update and restart to the latest version.
Didn’t face any difference.

  1. datascientyst.com

Changing theme to Casper 5.3.2

Improve the Desktop performance to 85, mobile remain the same:

  1. Adding members and changing cache level to standard for softhints.com

change score from 95 to 99.

Will continue to investigate what is going on.

Let us know what you find.

The biggest issue I see is that it’s taking the server longer than usual to respond (around 3s for the DataScientist homepage). For comparison, I have a site on DO (lowest tier, but no CF) that has a response time of 200ms. Are you running multiple sites from your single server? How are you building your homepage? If you’re using a lot of get helpers that could impact performance.

1 Like

Are you running multiple sites from your single server?

Yeah. 2 servers with 3 ghost instances.
Similar setup, ghost versions, CF usage.
The only one with performance issue at the moment is the commented site.
Several weeks ago - the problematic site was better.

Some of the other sites have 3 times more articles, same theme and score is > 95

How are you building your homepage? If you’re using a lot of get helpers that could impact performance.

Yeah. There are multiple gets in order to build the hierarchy and also the left side navigation.
Plus search on the featured posts in order to simulated drop down menu.

The same apply for the home page + additional searches.

Just tested again and things were 1000x faster, so maybe you made some progress?

The main change is the workers in CF: more info - Cloudflare and Ghost - bypass cookies - #6 by Johny_K

And Cache everything from CF.

Now I’m working on sign in - it seems that:

// Cookie prefixes that cause a request to bypass the cache when present.
const BYPASS_COOKIE_PREFIXES = [
  "ghost-members-ssr",
  "admin-api-session"
];

// URL paths to bypass the cache (each pattern is a regex)
const BYPASS_URL_PATTERNS = [
  ".*/members/api/member/"
];

This is not enough to fully work members, sign in and /ghost/

Thanks you @RyanF ,

For the moment cache everything from CF + upgrade on the CPU number from 1 to 2 is done.

Next I’ll

  • start optimization related to the theme.
  • check Ghost config and cache
  • read about Ghost optimization - self hosting - whatever I can find

P.S. Default casper on another blog on the same server is extremely fast - on Both web and Desktop

Nginx config

 GNU nano 4.8                                                                        datascientyst.com.conf                                                                                  
server {
    listen 80;
    listen [::]:80;

    server_name datascientyst.com;
    root /var/www/datascientyst/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

Sounds like a plan.

We recently updated our config docs, which might be of interest to you:

1 Like

So I guess the update is (maybe there is a typo in the docs):

  "caching": {
	"contentAPI": {
	    "maxAge": 10
	}
  }

I’m not sure that I understand these two correctly:

  • “frontend” - with "maxAge": 0, controls responses coming from public Ghost pages (like the homepage)
  • “contentAPI” - with "maxAge": 0, controls responses coming from Content API

But I think that for my case I need to change both of them.
I’m testing now with setting both to 60.

  "caching": {
		"contentAPI": {
		    "maxAge": 60
		},
		"frontend": {
		    "maxAge": 60
		}
  }

I guess I can check default values in this file:

Thanks again for your time and valuable help.

So at the end I think that problem is related to the VPS.
Tested higher VPS size didn’t change the performance.

Testing new VPS providers shows promising.

P.S. Few other optimization were done as well:

  • CF cache everything
  • Ghost caching
  • reduce 3rd party JS

So Ghost is really fast and works well.
For medium and high volume sites - I believe that VPS and CDN are important.
They need to be tested and monitored.

Thanks for the time and help @RyanF

1 Like

Nice work! I’m sure these insights will be helpful to other users.

2 Likes