# Rally: customize behaviour of each client

**URL:** <https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [August 11, 2022, 11:40am UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919 "2022-08-11T11:40:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [August 11, 2022, 11:40am UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/1 "2022-08-11T11:40:04Z")

</div>

Hi!

I have my track like this (snippet from challenges/operations)

```auto
        {
            "operation": "replay-listing-query",
            "clients": 4,
            "warmup-iterations": 10,
            "iterations": 1000,
            "target-throughput": 100
        }

{
  "name": "replay-listing-query",
  "operation-type": "search",
  "detailed-results": true,
  "param-source": "replay-listing-query-source"
}

```

I can see in my py code in track.py that 4 python (threads or processes) are created. I would like to customize the behaviour of each, something like (pseudo code)

```auto
if client==1 then X
if client==2 then Y

```

Is there something I can use in my py class to identify each client? I cannot find anything by looking around.  
thanks!

---

<div class="post-metadata">

**Author:** ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)\
**Post date:** [August 11, 2022, 12:38pm UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/2 "2022-08-11T12:38:43Z")

</div>

Hi! Can you please explain your use case in more detail? How would that help you?

---

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [August 11, 2022, 12:58pm UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/3 "2022-08-11T12:58:06Z")

</div>

I am replying some queries I load from a file. I would like each client to run just an Nth of the queries, so for instance each client 1 would run queries 1, 5, 9, client 2 would run 2, 6, 10...

Does this makes sense?

---

<div class="post-metadata">

**Author:** ![RickBoyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rickboyd/32/80022_2.png) [@RickBoyd](https://discuss.elastic.co/u/RickBoyd)\
**Post date:** [August 11, 2022, 3:29pm UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/4 "2022-08-11T15:29:04Z")

</div>

Hi @jmlucjav,

I am assuming your param source is a function. If you expand it to be a class, [per the docs](https://esrally.readthedocs.io/en/stable/adding_tracks.html#custom-parameter-sources), you can use the `partition` function for this purpose.

> partition(self, partition\_index, total\_partitions) is called by Rally to "assign" the parameter source across multiple clients. Typically you can just return self. If each client needs to act differently then you can provide different parameter source instances here as well.

---

<div class="post-metadata">

**Author:** ![jmlucjav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmlucjav/32/5870_2.png) [@jmlucjav](https://discuss.elastic.co/u/jmlucjav)\
**Post date:** [August 11, 2022, 6:41pm UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/5 "2022-08-11T18:41:23Z")

</div>

Thank you very much @RickBoyd , that works!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 8, 2022, 6:42pm UTC](https://discuss.elastic.co/t/rally-customize-behaviour-of-each-client/311919/6 "2022-09-08T18:42:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
