# What's the relationship between clients and CPU cores?

**URL:** <https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [October 8, 2023, 6:30am UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588 "2023-10-08T06:30:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhineshkumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhineshkumar_r/32/122038_2.png) [@Dhineshkumar\_R](https://discuss.elastic.co/u/Dhineshkumar_R)\
**Post date:** [October 8, 2023, 6:30am UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588/1 "2023-10-08T06:30:28Z")

</div>

Hi Folks,

I found that rally uses Actor model to generate load under the hood. From the documentation, I understand that target throughput is achieved with all clients together. However, I do not understand the way number of clients set in a race and CPU cores are related. Can someone help me understand how these two are related? Basically the way number of clients set in a rally schedule are mapped to Actors and inturn to CPU threads to generate target-throughput.

If there are any documentation that's already there regarding these, please point me to it.

Thanks

---

<div class="post-metadata">

**Author:** ![Bradley\_Deam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradley_deam/32/52991_2.png) [@Bradley\_Deam](https://discuss.elastic.co/u/Bradley_Deam)\
**Post date:** [October 8, 2023, 11:19pm UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588/2 "2023-10-08T23:19:38Z")

</div>

Hi @Dhineshkumar_R,

These are largely implementation details, and as a user of Rally you shouldn't _really_ need to be aware of them, but let me try and explain.

Rally is written in Python, which has a mechanism called [the GlobalInterpreterLock](https://wiki.python.org/moin/GlobalInterpreterLock) to prevent multiple threads of the same Python process from running on CPU in parallel.

This 'GIL' limits the total throughput we could achieve using a single Python process, so to work around this we use a model of allocating one 'Actor' per-available core, where an Actor is separate Python process responsible for [running a single asyncio event loop](https://esrally.readthedocs.io/en/latest/configuration.html?highlight=core.#system).

Then, the number of clients [defined in a specific task's `client` property](https://esrally.readthedocs.io/en/latest/track.html?highlight=schedule#schedule) are evenly distributed across the available 'Actors' (i.e. Python processes/asyncio event loops).

Brad

---

<div class="post-metadata">

**Author:** ![Dhineshkumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhineshkumar_r/32/122038_2.png) [@Dhineshkumar\_R](https://discuss.elastic.co/u/Dhineshkumar_R)\
**Post date:** [October 9, 2023, 5:30pm UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588/3 "2023-10-09T17:30:55Z")

</div>

Thanks Brad. This helps me imagine the flow. One followup question. I read that the latency metrics reported in the summary report includes the time spent by a request waiting in a queue after creation but before sent to the cluster. Where is this queue in the picture? Is this queue part of each client within an Actor or the Actor itself?

---

<div class="post-metadata">

**Author:** ![Bradley\_Deam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradley_deam/32/52991_2.png) [@Bradley\_Deam](https://discuss.elastic.co/u/Bradley_Deam)\
**Post date:** [October 9, 2023, 11:02pm UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588/4 "2023-10-09T23:02:15Z")

</div>

This really is an implementation detail, but right now it is per client within an Actor.

If you're interested in understanding this in more detail, take a look at these files for a start:

- [The `AsyncExecutor` is responsible for actually executing the task and measuring service times/processing time/latency](https://github.com/elastic/rally/blob/b18e0b48d2fb33f620f60cad896360cf59a425cc/esrally/driver/driver.py#L1887-L1998)
- [Schedulers which are responsible for defining when Rally should execute a request](https://github.com/elastic/rally/blob/master/esrally/driver/scheduler.py)

---

<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:** [November 6, 2023, 11:02pm UTC](https://discuss.elastic.co/t/whats-the-relationship-between-clients-and-cpu-cores/344588/5 "2023-11-06T23:02:46Z")

</div>

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