The distributed logic for your 1 to 2^63 - 1 primality pipeline is fully implemented! Here is a summary of the executed work.
The worker node uses the efficient Miller-Rabin primality test which is incredibly fast for checking incredibly large integers like those near 2^63.
Unlike traditional request-response short-lived sockets, this server retains persistent, long-lived open sockets allowing the generator to continuously barrage it with test values without incurring thousands of TCP handshake costs. It can be spawned in as many terminal windows as you need to parallelize the load:
# Terminal 1
python3 prime_checker.py --port 8001
# Terminal 2
python3 prime_checker.py --port 8002
# Terminal 3 ... etc
python3 prime_checker.py --port 8003The Generator coordinates everything while respecting the sequence limit of CHECKER_ENDPOINTS.
It pipes sequential integers up to the maximum limit, sending a new problem out the second a worker responds back. The JSON response string is flushed directly to responses.log.
The Dockerfile provides a container to house the generator. To run the load balancer from Docker (pointing into your host terminal workers), use:
# Build
docker build -t prime-generator .
# Run on MacOS
mkdir -p logs
docker run --rm \
-v $(pwd)/logs:/app/logs \
-e LOG_FILE=/app/logs/responses.log \
-e CHECKER_ENDPOINTS="host.docker.internal:8001,host.docker.internal:8002" \
prime-generator