Do jobs in self-hosted runners run in parallel? #26769
-
The document says "Jobs run in parallel by default. ". When I tried workflow in github-hosted runners, jobs do run in parallel. However, when I try to run the workflow in self-hosted runners, the jobs do not seem to run in parallel. I’ve tried in both macos and centos with the latest version runner v2.165.2. Is it that jobs only run in parallel in github-hosted runners? My work flow is as follows:
And the runner output in CentOS is as follows:
|
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 9 replies
-
Hi @dahuokolmostar , Jobs should run in parallel for both hosted runner and self-hosted runner. But for self-hosted runner, there are some comments:
Thanks. |
Beta Was this translation helpful? Give feedback.
-
Are there any plans to change this? That is so that a runner can run multiple jobs at the same time (concurrently). It would be really nice, since a lot of the time the jobs are small and don’t require the full machine to run and could run multiple jobs at the same time. Plus most of the time the jobs are spun up in containers so just having fewer runner machines with multiple cpus to spin those up vs having multiple smaller machines or having to run multiple instances of the actions runner service per machine to achieve this… For more cpu/resource intensive jobs you could select a runner via labels so that it would go onto a machine that is dedicated to that job? |
Beta Was this translation helpful? Give feedback.
-
Fact is that currently, the GitLab runner is much better than the Github actions runnner. Hopefully this will change. |
Beta Was this translation helpful? Give feedback.
-
@allir i agree with you man!!! |
Beta Was this translation helpful? Give feedback.
-
We can run Runner in docker and then we can run multiple runners on same server!!! |
Beta Was this translation helpful? Give feedback.
-
Thanks @weide-zhou for the details. I think it makes a lot of sense to add these comments into the official documentation. |
Beta Was this translation helpful? Give feedback.
-
if you want to have multiple runners on the same machine you can run them under different users:
|
Beta Was this translation helpful? Give feedback.
-
This doc should include this information. |
Beta Was this translation helpful? Give feedback.
-
should be possible to install the runner multiple times on the same machine with different users, no? |
Beta Was this translation helpful? Give feedback.
-
I've installed multiple runners in different folders, but this is quite frustrating to maintain between all the systemctl service definitions and special configs and permissions for each. I would love to see a single runner instance be able to run multiple jobs concurrently. |
Beta Was this translation helpful? Give feedback.
-
here is a script to automate adding runners on a single server #!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <runner-number> <github-token>"
exit 1
fi
RUNNER_NUMBER=$1
TOKEN=$2
RUNNER_DIR="/home/$USER/actions-runner-${RUNNER_NUMBER}"
SERVICE_FILE="/tmp/github-actions-${RUNNER_NUMBER}.service"
# Remove existing directory if exists
rm -rf "$RUNNER_DIR"
# Create fresh runner directory
mkdir -p "$RUNNER_DIR"
cd "$RUNNER_DIR" || exit
# Download and extract runner
curl -o actions-runner-linux-x64-2.321.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.321.0/actions-runner-linux-x64-2.321.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.321.0.tar.gz
# Configure runner
./config.sh --url https://github.com/tesote/treasury \
--token "$TOKEN" \
--name "runner-${RUNNER_NUMBER}" \
--unattended \
--replace
# Create service file in temp location
cat > "$SERVICE_FILE" << EOL
[Unit]
Description=GitHub Actions Runner ${RUNNER_NUMBER}
After=network.target
[Service]
Type=simple
User=${USER}
Group=${USER}
WorkingDirectory=${RUNNER_DIR}
ExecStart=${RUNNER_DIR}/run.sh
Restart=always
RestartSec=10
KillSignal=SIGTERM
[Install]
WantedBy=multi-user.target
EOL
# Move service file and configure systemd (these need sudo)
sudo mv "$SERVICE_FILE" "/etc/systemd/system/"
sudo systemctl daemon-reload
sudo systemctl enable "github-actions-${RUNNER_NUMBER}"
sudo systemctl start "github-actions-${RUNNER_NUMBER}"
echo "Runner ${RUNNER_NUMBER} has been created and started" run the script as ./add-runner 1 TOKEN_1
./add-runner 2 TOKEN_2
./add-runner 3 TOKEN_3 |
Beta Was this translation helpful? Give feedback.
Hi @dahuokolmostar ,
Jobs should run in parallel for both hosted runner and self-hosted runner.
But for self-hosted runner, there are some comments:
Thanks.