# ---
# name: executor-tuned-settings
# description: Annotated async-executor tuning for a mid-volume workload (Spring Boot)
# kind: settings
# phase: 09
# lesson: 03
# ---
# Baseline: Phase 2 lesson 05's starter. Only the executor dials differ.
# Every value here was chosen for: ~50k instances/month, bursty timers at
# month-end, third-party calls isolated behind async tasks (Phase 4).
# Re-derive them for your load; do not cargo-cult.

flowable.async-executor-activate=true

# --- Dial 1: poll interval -------------------------------------------------
# Default 10s adds up to 10s latency to every async hop. Loan steps are
# latency-visible to humans, so poll faster; 2s is a fair floor before
# acquisition chatter shows up in DB metrics.
flowable.process.async-executor-default-async-job-acquire-wait-time=PT2S
flowable.process.async-executor-default-timer-job-acquire-wait-time=PT2S

# --- Dial 2: acquisition batch ---------------------------------------------
# Month-end fires thousands of small timer jobs; grab more per round-trip.
flowable.process.async-executor-max-async-jobs-due-per-acquisition=64
flowable.process.async-executor-max-timer-jobs-per-acquisition=64

# --- Dial 3: lock time ------------------------------------------------------
# MUST exceed the slowest legitimate job. Our worst case is the bureau call
# at its timeout (5s) plus retry jitter — but batch document jobs run to
# 8 minutes, so 10 minutes with margin. Too-short lock time = double runs.
flowable.process.async-executor-async-job-lock-time=PT10M
flowable.process.async-executor-timer-lock-time=PT10M

# --- Dial 4: threads ---------------------------------------------------------
# 8 -> 16 only because probe data showed threads saturated with DB CPU < 50%.
# If DB CPU is the ceiling, DO NOT raise this — fix lesson 05 first.
flowable.process.async-executor-core-pool-size=8
flowable.process.async-executor-max-pool-size=16
flowable.process.async-executor-thread-pool-queue-size=256

# --- Unchanged on purpose -----------------------------------------------------
# Exclusive jobs stay default-on: per-instance serialization prevents
# optimistic-lock storms on parallel branches (Phase 2 cheat sheet).
