Skip to Content
AdvancedConcurrency

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

  1. Start small β€” test with concurrency: 1 first
  2. Add delays β€” delayBetweenProfilesMs prevents rate limiting
  3. Monitor memory β€” each browser profile uses ~200-500MB RAM
  4. Scale gradually β€” increase concurrency based on system resources
Last updated on