Jenkins: two agents vs. one agents with two executors
Asked Answered
G

3

12

Is there any difference between I create two agents, or one agent with two executors on the same Windows server?

Gilcrest answered 20/5, 2016 at 20:57 Comment(0)
A
11

Yes, there is a difference: It's about memory consumption and effort of maintenance/administration.

  • Starting a slave on a system starts a (main) process. This process costs (private) main memory to run and connects to the master.
  • Each executor is a sub-process of the main process.

It is therefore apparent that running two executors on one slave costs less memory in total compared to running two slaves (with one executor each), as there would be the memory consumption of the main process twice:

2 * Main Processes + 2 * Executors > 1 * Main Process + 2 * Executors

Moreover, administrating a slave is some more effort than just an executor: Whilst an executor has virtually nothing to worry, there are numerous things to configure for a slave. Additionally, the capabilities of the two slaves are anyhow the same (they are running on the same OS as you said), so there is little value-add to also assign it different labels.

In short, if there are no other boundary conditions, which make me do it differently, I always would prefer running two executors on one slave, as this is easier to administrate and some memory is saved.

Amenra answered 20/5, 2016 at 21:27 Comment(4)
Although in general I agree with your answer (+1) - every scenario should be treated differently. working with docker slaves is effortless and takes almost no administration. working with several slaves might be better running UI testing that can't run in parallel on the same machine. there are many scenarios that it makes more sense to have 2 slaves than one, and it's important to keep in mind that there are no global best practices for it, but depends on the flows that actually running on that intended environment.Loewi
That's why I said "if there are no other boundary conditions," :-) And, believe it or not, I had the "UI testing, which can't run on the same maschine in parallel" scenario on my mind, when writing it (I have exactly this issue here, which drives me crazy, as for each executor, I need an own vserver slave, because I can't dockerize the matter)Amenra
Keep in mind, you dont neccessarily need to control per-node concurrency with executor count. Also, there exist job layouts that need more than one executor.Sacrilege
In our case, it was on the same slave server with no difference, so I think it's better to use two executors then two slaves. At least can save disk space for the workspace.Gilcrest
P
5

A slave is a "machine". An executor is an "OS Process" in the slave.

So ideally we always add executors - they do the work and can run in parallel, and the simple theoretic answer to your question is "2 executors on one slave"

In practice we need to add slaves in several use cases:

  1. We need more resources (more cpu, more memory, more "machines")
  2. We need a different setting (Different OSes, Different hardware)
  3. We have global resources that would create a conflict for executors on same machine (shared browser for a UI testing process)

Make the decision based on your use case.

Personate answered 8/12, 2018 at 7:40 Comment(0)
O
0

One benefit which immediately comes to my mind for running 1 executor on given node, is to prevent conflicts between processes run at the same time.

On other hand you could prevent job conflicts using existing Jenkins plugins, ie. Heavy Job, Build Blocker.

Olfactory answered 22/5, 2016 at 8:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.