Files
company-celebration/packages/server/load-test/vote-real-scenario.yaml
empty 83bf1d3a43 chore: sync various improvements and fixes
- Update gitignore and serena config
- Improve connection and voting stores
- Enhance admin routes and socket handling
- Update client-screen views
- Add auth middleware

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:31:38 +08:00

154 lines
4.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================================
# 年会现场真实场景压测 - 节目投票瞬间爆发
# 场景节目结束后主持人宣布开始投票100人同时打开页面每人投7票
# ============================================================================
#
# 运行方式:
# artillery run vote-real-scenario.yaml -e live
#
# ============================================================================
config:
target: "http://127.0.0.1:3000"
# 性能阈值
ensure:
p95: 500
maxErrorRate: 1
# Socket.IO 配置 - 强制 WebSocket
socketio:
transports: ["websocket"]
path: "/socket.io"
extraHeaders:
Origin: "http://localhost:5174"
# 处理器脚本
processor: "./vote-processor.cjs"
# 7个节目ID和7个奖项票种一一对应
variables:
programIds:
- "p1"
- "p2"
- "p3"
- "p4"
- "p5"
- "p6"
- "p7"
ticketTypes:
- "creative"
- "visual"
- "atmosphere"
- "performance"
- "teamwork"
- "popularity"
- "potential"
# 环境配置
environments:
# 现场真实场景 - 100人同时涌入
live:
target: "http://127.0.0.1:3000"
phases:
# 阶段1: 瞬间爆发 - 100人同时进入主持人宣布投票开始
- name: "投票开始100人同时进入"
duration: 2
arrivalRate: 50 # 2秒100人 = 50人/秒,模拟瞬间爆发
# 阶段2: 投票高峰期 - 持续投票
- name: "投票高峰期"
duration: 45
arrivalRate: 5 # 维持连接,持续投票
# 阶段3: 投票结束
- name: "投票结束"
duration: 5
arrivalRate: 2
# ============================================================================
# 测试场景定义 - 模拟三种投票速度的用户
# ============================================================================
scenarios:
# 场景1: 快速投票者 (30%) - 2-3秒投完7票手速极快
- name: "快速投票者"
weight: 3
engine: socketio
flow:
- function: "generateUserId"
- emit:
channel: "connection:join"
data:
userId: "{{ userId }}"
userName: "快投-{{ userId }}"
role: "user"
# 快速投7票每票间隔 0.2-0.4 秒)
- loop:
- function: "selectSequentialTicket"
- function: "selectRandomProgram"
- emit:
channel: "vote:submit"
data:
candidateId: "{{ selectedProgram }}"
category: "{{ selectedTicket }}"
localId: "{{ $uuid }}"
- think: 0.3
count: 7
- think: 1
# 场景2: 正常投票者 (50%) - 10-15秒投完7票正常速度
- name: "正常投票者"
weight: 5
engine: socketio
flow:
- function: "generateUserId"
- emit:
channel: "connection:join"
data:
userId: "{{ userId }}"
userName: "正常-{{ userId }}"
role: "user"
# 正常速度投7票每票间隔 1-2 秒,看节目、思考)
- loop:
- function: "selectSequentialTicket"
- function: "selectRandomProgram"
- emit:
channel: "vote:submit"
data:
candidateId: "{{ selectedProgram }}"
category: "{{ selectedTicket }}"
localId: "{{ $uuid }}"
- function: "randomNormalDelay"
- think: "{{ normalDelay }}"
count: 7
- think: 3
# 场景3: 慢速投票者 (20%) - 30-40秒投完7票犹豫不决型
- name: "慢速投票者"
weight: 2
engine: socketio
flow:
- function: "generateUserId"
- emit:
channel: "connection:join"
data:
userId: "{{ userId }}"
userName: "慢投-{{ userId }}"
role: "user"
# 先观望 5-10 秒
- function: "randomLongDelay"
- think: "{{ longDelay }}"
# 慢速投7票每票间隔 3-5 秒)
- loop:
- function: "selectSequentialTicket"
- function: "selectRandomProgram"
- emit:
channel: "vote:submit"
data:
candidateId: "{{ selectedProgram }}"
category: "{{ selectedTicket }}"
localId: "{{ $uuid }}"
- function: "randomSlowDelay"
- think: "{{ slowDelay }}"
count: 7
- think: 5