17 days ago
n8n mount uses 800 mb even when i dont use it, then i put it to stateless mode and it dropped to 400 mb. there is only scheduled 2-3 daily scheduled tasks in n8n workflows. is there a way to drop memory to very low levels when n8n workflows are idle? in 2 days it accumulated 0.4 usd already.
Attachments
4 Replies
17 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 17 days ago
17 days ago
Why n8n Uses 800 MB RAM when Idle
Node.js (the runtime n8n is built on) does not automatically release unused memory back to the operating system right away. It keeps allocated memory reserved (RSS memory) in case it needs it later. Additionally, n8n runs continuous background tasks, telemetry, and internal polling, which keeps the process footprint larger than expected.
How to Drop n8n Memory Usage below 200–300 MB
Set the following Environment Variables in your Railway service settings:
Limit Node.js Maximum Heap Size:
Tell Node.js to trigger Garbage Collection earlier instead of holding onto memory.
Plaintext
NODE_OPTIONS=--max-old-space-size=256
Disable Main Process Executions:
By default, main n8n processes spawn heavy internal workers. Setting this forces lighter execution handling:
Plaintext
N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
Disable Unnecessary Features:
Turn off features that run idle background loops:
Plaintext
N8N_DIAGNOSTICS_ENABLED=false
N8N_METRICS=false
EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=168
Disable High-Concurrency Task Runners (if on n8n v1+):
Plaintext
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
N8N_BLOCK_ENV_ACCESS_IN_NODE=true
Key Summary for Railway
Railway charges based on container RSS memory, not just active JS heap. Applying --max-old-space-size=256 in NODE_OPTIONS forces Node's v8 engine to keep total RAM around 200 MB - 300 MB, dropping your daily billing costs significantly.
17 days ago
Heya. With 2–3 scheduled tasks a day you don't want an always-on service at all. Set the service to a Cron deployment, run the workflows on a schedule, let it stop. Cost drops to pennies — no memory tuning needed.
If you do want to keep it up 24/7, the real memory hog is likely the persistent volume. A SQLite mount gets mmap'd and buffered, so RSS climbs even when idle. Dropping the volume (or staying stateless as you already did) does more than any env var.
Then the usual suspects if you want to trim further: NODE_OPTIONS=--max-old-space-size=256 to force GC earlier, and EXECUTIONS_DATA_PRUNE=true with EXECUTIONS_DATA_MAX_AGE=168 so execution history doesn't creep up over weeks.
One warning on the earlier suggestion — N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS and N8N_BLOCK_ENV_ACCESS_IN_NODE are security flags, not memory settings, and N8N_DISABLE_PRODUCTION_MAIN_PROCESS will stop your scheduled triggers from firing at all. Leave those off.
andywithcamera
Heya. With 2–3 scheduled tasks a day you don't want an always-on service at all. Set the service to a Cron deployment, run the workflows on a schedule, let it stop. Cost drops to pennies — no memory tuning needed. If you do want to keep it up 24/7, the real memory hog is likely the persistent volume. A SQLite mount gets mmap'd and buffered, so RSS climbs even when idle. Dropping the volume (or staying stateless as you already did) does more than any env var. Then the usual suspects if you want to trim further: NODE_OPTIONS=--max-old-space-size=256 to force GC earlier, and EXECUTIONS_DATA_PRUNE=true with EXECUTIONS_DATA_MAX_AGE=168 so execution history doesn't creep up over weeks. One warning on the earlier suggestion — N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS and N8N_BLOCK_ENV_ACCESS_IN_NODE are security flags, not memory settings, and N8N_DISABLE_PRODUCTION_MAIN_PROCESS will stop your scheduled triggers from firing at all. Leave those off.
17 days ago
i set up cron deployment but was running for 1 hour without stopping, i though it should stop after 30 min idleness but it didn't. i didnt use n8n , browser tab was closed at that time.
tbmstbms857-wq
Why n8n Uses 800 MB RAM when Idle Node.js (the runtime n8n is built on) does not automatically release unused memory back to the operating system right away. It keeps allocated memory reserved (RSS memory) in case it needs it later. Additionally, n8n runs continuous background tasks, telemetry, and internal polling, which keeps the process footprint larger than expected. How to Drop n8n Memory Usage below 200–300 MB Set the following Environment Variables in your Railway service settings: Limit Node.js Maximum Heap Size: Tell Node.js to trigger Garbage Collection earlier instead of holding onto memory. Plaintext NODE_OPTIONS=--max-old-space-size=256 Disable Main Process Executions: By default, main n8n processes spawn heavy internal workers. Setting this forces lighter execution handling: Plaintext N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true Disable Unnecessary Features: Turn off features that run idle background loops: Plaintext N8N_DIAGNOSTICS_ENABLED=false N8N_METRICS=false EXECUTIONS_DATA_PRUNE=true EXECUTIONS_DATA_MAX_AGE=168 Disable High-Concurrency Task Runners (if on n8n v1+): Plaintext N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true N8N_BLOCK_ENV_ACCESS_IN_NODE=true Key Summary for Railway Railway charges based on container RSS memory, not just active JS heap. Applying --max-old-space-size=256 in NODE_OPTIONS forces Node's v8 engine to keep total RAM around 200 MB - 300 MB, dropping your daily billing costs significantly.
13 days ago
NODE_OPTIONS=--max-old-space-size=256 caused crash of service every time, so i removed that, instead i set 4gb ram.
Status changed to Open medim • 13 days ago
Status changed to Solved medim • 13 days ago
