7
CPU [                         0.0%]     Tasks: 15, 2 thr; 1 running
Mem [||||                 14/256MB]     Load average: 0.00 0.00 0.00 
Swp [|                     1/256MB]     Uptime: 15 days, 06:02:31

Above is the memory usage on my server (Ramnode, 256MB RAM with 256MB Swap) when there's no Ghost instance. On my VPS I am running 4 Ghost instances.

So when I ran a Ghost instance here with the command node index.js, it spawns 5 workers.

PID   USER   PRI  NI  VIRT  RES   SHR  S CPU% MEM%   TIME+  Command
10380 user    20   0  975M 80328  7712 S  0.0 30.6  0:00.00 node index.js
10381 user    20   0  975M 80328  7712 S  0.0 30.6  0:00.00 node index.js
10382 user    20   0  975M 80328  7712 S  0.0 30.6  0:00.00 node index.js
10383 user    20   0  975M 80328  7712 S  0.0 30.6  0:00.00 node index.js
10384 user    20   0  975M 80328  7712 S  0.0 30.6  0:00.00 node index.js

5 workers are actually quite a lot. And 30% is also a lot.

And now, the htop reading

CPU[                               0.0%]     Tasks: 18, 7 thr; 1 running
Mem[|||||||||||||||||||        82/256MB]     Load average: 0.00 0.00 0.00 
Swp[||                          8/256MB]     Uptime: 15 days, 06:22:29

How to reduce the memory usage? If I can adjust the number of workers, which file should I edit? If we have Ghost dev team here, do you have any plan on this issue?

HBruijn
  • 84,206
  • 24
  • 145
  • 224

1 Answers1

6

Ghost runs a single node process per instance. I believe what you're seeing there is that htop shows the underlying threads of processes, so it looks like you have one Ghost instance running but node/v8 has five active threads. Despite JavaScript being single-threaded, the engine/vm itself can be multi-threaded.

We (the Ghost project) do pay attention to the memory footprint so that we can do whatever we can do keep it as small as possible. I personally think 80MB is pretty good but obviously different people and situations have different criteria for what's "pretty good."

jtw
  • 76