Best practices for consumers in production #629
Replies: 4 comments
-
As you said, we at eMAG are running consumers using supervisord.
Depending on your application, if have both workers and www part, or maybe have multiple workers that impacts the same area of the application, I will advise you to restart your workers immediately after deploy. Otherwise you risk data corruption, or another unwanted behaviour, because some of the workers run the new version and other the old version. Going on that path, imagine that you set some fixed value for number of messages after the workers should restart. You may end up in a situation in which some of the workers are restarted very soon(because they receive a lot of messages) and others will restart really late, because the amount of messages is really small. |
Beta Was this translation helpful? Give feedback.
-
Thank you @beniamin. How many supervisord processes are you running if I might ask?
Good point, this is an interesting puzzle. |
Beta Was this translation helpful? Give feedback.
-
@rikvanderkemp supervisord is widely used in eMAG environment. In my applications, we have an average of 90-100 php processes "supervised" by supervisord. |
Beta Was this translation helpful? Give feedback.
-
@rikvanderkemp I'll add some extra tips, maybe it will help you
We are using all of the above, it depends where you will host your code and what you want to obtain:
you should have consumer based on what queues are you creating and what you want to accomplish.
Depending on what orchestration you choose you can obtain a stable processing rate and if is acceptable you can got with it. If you choose a managed system you can scale in/out base on different parameters in order to cut cost/improve performance. lmk if it was helpful or not |
Beta Was this translation helpful? Give feedback.
-
So I have successfully set up RabbitMQ (in Docker) and have sent messages to RabbitMq and successfully consumed test messages. All in a safe development environment.
What I'm missing in the documentation are some pointers when moving to production.
My idea is to run consumers using supervisord, currently using this for the messenger from Symfony. The disadvantage is, however, code changes mean restarting the consumer(s).
So when I see the following in the documentation:
It got me thinking, is this the preferred way of setting it up in production? Firing up consumers for limited amounts of messages and then starting new ones when needed? Not sure how that would work.
Or, just multiple consumers for multiple exchanges?
A single consumer handles incoming messages sequentially. So how would you deal with large bulks? An idea would be firing up multiple consumers for a single exchange channel. But again, is this the "right" way?
So I'd like to hear some pointers from people who are using this in production. I'd like to use this in a setup where we could potentially have big bulks of messages that need to be consumed.
Beta Was this translation helpful? Give feedback.
All reactions