-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Messenger] Added section about "Consuming Messages in Docker" #15340
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
base: 4.4
Are you sure you want to change the base?
Conversation
The approach I use is to run container for each queue.
|
You have to re-build a container for each queue on each deployment. Having a parameterized entrypoint in the same image makes much more sense. You only want to build one image for all environments per release (following twelve-factor-app concept). |
Yes, you build one image for all environments - one image for messenger and one for app.
|
Image to container is like class to instance. As long as the consumer is no seperate application but baked into your symfony website application, there should be no separate image, only another runtime configuration (entrypoint, env vars, etc). @Warxcell the articel you've linked, explicitly describes multi-service containers, running multiple prozesses in parallel. That's exactly, what I try to avoid with this tipps. |
In Symfony Slack there was a very active thread about this Pull Request. See https://symfony-devs.slack.com/archives/C8WHX21K7/p1621414331044800 Hopefully we can agree on some changes and propose them here? Thanks! |
To pick this up from the Symfony Slack:
If the inherited entrypoint of the base image doesn't support arguments, changing the command does nothing but handing over "wrong" parameters to a binary/script. ENTRYPOINT is the font-facing binary. Source: https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact Mostly ENTRYPOINT is a shell like As we cannot be sure whether the base image each and everyone uses supports entrypoint overwrite with simple CMD change, I'd like to promote having a separate (and very specific) entrypoint for this purpose. It also follows single responsibility principle, by providing a separate and specific bootstrapping for the consumer process.
If you build a separate consumer application, feel free to use whatever (single) entrypoint you like. |
Basically, as you wrote - there is completely no need of using custom entrypoint for commands using standard approach, so I see no point for writing docs that says something different. KISS. Instead of this two paragraphs you can simply cover base usecase with CMD overwrite. Same with limits tbh. It is something completely user-specific and there is no point in requiring from someone to restart their workers every N messages/every M minutes because it is only waste of resources. Only soft memory limit should be mentioned as obligatory in production environment, because not having it properly set up will result in app crash. But having it same as php native |
Fair enough. Maybe I'm going to add a hint about ENTRYPOINT vs CMD.
I don't understand why restarting is a waste of resources (it frees them), but anyways. The existing part about Deploying to Production tells axaclty that: "Don’t Let Workers Run Forever", so I've picked it up for Docker usage, as well. And as seamless restarting should be in the lifecycle of every containerized application, I shouldn't bother.
But having a too low |
New insights from my side: if your use single image with FPM and Messenger, you cannot gracefully restart messenger, since FPM image overrides Filled also a issue for it, in case symfony decides to handle that case aswell. |
That's exactly what I do. I have SINGLE image, and I run MULTIPLE containers from it. Did I ever said that I'm running 2 processes within single container? Did you even read what I wrote? I will quote myself
which basically mean "run another container from same image, but different command which is |
Symfony 4.4 is not supported anymore, you may want to rebase on top of 5.4 branch, otherwise please close the PR. Thank you |
Like announced on the syfomy-devs slack, some hints and tipps about running messenger:consume in a container environment.
My fork was heavy out of sync, so I needed three approaches for this PR 😉