Task 3-2: Tune Concurrency cho Từng Queue Type
Phase: 3 - Performance Priority: Medium Depends on: task-3-1 Reference:
docs/BountyHunter-Backend/details/feature-batch-async-processing/SPEC.md
Background
Concurrency hiện tại: PRIZE=1-1, UNLIMITED=20-100. Chưa rõ các queues khác (MISSION, GACHA, MKP, PRESALE, NONE) có concurrency bao nhiêu và có phù hợp với workload thực tế không.
Tasks
1. Audit concurrency config hiện tại
- [ ] Grep annotation
@JmsListenervớiconcurrencyattribute:grep -r "concurrency" batch/jms/ - [ ] List ra concurrency cho từng queue
2. Thu thập production workload data
- [ ] Average messages per minute cho từng queue (từ ActiveMQ metrics sau task-1-1)
- [ ] Average processing time per message (từ task-3-1)
- [ ] Calculate required concurrency:
throughput_required / (1000 / avg_processing_ms)
3. Đề xuất tuning
| Queue | Current concurrency | Proposed | Reason |
|---|---|---|---|
| PRIZE | 1-1 | 1-1 | Sequential required (prize integrity) |
| PRIZE_FOR_STREAMER | 1-1 | 1-1 | Sequential required |
| UNLIMITED | 20-100 | TBD after data | High throughput |
| MISSION | ? | TBD | Update after audit |
| GACHA | ? | TBD | Update after audit |
4. Externalize concurrency config
# application-common.yaml
jms:
listener:
concurrency:
prize: "1-1"
prize-for-streamer: "1-1"
unlimited: "20-100"
mission: "5-20"
Verification / Acceptance Criteria
- [ ]
grep -r "concurrency" batch/jms/produces a complete list of all@JmsListenerconcurrency settings — document this list in the task notes - [ ] Production workload data (messages/min and avg processing time per queue) is captured from ActiveMQ metrics dashboard (task-1-1 output) and recorded before making changes
- [ ]
application-common.yamlcontains externalized concurrency values for all named queue types (at minimum: prize, prize-for-streamer, unlimited, mission, gacha) - [ ]
@JmsListenerconcurrency attributes reference${jms.listener.concurrency.<key>}properties instead of hardcoded strings - [ ] After applying new concurrency values, all JMS listener containers start successfully (no
IllegalArgumentExceptionin startup logs)
Files to Modify
- 9 prize allocation listener files (concurrency annotation)
batch/src/main/resources/application-common.yaml