|
| 1 | +# Example: Choosing a CI/CD Strategy |
| 2 | + |
| 3 | +Your legacy deployments work — SSH into server, git pull, build in place. |
| 4 | +But every deployment is a prayer. No rollbacks, no consistency, no audit trail. |
| 5 | + |
| 6 | +You're building a new service and want to do it right this time. |
| 7 | + |
| 8 | +## The Problem |
| 9 | + |
| 10 | +Current state: |
| 11 | +- Git clone via SSH directly to EC2 |
| 12 | +- Build happens on the server |
| 13 | +- No rollback mechanism |
| 14 | +- "Works on my machine" is the deployment strategy |
| 15 | + |
| 16 | +Requirements: |
| 17 | +- Build/release idempotency |
| 18 | +- Cost-effective (no Kubernetes) |
| 19 | +- Must scale to other services later |
| 20 | +- Private repos, AWS infrastructure |
| 21 | + |
| 22 | +## With Quint |
| 23 | + |
| 24 | +```bash |
| 25 | +$ /q1-hypothesize "CICD strategy for new service - no k8s, cost-effective, idempotent" |
| 26 | +``` |
| 27 | + |
| 28 | +AI generates competing approaches: |
| 29 | + |
| 30 | +| # | Approach | Complexity | Cost | Rollback | |
| 31 | +|---|----------|------------|------|----------| |
| 32 | +| H1 | GitHub Actions + SSH deploy | Low | Free | Manual | |
| 33 | +| H2 | Docker Swarm + ECR | Medium | ~$5/mo registry | Built-in | |
| 34 | +| H3 | ECS Fargate | Medium-High | ~$30+/mo | Built-in | |
| 35 | +| H4 | Kamal (DHH's tool) | Medium | Free | Built-in | |
| 36 | + |
| 37 | +```bash |
| 38 | +$ /q2-verify |
| 39 | +``` |
| 40 | + |
| 41 | +AI checks constraints: |
| 42 | +- **H1 fails:** "No idempotency — same problem as current setup" |
| 43 | +- **H3 partial:** "Overkill for B2B fintech with <100 RPS" |
| 44 | +- **H4 partial:** "Requires Ruby runtime on deploy machine" |
| 45 | +- **H2 passes:** "Native Docker, no external dependencies, handles multi-service" |
| 46 | + |
| 47 | +```bash |
| 48 | +$ /q1-add "concerned about blast radius — all services on one Swarm node?" |
| 49 | +``` |
| 50 | + |
| 51 | +AI generates sub-hypotheses: |
| 52 | + |
| 53 | +| # | Approach | Blast Radius | Cost | |
| 54 | +|---|----------|--------------|------| |
| 55 | +| H2a | Single Swarm node, all services | High | Low (~$50/mo) | |
| 56 | +| H2b | Swarm node per service | Low | Higher (~$150/mo) | |
| 57 | +| H2c | Hybrid: Swarm for new, legacy stays | Medium | Medium | |
| 58 | + |
| 59 | +```bash |
| 60 | +$ /q3-validate |
| 61 | +``` |
| 62 | + |
| 63 | +AI researches evidence: |
| 64 | + |
| 65 | +``` |
| 66 | +H2 — Docker Swarm + ECR |
| 67 | +
|
| 68 | +Evidence collected: |
| 69 | +1. [Docker docs] Swarm handles 1000s of containers per node — CL2 |
| 70 | +2. [AWS pricing] ECR ~$0.10/GB, t3.medium ~$30/mo — CL3 (our context) |
| 71 | +3. [HN thread] "Swarm dead?" — maintainers confirm active, just feature-complete — CL1 |
| 72 | +
|
| 73 | +R_eff = 0.68 (limited by HN thread uncertainty) |
| 74 | +``` |
| 75 | + |
| 76 | +```bash |
| 77 | +$ /q4-audit |
| 78 | +``` |
| 79 | + |
| 80 | +``` |
| 81 | +Bias check: Initial preference was Kamal (H4) — rejected on Ruby dependency |
| 82 | +
|
| 83 | +Trust scores: |
| 84 | +- H2b (Swarm per service): R_eff = 0.68 |
| 85 | +
|
| 86 | +Cost analysis: |
| 87 | +- Staging: Single Swarm node acceptable (blast radius OK for non-prod) |
| 88 | +- Production: Swarm per service for isolation |
| 89 | +
|
| 90 | +Recommendation: H2b for prod, H2a for staging. Revisit if RPS > 1000. |
| 91 | +``` |
| 92 | + |
| 93 | +```bash |
| 94 | +$ /q5-decide |
| 95 | +``` |
| 96 | + |
| 97 | +``` |
| 98 | +Decision: Docker Swarm + ECR |
| 99 | +
|
| 100 | +Architecture: |
| 101 | +- Staging: Single t3.medium, all services in Swarm |
| 102 | +- Production: t3.medium per service, Swarm mode |
| 103 | +- Registry: AWS ECR (private, ~$5/mo) |
| 104 | +- CI: GitHub Actions (free tier sufficient) |
| 105 | +
|
| 106 | +Rationale: |
| 107 | +- Idempotent deploys via image tags |
| 108 | +- Rolling updates with automatic rollback |
| 109 | +- No Ruby/external dependencies |
| 110 | +- Migration path for legacy services |
| 111 | +
|
| 112 | +Review trigger: If any service needs >1000 RPS or HA across AZs |
| 113 | +``` |
| 114 | + |
| 115 | +When new developer asks: *"Why aren't we using Kubernetes? Everyone uses it."* |
| 116 | + |
| 117 | +```bash |
| 118 | +$ /q-query "CICD architecture decision" |
| 119 | +``` |
| 120 | + |
| 121 | +``` |
| 122 | +Decision: 2024-02-15 — Docker Swarm selected over ECS/K8s |
| 123 | +
|
| 124 | +Key evidence: |
| 125 | +- B2B fintech, <100 RPS typical load |
| 126 | +- K8s operational overhead not justified |
| 127 | +- Swarm provides 90% of benefits at 10% complexity |
| 128 | +- Cost: ~$80/mo vs ~$300/mo for ECS |
| 129 | +
|
| 130 | +Recommendation: Revisit only if: |
| 131 | +- Multi-AZ HA required |
| 132 | +- RPS exceeds 1000 sustained |
| 133 | +- Team grows beyond 5 engineers |
| 134 | +``` |
| 135 | + |
| 136 | +**The decision survives team changes. No tribal knowledge required.** |
0 commit comments