Building tools for
Fair job distribution with per-user concurrency limits. Round-robin, random, and smart strategies.
Interactive PHP REPL for Laravel. Desktop app + PhpStorm plugin. SSH & Docker, magic comments, Claude AI integration.
A Laravel package for queue management with load balancing between partitions (user groups). Perfect for scenarios where you need fair job distribution and concurrency control per user/tenant.
composer require yangusik/balanced-queue
php artisan vendor:publish --tag="balanced-queue-config"
return [
'connection' => env('BALANCED_QUEUE_CONNECTION', 'redis'),
// Strategy: 'round-robin' | 'random' | 'smart'
'strategy' => 'round-robin',
// Max concurrent jobs per partition
'limiter' => [
'driver' => 'simple', // 'simple' | 'adaptive' | 'none'
'max_concurrent' => 2,
],
'queue' => env('BALANCED_QUEUE_NAME', 'default'),
];
use YanGusik\BalancedQueue\Traits\HasBalancedQueue;
class ProcessReport implements ShouldQueue
{
use HasBalancedQueue;
public function __construct(
private User $user,
private Report $report,
) {}
// Partition key — one partition per user
public function partitionKey(): string
{
return 'user:' . $this->user->id;
}
}
// Dispatch normally — balancing is automatic
ProcessReport::dispatch($user, $report);
php artisan balanced-queue:table # Show live stats
php artisan balanced-queue:clear # Clear all partitions
Cycles through partitions in order. Guaranteed fairness — every user gets equal turns regardless of queue size.
strategy: 'round-robin'
Prioritizes partitions with fewer jobs. Helps clear smaller queues faster but may not be perfectly fair.
strategy: 'smart'
Randomly selects the next partition. Simple, low overhead, statistically fair over time.
strategy: 'random'
Interactive PHP REPL for Laravel. Run code on remote servers via SSH or Docker — right from your desktop or inside PhpStorm.
//? after any expression to see its value inline — no var_dump() needed.// Capture line value
$users = User::find(36)->id; //? → ← 36
// Capture mid-chain (passes original through)
collect([1,2,3])/*?*/->count()/*?*/->map(fn($x) => $x * 2);
// ← [1,2,3] ← 3
// Timing (ms since script start)
heavyOperation(); /*?.*/ → ← 142ms