Skip to content

Commit 1c3205e

Browse files
authored
Enhance documentation with best practices for ActiveMQ Artemis
Added detailed best practices for ActiveMQ Artemis on Azure Container Apps, including probes, autoscaling, revision rollouts, resource limits, and observability.
1 parent b5e6f0d commit 1c3205e

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

0_Azure/8_AzureApps/demos/1_Compute/1_ACA_ActiveMQArtemis_broker-quorum.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ Last updated: 2025-10-23
3131

3232
<details>
3333
<summary><b>Table of Content</b> (Click to expand)</summary>
34-
34+
35+
- [Overview](#overview)
36+
- [How Artemis work?](#how-artemis-work)
37+
- [Best Practices for ActiveMQ Artemis on Azure Container Apps](#best-practices-for-activemq-artemis-on-azure-container-apps)
38+
- [Q&A sample](#qa-sample)
3539

3640
</details>
3741

@@ -42,6 +46,9 @@ Last updated: 2025-10-23
4246
- **Quorum voters** (also running in Azure or other sites) decide which broker should be live during failures.
4347
- Your app doesn’t need to know which broker is live, the client libraries handle failover automatically if configured correctly.
4448

49+
<img width="1600" height="917" alt="image" src="https://github.com/user-attachments/assets/d8fb6d24-429c-4199-a18a-2c737f330d9c" />
50+
51+
From [Azure Container Apps overview](https://learn.microsoft.com/en-us/azure/container-apps/overview)
4552

4653
## Overview
4754

@@ -246,6 +253,30 @@ producer.send(session.createTextMessage("Order #123"));
246253
- **Resource limits:** Right-size CPU/memory; set hard limits to avoid eviction.
247254
- **Observability:** Monitor queue depth, consumer lag, connection churn, and election events with actionable alerts.
248255

256+
<details>
257+
<summary><b> Expand for detailed explanation</b> (Click to expand)</summary>
258+
259+
- **Probes:** Set liveness and readiness probes to accommodate journal recovery time and cluster handshakes. Container restarts are fast, but broker initialization isn't. Use readiness gates so traffic flows only after the broker is truly operational. Set readiness initial delay equal to measured journal recovery time; liveness timeout slightly longer than typical GC pauses. `Kubernetes reports containers ready when the process starts, not when the broker finishes recovery. Misaligned probes route traffic prematurely, causing errors.`
260+
- **Prevents:** Premature traffic routing, failed connection handshakes, and false positive health-check cycles.
261+
- **Evidence:** Readiness probe passes only after journal replay and cluster initialization complete; liveness probe tolerates normal GC pauses without restart; no client connection failures during broker startup.
262+
263+
- **Autoscaling:** Keep minimum replica counts that preserve quorum during maintenance and scale-down events. Avoid scaling voters down below majority threshold. Use metrics like active connections or queue depth for scale decisions, not just CPU/memory. Never reduce voters below the count needed for majority (e.g., keep ≥3 for a 3-voter setup). `Autoscalers don't understand quorum. Scaling down voters can unintentionally remove your majority, halting elections and promotions.`
264+
- **Prevents:** Accidental quorum loss from autoscaler decisions; inability to elect a new live broker during scale-down.
265+
- **Evidence:** Autoscaling policies enforce minimum replica floors that maintain quorum; scale events logged and reviewed; quorum remains intact during all scale actions.
266+
267+
- **Revision rollouts:** Use rolling updates with surge capacity so a new replica is ready before the old one terminates. Partition upgrades to ensure a live broker isn't replaced before its backup is confirmed ready. Validate new revisions against health endpoints before shifting traffic. `Rolling updates must preserve at least one live messaging path. Surge capacity and partitioned rollouts prevent update-induced outages.`
268+
- **Prevents:** Update-induced outages or mid-traffic role swaps causing message loss or connection drops.
269+
- **Evidence:** Zero-downtime deployments; backup brokers report ready before live brokers terminate; traffic continues seamlessly during revision rollouts.
270+
271+
- **Resource limits:** Right-size CPU and memory allocations based on measured peak usage. Set hard limits to prevent node eviction from resource contention. Pin replicas to availability zones when possible; avoid noisy-neighbor impacts by reserving baseline resources. `Under-provisioning causes throttling and OOM kills. Over-provisioning wastes cost. Noisy neighbors and memory spikes can evict critical brokers.`
272+
- **Prevents:** Container preemption, out-of-memory crashes, CPU throttling under load, and noisy-neighbor interference.
273+
- **Evidence:** Stable resource usage patterns; no CPU throttling or memory pressure events; no evictions in container logs; consistent latency under load.
274+
275+
- **Observability:** Centralize logs and metrics covering connections, queue depth, page usage, and election outcomes. Implement actionable alerts tied to SLOs. Sign or encrypt logs and keep retention aligned to audit and compliance needs. `You can't fix what you can't see. Fine-grained metrics and tamper-proof logs let you act before SLOs break and provide forensic trails.`
276+
- **Prevents:** Blind spots leading to silent message buildup, election failures, or security incidents going undetected.
277+
- **Evidence:** Dashboards show queue depth, consumer lag, connection churn, and election events; alerts fire before SLO breaches; log integrity verified via signatures.
278+
279+
</details>
249280
250281
7. **Operations and DR drills**
251282
- **Regular failover tests:** Simulate broker crash, zone outage, and region outage.
@@ -254,6 +285,31 @@ producer.send(session.createTextMessage("Order #123"));
254285
- **Runbooks:** Document voter replacement, broker promotion/demotion, and planned maintenance.
255286
- **Post-incident reviews:** Tune timeouts and probes based on real incident data.
256287

288+
<details>
289+
<summary><b> Expand for detailed explanation</b> (Click to expand)</summary>
290+
291+
- **Regular failover tests:** Simulate broker crashes, zone outages, and full region loss scenarios. Verify voter quorum behavior, promotion timing, and client continuity during each test. Record actual RTO/RPO and compare against targets. `High availability isn't real until it's rehearsed. Testing validates timing, correctness, and actual client experience under realistic failure conditions.`
292+
- **Prevents:** Discovering HA gaps, misconfigured timeouts, or broken failover logic during actual incidents.
293+
- **Evidence:** Documented RTO/RPO from drill runs; clean promotions within target windows; no data anomalies or message loss; client reconnections succeed automatically.
294+
295+
- **Backup/restore rehearsals:** Test full and point-in-time restores to staging environments regularly. Validate journal integrity, certificates/keys, and configuration after recovery. Automate backups with documented retention policies. `Backups you've never restored are hope, not strategy. Rehearsals reveal corruption, missing dependencies, and restore-time gaps.`
296+
- **Prevents:** Discovering broken or incomplete backups during a crisis; prolonged downtime from restore failures.
297+
- **Evidence:** Successful restores to staging within RTO targets; journal integrity checks pass; all certificates, keys, and configs usable post-restore.
298+
299+
- **Config drift detection:** Keep broker and voter configurations under version control (Git). Continuously compare running state to desired state in source control. Alert on unauthorized or manual changes. `Small manual edits accumulate into dangerous divergence. Drift creates inconsistent HA behavior and surprises during failover.`
300+
- **Prevents:** Inconsistent HA behavior across nodes; unknown configuration changes breaking failover logic.
301+
- **Evidence:** Git-backed configurations; periodic automated diff checks; alerts fire on unauthorized changes; all config changes traceable to commits and approvals.
302+
303+
- **Runbooks:** Create time-boxed, step-by-step runbooks with clear rollback triggers for common operations: voter replacement, broker promotion/demotion, and planned maintenance. Test runbooks during drills to validate accuracy and timing. `Clear steps reduce decision-making overhead and human error when stress is high. Time-boxing ensures teams don't get stuck.`
304+
- **Prevents:** Human error, slow response during incidents, and incomplete or incorrect operational changes.
305+
- **Evidence:** Teams execute voter replacement or broker demotion quickly and consistently; runbook steps completed within documented time windows; rollback procedures validated.
306+
307+
- **Post-incident reviews:** Capture metrics, timelines, decisions, and communication during incidents. Tune timeouts, resource limits, and probe thresholds based on actual failure data. Update chaos tests and runbooks to cover newly discovered failure modes. `Learning turns pain into resilience. Real incidents reveal assumptions and gaps that no amount of planning catches.`
308+
- **Prevents:** Repeated failures from the same root cause; gradual erosion of HA guarantees from undocumented changes.
309+
- **Evidence:** Timeouts and probes adjusted based on real latency data; capacity planning updated with actual usage patterns; new chaos tests added for observed failure modes; incident learnings documented and shared.
310+
311+
</details>
312+
257313
## Q&A sample
258314

259315
> `Discovery questions`, is about the **number and distribution of quorum voters**. Because quorum logic depends on majority, the design must use an **odd number** (3, 5, 7…) and spread them across independent sites.

0 commit comments

Comments
 (0)