Test your Load Balancer
This page explains how to test your Load Balancer after installation and configuration, to ensure it is running and routing tasks as expected.
Start the Load Balancer
Make sure your Load Balancer is running locally (default port: 4000
):
npm start
Or, if using Docker:
docker network create andera-net
docker-compose build
docker-compose up
Health Check
Test the health endpoint to verify the Load Balancer is up:
curl http://localhost:4000/health
Expected response:
{
"status": "ready"
}
tip
The /health
endpoint displays more useful information when authenticated with the LB_AUTH_KEY
:
curl -H "Authorization: <LB_AUTH_KEY>" http://localhost:4000/health
Submit a Task
Call the /task
endpoint to route a task to a connected Worker. You must specify the group
, contract
, and function
fields, and provide two headers:
Authorization: <LB_AUTH_KEY>
(your Load Balancer's LB_AUTH_KEY)x-wr-auth: <AUTH_KEY>
(the target Worker's AUTH_KEY)
curl -X POST http://localhost:4000/task \
-H "Content-Type: application/json" \
-H "Authorization: <LB_AUTH_KEY>" \
-H "x-wr-auth: <AUTH_KEY>" \
-d '{
"function": "hello",
"input": { "name": "Andera" },
"contract": 1,
"group": "default"
}'
Expected response:
{
"success": true,
"result": {
"message": "Hello Andera!"
}
}
Troubleshooting
Common Issues
- No workers available: Make sure at least one Worker is connected and healthy.
- 401 Unauthorized: Check your
LB_AUTH_KEY
and use the correct header. - Missing group/contract/function: All three fields are required for routing.
- Timeout: Check load balancer and worker logs for errors, as well as group name, contract version, etc.