performance-concurrency-advisor

작성자: kotlin

Kotlin과 Spring 서비스에서 메트릭, 트레이스, SQL 등의 실제 증거를 사용하여 성능, 처리량, 지연 시간 및 동시성 동작을 분석하고 개선합니다.

npx skills add https://github.com/kotlin/kotlin-backend-agent-skills --skill performance-concurrency-advisor

Performance Concurrency Advisor

Source mapping: Tier 2 high-value skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-18).

Mission

Find the bottleneck that actually limits the system, then recommend the smallest high-leverage change. Treat performance work as evidence-driven systems analysis, not as a bag of folklore.

Read Evidence First

  • Latency metrics, percentile breakdowns, throughput, and error rate.
  • Traces for slow flows.
  • SQL count or explain plans when persistence is involved.
  • Hikari, thread pool, event loop, or queue metrics when available.
  • Thread dumps, heap or GC signals, and recent code changes when the issue is severe.

Diagnose By Layer

Check these layers explicitly:

  • database query count and query latency
  • connection pool contention
  • downstream HTTP or messaging latency
  • thread pool starvation or scheduler misuse
  • event-loop blocking in reactive flows
  • serialization or large payload overhead
  • lock contention or transactional scope
  • cache misses or invalidation churn
  • CPU-bound work and allocation pressure

Advanced Performance Heuristics

  • N+1 is both a latency bug and a load amplifier. Fixing it often helps pool pressure and downstream CPU together.
  • Bigger pools are not a universal fix. If the database is slow, increasing concurrency often worsens tail latency.
  • Hikari tuning should follow database capacity and workload pattern, not only CPU count.
  • Blocking calls inside WebFlux or coroutine event loops are catastrophic even when average latency looks acceptable.
  • Dispatchers.IO is not a free performance button. It moves blocking but can also hide architectural mismatch and increase context switching.
  • Parallelizing downstream calls can reduce mean latency while worsening saturation and timeouts under load.
  • Caches need invalidation, warm-up, and cardinality discipline. A bad cache can improve benchmarks and hurt production correctness.
  • Large object graphs, verbose JSON, and repeated mapping can dominate latency once the database is already optimized.
  • Lock contention and long transactions often look like random latency spikes until you correlate them with pool saturation and retries.
  • GC tuning is downstream of allocation patterns. Do not jump to JVM flags before understanding object churn.

Measurement Nuances

  • Average latency hides tail pain. Prefer percentiles and saturation correlation when user pain is bursty.
  • Coordinated omission can make a load test look healthier than production. Treat benchmark tooling assumptions as part of the evidence.
  • Container CPU limits, memory limits, and JDK container-awareness can dominate runtime behavior even when local profiling looks clean.
  • Warm-up state, JIT compilation, cache fill, and connection pool priming matter. Separate cold-start behavior from steady-state behavior.
  • If queueing exists anywhere in the path, small utilization increases can create nonlinear latency growth. Think in queueing terms, not only in raw CPU percentages.

Expert Heuristics

  • Prefer eliminating unnecessary work before parallelizing existing work.
  • If one optimization helps throughput but worsens tail latency or operator clarity, call that tradeoff out explicitly.
  • When reactive or coroutine code is slower than blocking code, first verify hidden blocking boundaries and context switches before blaming the paradigm.
  • If the service is already SLO-bound by a dependency, optimize isolation and graceful degradation before micro-optimizing local code.

Concurrency Rules

  • Distinguish I/O-bound work from CPU-bound work before recommending async or parallel execution.
  • Keep transaction scopes short when locks or connection usage are involved.
  • Treat shared mutable in-memory state as a design smell in horizontally scaled services.
  • For coroutine or reactive flows, verify context propagation for transactions, security, and MDC if debugging or tracing is part of the issue.
  • Use backpressure, bulkheads, or bounded queues before unbounded parallelism.

Output Contract

Return these sections:

  • Observed bottleneck: the most likely limiting resource or contention point.
  • Evidence: metrics, traces, code path, or SQL evidence supporting that conclusion.
  • Recommended change: the smallest high-impact optimization.
  • Tradeoffs: what gets better and what new risk appears.
  • Verification: the benchmark, metric, or load-test signal that should improve.

Guardrails

  • Do not optimize without measurement.
  • Do not recommend caching, async, or bigger pools as reflexes.
  • Do not confuse throughput optimization with latency optimization; sometimes they move in opposite directions.
  • Do not trust local benchmarks alone for highly concurrent or I/O-heavy paths.

Quality Bar

A good run of this skill identifies the true constraint and gives a measurable improvement plan. A bad run suggests generic tuning knobs with no evidence, no tradeoffs, and no way to confirm success.

kotlin의 다른 스킬

ci-cd-containerization-advisor
kotlin
재현 가능한 빌드, 이미지 및 배포 파이프라인을 설계합니다. Kotlin 및 Spring 애플리케이션을 대상으로 하며, CI 검증, 계층형 컨테이너, 롤아웃 안전성 등을 포함합니다.
official
configuration-properties-profiles-kotlin-safe
kotlin
Design and diagnose Spring configuration, profiles, and `@ConfigurationProperties` binding for Kotlin applications. Use when property binding fails,…
official
dependency-conflict-resolver
kotlin
Diagnose and resolve Gradle and Spring classpath conflicts, version drift, and binary incompatibilities in Kotlin applications. Use when `NoSuchMethodError`,…
official
domain-decomposition-api-design-advisor
kotlin
구현을 시작하기 전에 비즈니스 범위를 경계 컨텍스트, 모듈 또는 서비스 경계, 워크플로우, API 계약으로 분해합니다. 새로운 것을 설계할 때 사용하세요.
official
error-model-validation-architect
kotlin
Kotlin과 Spring 서비스를 위한 일관된 API 검증 및 오류 처리 동작을 설계하고 구현합니다. 오류 페이로드를 정의하거나 프레임워크를 매핑할 때 사용합니다.
official
gradle-kotlin-dsl-doctor
kotlin
Generate, debug, and repair Kotlin + Spring Gradle builds with minimal, compatible changes. Use when `build.gradle.kts` or `settings.gradle.kts` is failing,…
official
integration-resilience-engineer
kotlin
탄력적인 HTTP, 메시징, 예약 통합을 Kotlin 및 Spring 서비스용으로 설계하며 명시적인 타임아웃 예산, 재시도, 멱등성, 서킷 브레이커를 포함합니다.
official
jackson-kotlin-serialization-specialist
kotlin
Kotlin과 Jackson을 사용하는 Spring 애플리케이션에서 JSON 직렬화 및 역직렬화 동작을 진단하고 설계합니다. DTO 역직렬화 실패 시, 기본값…
official