Skip to content

Commit 2e72172

Browse files
committed
fix: Slow down requests and simplify visualization for clarity
- Add timing constants for educational pace (1s between requests) - Reduce concurrent requests from 8 to 3 for better visibility - Increase request dot size with ring indicator - Simplify connection lines from LB to pods area - Slower animation transitions (0.25s)
1 parent 37c2a36 commit 2e72172

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

components/games/deployment-strategies-simulator.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ const getPodPosition = (idx: number): { x: number; y: number } => {
139139
return { x, y };
140140
};
141141

142+
// Slower timing for educational purposes
143+
const REQUEST_INTERVAL_MS = 1000; // Time between new requests
144+
const PHASE_TO_LB_MS = 300; // Time to reach load balancer
145+
const PHASE_TO_POD_MS = 600; // Time to reach pod after LB
146+
const REQUEST_CLEANUP_MS = 900; // Time before request disappears
147+
const MAX_CONCURRENT_REQUESTS = 3; // Fewer concurrent requests for clarity
148+
142149
export default function DeploymentStrategiesSimulator() {
143150
const [strategy, setStrategy] = useState<DeploymentStrategy>('rolling');
144151
const [isRunning, setIsRunning] = useState(false);
@@ -442,7 +449,7 @@ export default function DeploymentStrategiesSimulator() {
442449

443450
const packetId = `req-${Date.now()}-${Math.random()}`;
444451
setRequests((prev) => [
445-
...prev.slice(-8),
452+
...prev.slice(-(MAX_CONCURRENT_REQUESTS - 1)),
446453
{
447454
id: packetId,
448455
targetPod: targetPod.id,
@@ -465,20 +472,20 @@ export default function DeploymentStrategiesSimulator() {
465472
r.id === packetId ? { ...r, phase: 'to-pod' as const } : r
466473
)
467474
);
468-
}, 150);
475+
}, PHASE_TO_LB_MS);
469476

470477
setTimeout(() => {
471478
setRequests((prev) =>
472479
prev.map((r) =>
473480
r.id === packetId ? { ...r, phase: 'done' as const } : r
474481
)
475482
);
476-
}, 350);
483+
}, PHASE_TO_POD_MS);
477484

478485
setTimeout(() => {
479486
setRequests((prev) => prev.filter((r) => r.id !== packetId));
480-
}, 500);
481-
}, 350);
487+
}, REQUEST_CLEANUP_MS);
488+
}, REQUEST_INTERVAL_MS);
482489

483490
return () => clearInterval(interval);
484491
}, [isRunning, pods, strategy, blueGreenActive, canaryPercentage]);
@@ -627,22 +634,16 @@ export default function DeploymentStrategiesSimulator() {
627634
strokeWidth="2"
628635
strokeDasharray="4"
629636
/>
630-
{/* LB to pods - use same getPodPosition function */}
631-
{pods.map((pod, idx) => {
632-
const pos = getPodPosition(idx);
633-
return (
634-
<line
635-
key={pod.id}
636-
x1="27%"
637-
y1="50%"
638-
x2={`${pos.x}%`}
639-
y2={`${pos.y}%`}
640-
stroke={pod.version === 'v1' ? '#3b82f6' : '#22c55e'}
641-
strokeWidth="1"
642-
strokeOpacity="0.3"
643-
/>
644-
);
645-
})}
637+
{/* LB to pods area - simplified single line */}
638+
<line
639+
x1="27%"
640+
y1="50%"
641+
x2="40%"
642+
y2="50%"
643+
stroke="#475569"
644+
strokeWidth="2"
645+
strokeDasharray="4"
646+
/>
646647
</svg>
647648

648649
{/* Pods - positioned using getPodPosition */}
@@ -711,10 +712,10 @@ export default function DeploymentStrategiesSimulator() {
711712
opacity: req.phase === 'done' ? 0.3 : 1,
712713
}}
713714
exit={{ opacity: 0 }}
714-
transition={{ duration: 0.15, ease: 'easeOut' }}
715-
className={`absolute w-2 h-2 rounded-full -translate-x-1/2 -translate-y-1/2
715+
transition={{ duration: 0.25, ease: 'easeOut' }}
716+
className={`absolute w-3 h-3 rounded-full -translate-x-1/2 -translate-y-1/2
716717
${req.version === 'v1' ? 'bg-blue-400 shadow-blue-400/50' : 'bg-green-400 shadow-green-400/50'}
717-
shadow-lg`}
718+
shadow-lg ring-2 ring-white/20`}
718719
/>
719720
);
720721
})}

0 commit comments

Comments
 (0)