From eb52cb06bb7969f3807b47701f0e5c6749a782d9 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 30 Nov 2020 13:27:40 +1300 Subject: [PATCH] Improved threading performance on non-SQLite clients refs https://github.com/TryGhost/Ghost/pull/12431 - child_process are more expensive to run comparing to worker_threads (ref. https://wanago.io/2019/05/20/node-js-typescript-14-performance-hooks/) - limiting child process only to sqlite backed instances allows high load servers running with MySQL (most usecases) to continue using worker_threads --- core/server/overrides.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/server/overrides.js b/core/server/overrides.js index a1693fbd9e..2ffe6e8c09 100644 --- a/core/server/overrides.js +++ b/core/server/overrides.js @@ -1,3 +1,5 @@ +const config = require('../shared/config'); + /** * If we enable bluebird debug logs we see a huge memory usage. * You can reproduce by removing this line and import a big database export into Ghost. @@ -9,7 +11,10 @@ process.env.BLUEBIRD_DEBUG = 0; * Force bthreads to use child_process backend until a worker_thread-compatible version of sqlite3 is published * https://github.com/mapbox/node-sqlite3/issues/1386 */ -process.env.BTHREADS_BACKEND = 'child_process'; +const isSQLite = config.get('database:client') === 'sqlite3'; +if (isSQLite) { + process.env.BTHREADS_BACKEND = 'child_process'; +} const moment = require('moment-timezone');