Skip to content

feat: Horizontal Scaling Readiness (PM2)#142

Merged
Sadeequ merged 1 commit intoStellarFlow-Network:mainfrom
Adeyemi-cmd:horizontal_scaling_readiness
Mar 29, 2026
Merged

feat: Horizontal Scaling Readiness (PM2)#142
Sadeequ merged 1 commit intoStellarFlow-Network:mainfrom
Adeyemi-cmd:horizontal_scaling_readiness

Conversation

@Adeyemi-cmd
Copy link
Copy Markdown
Contributor

Close #116

PR Description

Summary

Add PM2 horizontal scaling readiness by introducing an ecosystem.config.js configuration file for clustered Node.js process management.

Changed file

  • ecosystem.config.js

What it does

  • Configures PM2 to run the app in cluster mode
  • Uses instances: "max" to spawn one worker per CPU core
  • Enables autorestart: true so crashed instances are automatically restarted
  • Sets max_restarts: 10 and restart_delay: 5000 for controlled recovery
  • Writes logs to server.out.log and server.err.log
  • Disables watch mode and ignores common directories for stability

Why this is needed

  • Allows the backend to leverage multiple CPU cores
  • Improves availability by restarting crashed worker processes
  • Provides a production-ready PM2 setup for scaled deployment

Testing

  1. Run npm install if dependencies are missing
  2. Build the app:
    • npm run build
  3. Start PM2:
    • pm2 start ecosystem.config.js --env production
  4. Verify cluster mode:
    • pm2 list
  5. Check logs and automatic recovery:
    • pm2 logs stellarflow-backend

Notes

  • PM2 expects the built output at index.js
  • Ensure the project is built before starting with PM2
  • A convenience script like pm2:start can be added separately if needed

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@Adeyemi-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Sadeequ Sadeequ merged commit c4d9acc into StellarFlow-Network:main Mar 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BACKEND] Horizontal Scaling Readiness (PM2)

2 participants