Skip to content

Commit de342b5

Browse files
Improve documentation coherence for sticky sessions
- Fix STICKY_SESSIONS.md to reference local terraform module (not sibling repo) - Add enable_sticky_sessions variable and outputs to terraform/README.md - Add sticky sessions section to terraform README explaining multi-replica usage - Add sticky sessions to PRODUCTION_SETUP.md scaling section with instructions - Add sticky sessions to security checklist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b4b6582 commit de342b5

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

docs/PRODUCTION_SETUP.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ View metrics in Azure Portal:
395395

396396
## Scaling
397397

398+
### Important: Enable Sticky Sessions First
399+
400+
When running multiple replicas, you **must** enable sticky sessions for MCP session affinity. MCP sessions are stored in-memory, so requests must be routed to the same replica.
401+
402+
```bash
403+
# Enable sticky sessions (required for multi-replica)
404+
az containerapp ingress sticky-sessions set \
405+
--name $APP_NAME \
406+
--resource-group $RG_NAME \
407+
--affinity sticky
408+
```
409+
410+
If using Terraform, sticky sessions are enabled by default (`enable_sticky_sessions = true`).
411+
412+
See [STICKY_SESSIONS.md](STICKY_SESSIONS.md) for details.
413+
398414
### Configure Auto-scaling
399415

400416
```bash
@@ -525,6 +541,7 @@ Tips:
525541
- [ ] Configure network restrictions if needed
526542
- [ ] Enable Azure Monitor for logging
527543
- [ ] Set up alerts for errors/failures
544+
- [ ] Enable sticky sessions if running multiple replicas
528545

529546
## Next Steps
530547

docs/STICKY_SESSIONS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ AgentGateway stores MCP sessions in-memory. When running multiple replicas, requ
1717

1818
### Terraform (Recommended)
1919

20-
Sticky sessions are enabled by default in the Terraform module:
20+
Sticky sessions are enabled by default in the Terraform module (`terraform/`):
2121

2222
```hcl
23-
module "agentgateway" {
24-
source = "../../../modules/azure/agentgateway"
23+
# In terraform/terraform.tfvars
24+
environment = "prod"
25+
resource_group_name = "agentgateway-prod-rg"
2526
26-
# ... other configuration ...
27-
28-
# Enable sticky sessions for MCP session affinity (default: true)
29-
enable_sticky_sessions = true
30-
}
27+
# Enable sticky sessions for MCP session affinity (default: true)
28+
enable_sticky_sessions = true
3129
```
3230

31+
The module automatically runs `az containerapp ingress sticky-sessions set` after creating the Container App.
32+
3333
### Azure CLI
3434

3535
Enable manually with:

terraform/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ terraform output mcp_endpoint
9696
| `github_repo_url` | GitHub repo for CI/CD | `""` | No |
9797
| `github_pat` | GitHub PAT for CI/CD | `""` | No |
9898
| `client_certificate_mode` | mTLS mode: ignore/accept/require | `ignore` | No |
99+
| `enable_sticky_sessions` | Enable sticky sessions for MCP session affinity | `true` | No |
99100

100101
## Outputs
101102

@@ -109,6 +110,20 @@ terraform output mcp_endpoint
109110
| `build_command` | Command to build image |
110111
| `deploy_command` | Command to deploy new image |
111112
| `logs_command` | Command to view logs |
113+
| `sticky_sessions_enabled` | Whether sticky sessions are enabled |
114+
| `sticky_sessions_verify_command` | Command to verify sticky sessions |
115+
116+
## Sticky Sessions (Multi-Replica)
117+
118+
When running multiple replicas, sticky sessions ensure MCP clients always connect to the same replica. This is critical because MCP sessions are stored in-memory.
119+
120+
Sticky sessions are **enabled by default**. To disable:
121+
122+
```hcl
123+
enable_sticky_sessions = false
124+
```
125+
126+
See [docs/STICKY_SESSIONS.md](../docs/STICKY_SESSIONS.md) for details.
112127

113128
## CI/CD Automation
114129

0 commit comments

Comments
 (0)