Skip to content

Commit 525dfdc

Browse files
committed
Clarified HOSTNAME environment variable
1 parent ffe9dff commit 525dfdc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

messenger.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,10 +904,10 @@ serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`
904904

905905
At some point you'll likely want to scale the number of workers working on your queue.
906906
Make sure you assign the correct ``consumer`` and ``group`` values in that case.
907-
The more likely case is that each worker shall work on the queue independently, reducing
907+
The more likely case is that you want every worker to work on the queue independently, reducing
908908
the time needed to process the pending messages. In that case, every single worker
909-
must have a different ``consumer`` configuration value. When working with Docker
910-
containers one idea might be to use the ``HOSTNAME`` environment variable:
909+
must have a different ``consumer`` option value so Redis can identify the different workers.
910+
When working with Docker containers one idea might be to use the ``HOSTNAME`` environment variable:
911911

912912
.. configuration-block::
913913

@@ -923,6 +923,16 @@ serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`
923923
That means messages would be processed multiple times. In that case, you must have different ``group``
924924
configurations.
925925

926+
.. caution::
927+
928+
Be careful when using the ``HOSTNAME`` environment variable in orchestrated environments such as Kubernetes or
929+
Docker Swarm. It usually contains a random unique identifier which means if you destroy a container while it was
930+
working on a message, this message will remain in pending state forever as it is very unlikely there's ever going
931+
to be another worker with exactly the same ``HOSTNAME`` as the one you destroyed. In other words, you have to
932+
make sure you're using deterministic ``HOSTNAME`` values such as ``worker-1``, ``worker-2`` etc.
933+
In case you are using Kubernetes to orchestrate your containers, consider using a ``StatefulSet`` rather than
934+
a ``Deployment`` for example.
935+
926936
In Memory Transport
927937
~~~~~~~~~~~~~~~~~~~
928938

0 commit comments

Comments
 (0)