Skip to content

Commit

Permalink
Add concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelWei committed Feb 6, 2025
1 parent 93908f8 commit 8206b4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ services:
image: pilos/bbb-streaming-server:worker-dev-main
depends_on:
- redis
environment:
CONCURRENCY: 1
deploy:
mode: replicated
replicas: 5
Expand Down
3 changes: 2 additions & 1 deletion src/worker/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as path from "node:path";
import axios from 'axios';
const redisHost: string = process.env.REDIS_HOST || 'redis';
const redisPort: number = Number(process.env.REDIS_PORT) || 6379;
const concurrency: number = Number(process.env.CONCURRENCY) || 1;

// Create a Redis client
const redis = new Redis({
Expand All @@ -17,7 +18,7 @@ const processorFile = path.join(__dirname, 'sandbox.js');
const worker = new Worker('streams', processorFile,
{ connection: redis,
removeOnComplete: { count: 0 },
concurrency: 50
concurrency: concurrency
});

worker.on("error", (error) => {
Expand Down

0 comments on commit 8206b4a

Please sign in to comment.