zhaohai666 opened a new pull request, #1675: URL: https://github.com/apache/rocketmq-dashboard/pull/1675
# PR: perf(server): bound the N+1 fan-out family with a shared parallel executor and short TTL cache **Branch:** `feature/studio-n1-reduction` **Commit:** `ce09a0c7` — pushed to `origin/feature/studio-n1-reduction` **Base:** `apache:rocketmq-studio` @ `990ba092` **PR create link:** https://github.com/zhaohai666/rocketmq-dashboard/pull/new/feature/studio-n1-reduction ## Summary The remaining N+1 call sites next to #1446 issued per-item admin/cloud calls serially. This PR adds two small shared utilities — `ParallelOps` (bounded parallel mapping) and `TtlCache` (thread-safe short-TTL cache) — and applies them to six call sites. Every site keeps its existing per-item failure tolerance and error semantics. ## Changes ### New utilities (`server/.../common/util/`) - **`ParallelOps`**: order-preserving parallel `map` over a shared daemon executor with a per-call semaphore, so a busy page cannot exhaust JVM threads. Empty / single-item inputs run inline. - **`TtlCache`**: minimal thread-safe TTL cache (values reloaded after expiry; stampede tolerated for short TTLs). ### Call sites 1. **Dashboard** — `RocketMQDashboardProvider`: per-topic `examineTopicRouteInfo` now runs in parallel (per-topic failures return `null` and are skipped). 2. **Dashboard caching** — `DashboardService` caches aggregates for 10s per instance, since the frontend polls this endpoint. 3. **Topic consumers** — `RocketMQMetadataProvider`: per-group `examineConsumeStats` + `examineConsumerConnectionInfo` run in parallel, keeping the per-group fallback VO. 4. **Client list** — `RocketMQClientProvider`: per-group `examineConsumerConnectionInfo` runs in parallel; the "all groups failed" business error is preserved via an `AtomicInteger`. 5. **Instance list** — `InstanceService`: per-instance vendor count calls (`fillCounts`) run in parallel; Aliyun's internal pagination keeps its early-break optimization. 6. **Tencent topic list** — `TencentInstanceProvider`: per-topic `DescribeTopic` time enrichment runs in parallel after pagination instead of inline. 7. **DLQ list** — `RocketMQDLQProvider`: per-DLQ-topic `examineTopicStats` runs in parallel (`buildDLQGroup` already tolerates per-topic failures). ## Verification - `mvn compile` — BUILD SUCCESS (checkstyle clean). - 92 related tests green: `RocketMQDashboardProviderTest` 8, `RocketMQDLQProviderTest` 6, `RocketMQClientProviderTest` 14, `RocketMQMetadataProviderTest` 9, `InstanceServiceTest` 47, `TencentInstanceProviderTest` 4, `DashboardServiceTest` 4. ## Notes - Parallelism is bounded (default 8 concurrent per fan-out) and all pools are daemon threads, so request threads never block the JVM shutdown. - No behavior change: output ordering, per-item failure handling and business error codes are identical to the serial versions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
