fix#64
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @HoseokWon99, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've updated the PM2 configuration for the comeet application. The primary goal of this change is to switch the process management mode from cluster to fork, ensuring the application runs as a single instance rather than multiple clustered instances.
Highlights
- PM2 Configuration Update: Modified
ecosystem.config.jsto change the application's PM2 execution mode. - Instance Count Reduction: Reduced the number of application instances from 3 to 1.
- Execution Mode Change: Removed the explicit
exec_mode: "cluster"setting, which, combined withinstances: 1, effectively switches the PM2 process management toforkmode.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request changes the PM2 configuration to run the application in fork mode with a single instance, instead of cluster mode with three instances. While this might fix issues related to multi-process execution (like duplicated scheduled tasks), it severely impacts the application's scalability and availability by not leveraging multiple CPU cores and removing redundancy. My review includes a detailed comment explaining these risks and suggests alternative approaches, such as using a dedicated worker instance for scheduled tasks, to handle such issues in a clustered environment without sacrificing performance.
| watch: false, | ||
| instances: 3, | ||
| exec_mode: "cluster", | ||
| instances: 1, |
There was a problem hiding this comment.
Switching from cluster mode with 3 instances to fork mode with a single instance will significantly impact the application's performance and scalability, as it will no longer be able to utilize multiple CPU cores for handling requests. This also reduces availability as there is no longer any redundancy.
If this change is intended to resolve issues with scheduled tasks (@nestjs/schedule) running on multiple instances, which is a common problem with cluster mode, please consider alternative solutions that don't sacrifice scalability:
- Use a distributed lock: Implement a locking mechanism (e.g., using Redis or a database) to ensure that a scheduled task is executed by only one instance at a time.
- Designate a worker instance: You could have a separate PM2 app definition for a single worker instance that is responsible for running scheduled tasks, while the main app continues to run in cluster mode for handling API requests. For example:
In your application code, you would then conditionally register the
// ecosystem.config.js module.exports = { apps: [ { name: "comeet-api", script: "dist/main.js", instances: -1, // Use all available CPUs exec_mode: "cluster", env: { IS_WORKER: "false" } }, { name: "comeet-worker", script: "dist/main.js", instances: 1, exec_mode: "fork", // Explicitly fork mode for worker env: { IS_WORKER: "true" } } ] };
ScheduleModulebased on theIS_WORKERenvironment variable.
If this change is made for other reasons, it's highly recommended to add a comment to the configuration file explaining the rationale for running in single-instance fork mode to aid future maintenance.
pm2 cluster -> fork로 모드 변경