title: Why redis stream consumers should specify an individual name in the same consumer group?
body: <p>The codes below show how I test the Redis stream functions.</p>
  <p>And I found that different processes with the same consumer name are competing to consume messages in the same stream. In my understanding, if this performance is normal, Redis should not design a function to specify the consumer name.</p>
  <p>Is there any problem with my understanding? Or am I using the wrong method?</p>
  <pre><code>import asyncio
  import aioredis
  
  # consumer with name &quot;a&quot;, subscribing two streams
  async def consume_a():
      try:
          while True:
              redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
              res = await redis.xreadgroup(
                  &quot;test_consumer_group&quot;,
                  &quot;consumer_a&quot;,
                  streams={&quot;test_stream&quot;: &quot;&gt;&quot;, &quot;test_stream_1&quot;: &quot;&gt;&quot;},
                  count=1,
                  block=10000,
                  noack=True,
              )
              print(res)
      finally:
          await redis.close()
  </code></pre>
  <p>consumer with name &quot;b&quot;, subscribing two streams</p>
  <pre><code>async def consume_b():
      try:
          while True:
              redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
              res = await redis.xreadgroup(
                  &quot;test_consumer_group&quot;,
                  &quot;consumer_b&quot;,
                  streams={&quot;test_stream&quot;: &quot;&gt;&quot;, &quot;test_stream_1&quot;: &quot;&gt;&quot;},
                  count=1,
                  block=10000,
                  noack=True,
              )
              print(res)
      finally:
          await redis.close()
  </code></pre>
  <p>create group before runing script</p>
  <pre><code>async def config_group_0():
      try:
          redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
          res = await redis.xgroup_create(&quot;test_stream&quot;, &quot;test_consumer_group&quot;)
          print(res)
      finally:
          await redis.close()
  
  async def config_group_1():
      try:
          redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
          res = await redis.xgroup_create(&quot;test_stream_1&quot;, &quot;test_consumer_group&quot;)
          print(res)
      finally:
          await redis.close()
  </code></pre>
  <p>producers</p>
  <pre><code>async def produce_0():
      try:
          redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
          i = 0
          while i &lt; 100:
              res = await redis.xadd(
                  &quot;test_stream&quot;,
                  {&quot;domain_name&quot;: &quot;test_domain_name_0&quot;, &quot;sid&quot;: 0},
                  maxlen=5,
              )
              print(res)
              i += 1
      finally:
          await redis.close()
  
  async def produce_1():
      try:
          redis = aioredis.from_url(&quot;redis://localhost:36379&quot;)
          i = 0
          while i &lt; 100:
              res = await redis.xadd(
                  &quot;test_stream_1&quot;,
                  {&quot;domain_name&quot;: &quot;test_domain_name_1&quot;, &quot;sid&quot;: 1},
                  maxlen=2,
              )
              print(res)
              i += 1
      finally:
          await redis.close()
  </code></pre>
  <p>test code</p>
  <pre><code>if __name__ == &quot;__main__&quot;:
      # two coroutines consume messages from two streams with the same consumer name
      asyncio.run(asyncio.gather(consume_a(), consume_a(), produce_0(), produce_1()))
  </code></pre>