Skip to content

fix#64

Merged
HoseokWon99 merged 1 commit into
prgrms-fullstack-devcourse:mainfrom
HoseokWon99:main
Aug 10, 2025
Merged

fix#64
HoseokWon99 merged 1 commit into
prgrms-fullstack-devcourse:mainfrom
HoseokWon99:main

Conversation

@HoseokWon99

Copy link
Copy Markdown
Contributor

pm2 cluster -> fork로 모드 변경

@HoseokWon99 HoseokWon99 requested a review from ksy90101 as a code owner August 10, 2025 05:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js to 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 with instances: 1, effectively switches the PM2 process management to fork mode.
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

  1. 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.

@HoseokWon99 HoseokWon99 merged commit 4796e78 into prgrms-fullstack-devcourse:main Aug 10, 2025
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ecosystem.config.js
watch: false,
instances: 3,
exec_mode: "cluster",
instances: 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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:
    // 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"
          }
        }
      ]
    };
    In your application code, you would then conditionally register the ScheduleModule based on the IS_WORKER environment 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.

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.

1 participant