Concurrency
Configuration
Control how many profiles run in parallel:
const params = {
execution: {
concurrency: 3, // 3 profiles at once
delayBetweenProfilesMs: 2000, // 2s delay between starts
},
}Example 1 β Sequential execution
const params = {
execution: {
concurrency: 1, // one profile at a time
},
}Example 2 β High concurrency with delays
const params = {
execution: {
concurrency: 10, // 10 parallel profiles
delayBetweenProfilesMs: 3000, // stagger starts by 3s
},
}Log output during delay:
β³ Waiting 3000ms before next profile...How it works
The SDK uses p-limit to control concurrency:
Timeline (concurrency: 3, delay: 1s):
t=0s Profile 1 starts βββββββββββββββ done
t=1s Profile 2 starts ββββββββββββ done
t=2s Profile 3 starts βββββββββββββββββ done
t=3s Profile 4 starts (slot freed) ββββ done
...Window Manager
The SDK includes WindowManager to calculate grid positions for browser windows:
import { WindowManager } from '@hira-core/sdk'
const screen = { width: 1920, height: 1080 }
const pos = WindowManager.calculatePosition(
0, // profile index
screen,
800, // window width
600, // window height
0.5, // scale factor
)
// β { x: 0, y: 0 }
const pos2 = WindowManager.calculatePosition(1, screen, 800, 600, 0.5)
// β { x: 800, y: 0 }Example 1 β Default grid layout
With 1920Γ1080 screen and 800Γ600 windows:
ββββββββββββ¬βββββββββββ
β Profile 0 β Profile 1 β
ββββββββββββΌβββββββββββ€
β Profile 2 β Profile 3 β
ββββββββββββ΄βββββββββββExample 2 β Scaled windows for more profiles
// 50% scale = 400Γ300 per window β fits more profiles on screen
const pos = WindowManager.calculatePosition(index, screen, 800, 600, 0.5)Performance Tips
- Start small β test with
concurrency: 1first - Add delays β
delayBetweenProfilesMsprevents rate limiting - Monitor memory β each browser profile uses ~200-500MB RAM
- Scale gradually β increase concurrency based on system resources
Last updated on