Skip to content

Documentation about Implement Supervisor for Multi-Process Execution in Docker #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ErdemAkin
Copy link

This pull request introduces Supervisor to our Docker setup, enabling the execution of multiple processes within a single container. The implementation was initially motivated by a personal project requirement but has broader applications, particularly in solving common issues with Symfony Messenger.

Documentation includes these:

  1. Added Supervisor configuration to manage multiple processes efficiently.
  2. Improved container stability and resource utilization.
  3. Simplified process management, especially beneficial for Symfony Messenger consumers.
  4. Enhanced scalability for applications requiring concurrent process execution.

This addition not only resolves our immediate needs but also provides a robust solution for similar scenarios in other projects. It's particularly valuable for Symfony-based applications utilizing message queues.

I welcome your review and feedback on this implementation. Please let me know if you need any clarifications or have suggestions for improvement.

@7-zete-7
Copy link
Contributor

Hello @ErdemAkin!

Is it a good idea to implement Supervisor in Docker?

Docker itself implements all the functionality provided by Supervisor.

@7-zete-7
Copy link
Contributor

Symfony Messenger's consumer can be easily configured in Docker without Supervisor. However, Docker will have much more control over the processes.

services:
  ...
  consumer:
    extends: php
    restart: unless-stopped
    deploy:
      replicas: 2
    healthcheck:
      disable: true
      #command: /usr/bin/true # if "disable: true" isn't works

    # if you need to disable the entry point provided by this repository
    #entrypoint: ""

    # https://symfony.com/doc/current/messenger.html#deploying-to-production
    command: bin/console messenger:consume --limit=... --time-limit=... async ...

Some discussion abount this theme in #539.

@ErdemAkin
Copy link
Author

Hey @7-zete-7 ! Thanks for the great question. You're right to be curious about using Supervisor in Docker.

This pull request isn't necessarily saying we should use Supervisor in our project, but more of a helpful guide for situations where it might be useful. Sometimes, running multiple processes in a single Docker container makes sense for specific use cases. Supervisor really helped there, so I thought it could be a valuable resource for others who might face a similar scenario.

Of course, Docker's philosophy leans towards one process per container, which simplifies scalability and maintenance. But if anyone on the team ever finds themselves needing to run multiple processes, this PR can serve as a practical solution. Even if it's not a perfect fit for our project right now, it's all about having options in our toolbox for the future!

@ErdemAkin
Copy link
Author

After discussing my friends, I decided to close this pr. I will create documentation for Kubernetes.

@ErdemAkin ErdemAkin closed this Oct 18, 2024
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.

2 participants