Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Actions - parallel self-hosted runners on the same machine

Question related to the topic of Parallelism in Self-Hosted Runners:

One self-hosted runner can only run one job at a time, when no available runners are idle, the subsequent jobs will be in queueing until have available runners are idle.

Can I possibly achieve parallelism by running multiple self-hosted runners on the same machine with multiple CPUs?

In the GitHub Actions - Getting Started - Usage Limits I found:

The number of concurrent jobs you can run in your account depends on your GitHub plan, as indicated in the following table. If exceeded, any additional jobs are queued. There are no concurrency limits for self-hosted runners.

But I'm not sure how to understand this in the context of multi-core machines.

like image 256
Tomasz Bartkowiak Avatar asked Apr 09 '20 15:04

Tomasz Bartkowiak


1 Answers

One runner can only run one job at the time. That is independent of how many cores that machine has.

However, you can install and run multiple runners on the same machine.

When you go through the setup wizard, you will be asked for a directory. If you used /home/github/action-runner for the first one, maybe use /home/github/action-runner-2 for the second directory. They will have completely different workspaces.

Give the additional runner a unique name.

If you are managing the services with systemd, a final step is to create a second systemd unit file for the additional run, with a unique service name and a WorkingDirectory= directory that matches the one you used above:

# for example, this might be /etc/systemd/system/ actions.runner.MyCorp.ci-2.service
[Unit]
Description=GitHub Actions Runner (RideAmigosCorp.ci-2)
After=network.target

[Service]
ExecStart=/home/github/action-runner/runsvc.sh
User=github
# The working directory here must match the one during setup
WorkingDirectory=/home/github/action-runner-2
KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=5min

[Install]
WantedBy=multi-user.target
like image 68
Peter Fortuin Avatar answered Oct 01 '22 23:10

Peter Fortuin