Skip to content

Commit 330c6f7

Browse files
committed
add configurable replicas
1 parent 5829f48 commit 330c6f7

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

edge/wasm-sensors/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ This scenario demonstrates the message flow and deployment behavior across diffe
201201
1. Start the network:
202202

203203
```bash
204+
export REPLICAS=3 # Set number of replicas per region
204205
./demo.sh start_network
205206
```
206207

@@ -386,3 +387,31 @@ This should return:
386387

387388
- **Configuration Updates**: Configuration is set at job startup and cannot be changed during execution. To change configuration, you need to stop and redeploy the job.
388389
- **Direct File Access**: WASM modules have limited filesystem access through Bacalhau.
390+
391+
### Environment Variables
392+
393+
The demo script uses the following environment variables:
394+
395+
- `PROXY_URL`: URL of the SQS proxy service (default: `http://bacalhau-edge-sqs-proxy-1:9090`)
396+
- `REPLICAS`: Number of edge nodes and job instances per region (default: `3`)
397+
398+
This single `REPLICAS` variable controls both:
399+
400+
- The number of edge nodes per region in the Docker Compose setup
401+
- The number of job instances deployed per region
402+
403+
You can set these variables before running the demo script:
404+
405+
```bash
406+
export PROXY_URL="http://custom-proxy:9090"
407+
export REPLICAS=5
408+
./demo.sh deploy_us
409+
```
410+
411+
Or set them inline with the command:
412+
413+
```bash
414+
PROXY_URL="http://custom-proxy:9090" REPLICAS=5 ./demo.sh deploy_us
415+
```
416+
417+
Note: When using multiple replicas per region, make sure your system has enough resources to handle the increased load. Each replica will have its own resource limits as defined in the Docker Compose file.

edge/wasm-sensors/demo.sh

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ NC='\033[0m' # No Color
1212

1313
# Default configuration
1414
PROXY_URL=${PROXY_URL:-"http://bacalhau-edge-sqs-proxy-1:9090"}
15+
REPLICAS=${REPLICAS:-3}
1516

1617
# Helper functions
1718
print_step() {
@@ -54,6 +55,7 @@ print_usage() {
5455
echo
5556
echo "Environment variables:"
5657
echo " PROXY_URL SQS proxy URL (default: http://bacalhau-edge-sqs-proxy-1:9090)"
58+
echo " REPLICAS Number of instances to deploy (default: 3)"
5759
echo
5860
echo "Examples:"
5961
echo " $0 start_network"
@@ -62,6 +64,7 @@ print_usage() {
6264
echo " $0 deploy_interactive"
6365
echo " $0 --interactive"
6466
echo " PROXY_URL=http://custom-proxy:9090 $0 deploy_us"
67+
echo " REPLICAS=50 $0 deploy_us"
6568
}
6669

6770
# Get running job IDs for a specific region
@@ -111,6 +114,7 @@ deploy() {
111114
-V interval="$interval" \
112115
-V region="$region" \
113116
-V submission_time="$submission_time" \
117+
-V count=$REPLICAS \
114118
jobs/sqs-publisher.yaml)
115119

116120
print_success "$region region deployed"

edge/wasm-sensors/jobs/sqs-proxy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ tasks:
2020
type: host
2121
ports:
2222
- name: http
23-
static: 8080
23+
static: 8080

edge/wasm-sensors/jobs/sqs-publisher.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: sqs-publisher-{{.region}}
22
type: batch
3+
count: {{.count}}
34
constraints:
45
- key: type
56
operator: "="
@@ -38,6 +39,6 @@ tasks:
3839
target: /app/
3940
resources:
4041
cpu: "0.001"
41-
memory: "4mb"
42+
memory: "36mb"
4243
timeouts:
4344
queueTimeout: 300

edge/wasm-sensors/network/docker-compose.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ services:
5656
orchestrator:
5757
condition: service_healthy
5858
deploy:
59-
replicas: 1
59+
replicas: ${REPLICAS:-3}
6060
resources:
6161
limits:
6262
cpus: "0.1" # 10% of a CPU core (enough for 20 jobs at 0.001 each)
63-
memory: "200M" # 200MB (enough for 20 jobs at 4MB each, plus overhead)
63+
memory: "400M" # 400MB (enough for 10 jobs at 36MB each, plus overhead)
6464
networks:
6565
- bacalhau-network
6666

@@ -78,11 +78,11 @@ services:
7878
orchestrator:
7979
condition: service_healthy
8080
deploy:
81-
replicas: 1
81+
replicas: ${REPLICAS:-3}
8282
resources:
8383
limits:
8484
cpus: "0.1" # 10% of a CPU core (enough for 20 jobs at 0.001 each)
85-
memory: "200M" # 200MB (enough for 20 jobs at 4MB each, plus overhead)
85+
memory: "400M" # 400MB (enough for 10 jobs at 36MB each, plus overhead)
8686
networks:
8787
- bacalhau-network
8888

@@ -100,11 +100,11 @@ services:
100100
orchestrator:
101101
condition: service_healthy
102102
deploy:
103-
replicas: 1
103+
replicas: ${REPLICAS:-3}
104104
resources:
105105
limits:
106106
cpus: "0.1" # 10% of a CPU core (enough for 20 jobs at 0.001 each)
107-
memory: "200M" # 200MB (enough for 20 jobs at 4MB each, plus overhead)
107+
memory: "400M" # 400MB (enough for 10 jobs at 36MB each, plus overhead)
108108
networks:
109109
- bacalhau-network
110110

0 commit comments

Comments
 (0)