When my blog has hundreds of posts, it works well.
But when the posts number is larger than 10,000, the machine’s memory will be cost by ghost. If the number reaches 20,000, it’s done, the server cannot operate any longer.
Is this because ghost is trying to preload posts into memory?
20,000, it’s done, the server cannot operate any longer.
Could you please describe this behaviour with more details? Which Database, which server, when does the server not operate etc.
Is this because ghost is trying to preload posts into memory?
Yeah we preload resources on bootstrap to generate the blog’s urls for an upcoming feature: dynamic routing. But we only keep a minimal set of fields in memory. This behaviour was added in 1.17.3 to pre-catch any unexpected behaviour with url preloading.
You can currently disable preloading urls with putting disableUrlPreload: true in your config file. But this config option will be removed as soon as we ship dynamic routing.
When there are over 20,000 posts in the mysql database, after the ghost process starts, the memory cost will increase untill the memory is 100%. Then the machine cannot be connected by ssh/http.
After I truncated the tables “posts” and “posts_tags”, the server is back in service now.
Could you please update your blog to the latest Ghost version (1.22.3) and report back?
I doubt it will make a huge difference, but still good to share how the behaviour is.
The goal is that Ghost has a knowledge of all resource urls (for posts, users, pages, tags) in memory at runtime, yes. Not sure what you mean by scanning? We don’t expose all the urls somewhere, it’s for internal processing.
Was ghost update successful? Doesn’t look like it was. ghost setup migrate should fix your state.
The migration can run a little longer if you have 20.000 posts
That is good news. That means Ghost is able to fetch all your resources, generates a set of urls and you are currently not running into serious problems.
If you discover any weird behaviour, don’t hesitate to come back here
Oh, do you mind sharing an export of your blog with me?
It could be useful for me when testing performance. I will respect your data with respect and only use it for local testing. If so, please send the JSON to kate@ghost.org.
I can understand if you say no But I’ll give you a hug when you say yes
A backup of your database should be in content/data.
Not sure why you are getting a 502 on export. The exporter is a labs feature and it was e.g. never designed to be performant. But as said, you should find backups of your database in your content folder