Skip to main content

04 - Cost Optimization

Pricing strategies, caching savings, and bandwidth optimization for Azure Front Door

WAF


🎯 Cost Optimization Principles

PrincipleFront Door Implementation
Right-size resourcesChoose appropriate tier (Standard vs Premium)
Reduce consumptionMaximize caching, enable compression
Monitor spendingCost alerts, usage analytics
Optimize data transferReduce origin egress with caching

✅ Cost Optimization Checklist

#RecommendationSavings Impact
1Choose the right tier for your needs🔴 High
2Maximize cache hit ratio🔴 High
3Enable compression🟡 Medium
4Optimize routing to reduce latency charges🟡 Medium
5Use caching rules strategically🟡 Medium
6Monitor and set cost alerts🟢 Low
7Review unused custom domains🟢 Low

💰 Pricing Model Overview

Azure Front Door Pricing Components

Tier Comparison

ComponentStandardPremium
Base Fee$35/month$330/month
Requests (first 100M)$0.01/10K$0.012/10K
Data Transfer (Zone 1)$0.08/GB$0.08/GB
Custom Domains$0.01/month eachIncluded
WAF Requests$0.60/1M$0.60/1M

💡 Premium Break-Even: If you need Private Link or managed WAF rules, Premium is worth the $295/month premium. Calculate based on your security requirements.


📊 Tier Selection Guide

When to Choose Standard ($35/month)

  • ✅ Public-facing websites with basic WAF needs
  • ✅ CDN/caching for static content
  • ✅ Global load balancing without Private Link
  • ✅ Custom WAF rules are sufficient
  • ✅ Budget-conscious deployments

When to Choose Premium ($330/month)

  • Private Link to origins (no public exposure)
  • Managed WAF rules (OWASP, Microsoft Default Rule Set)
  • Bot protection required
  • ✅ Enhanced security reports needed
  • ✅ Enterprise compliance requirements

🎯 Caching for Cost Savings

Caching is the #1 cost optimization lever for Front Door.

Cost Impact of Caching

Caching Cost Savings Example

ScenarioMonthly RequestsCache Hit %Origin Egress (GB)Estimated Savings
No caching10M0%1,000 GB$0
Basic caching10M50%500 GB~$40/month
Optimized caching10M80%200 GB~$64/month
Aggressive caching10M95%50 GB~$76/month

Caching Configuration (Bicep)

resource route 'Microsoft.Cdn/profiles/afdEndpoints/routes@2023-05-01' = {
name: 'static-content-route'
parent: endpoint
properties: {
originGroup: { id: originGroup.id }
patternsToMatch: ['/static/*', '/images/*', '/css/*', '/js/*']
cacheConfiguration: {
queryStringCachingBehavior: 'IgnoreQueryString'
cacheBehavior: 'OverrideAlways'
cacheDuration: '7.00:00:00' // 7 days for static content
compressionSettings: {
isCompressionEnabled: true
contentTypesToCompress: [
'text/html'
'text/css'
'application/javascript'
'application/json'
'image/svg+xml'
]
}
}
}
}

Cache Duration Recommendations

Content TypeRecommended TTLReason
Static assets (CSS, JS)7-30 daysRarely change, use versioning
Images7-30 daysStable content
API responses1-60 secondsBalance freshness vs. savings
HTML pages1-5 minutesDepends on update frequency
User-specific contentDon't cachePrivacy concerns

🗜️ Compression Savings

Enable compression to reduce bandwidth costs by 60-80%.

Compression Impact

Content TypeOriginal SizeCompressed (gzip)Savings
HTML100 KB20 KB80%
CSS50 KB10 KB80%
JavaScript200 KB40 KB80%
JSON100 KB15 KB85%
Images (PNG/JPG)N/AN/AAlready compressed

Enable Compression

cacheConfiguration: {
compressionSettings: {
isCompressionEnabled: true
contentTypesToCompress: [
'text/plain'
'text/html'
'text/css'
'text/javascript'
'application/javascript'
'application/json'
'application/xml'
'image/svg+xml'
]
}
}

📉 Reduce Unnecessary Traffic

1. Block Bad Bots (Premium)

Bad bots consume bandwidth without providing value.

// Bot Manager rule set blocks malicious bots
managedRules: {
managedRuleSets: [
{
ruleSetType: 'Microsoft_BotManagerRuleSet'
ruleSetVersion: '1.0'
}
]
}

2. Rate Limiting

Prevent abuse that inflates costs.

customRules: {
rules: [
{
name: 'RateLimitAbuse'
priority: 1
ruleType: 'RateLimitRule'
rateLimitDurationInMinutes: 1
rateLimitThreshold: 1000
matchConditions: [
{
matchVariable: 'RemoteAddr'
operator: 'IPMatch'
matchValue: ['0.0.0.0/0']
}
]
action: 'Block'
}
]
}

3. Geo-Filtering

Block traffic from regions you don't serve.

{
name: 'BlockUnservedRegions'
priority: 10
ruleType: 'MatchRule'
matchConditions: [
{
matchVariable: 'RemoteAddr'
operator: 'GeoMatch'
matchValue: ['CN', 'RU', 'KP'] // Example: countries not served
}
]
action: 'Block'
}

📊 Cost Monitoring

Set Up Cost Alerts

resource costAlert 'Microsoft.CostManagement/budgets@2023-03-01' = {
name: 'frontdoor-monthly-budget'
properties: {
category: 'Cost'
amount: 500 // Monthly budget in USD
timeGrain: 'Monthly'
timePeriod: {
startDate: '2024-01-01'
}
filter: {
dimensions: {
name: 'ServiceName'
values: ['Azure Front Door Service']
}
}
notifications: {
Actual_GreaterThan_80_Percent: {
enabled: true
operator: 'GreaterThan'
threshold: 80
contactEmails: ['team@company.com']
}
}
}
}

Key Metrics to Monitor

MetricWhy MonitorAction if High
Request CountUnderstand traffic patternsCheck for bot abuse
Origin Request CountCache misses = origin costsImprove cache hit ratio
Bytes SentBandwidth costsEnable compression, optimize caching
WAF Request CountWAF processing costsTune rules, block abusers

Cost Analysis Query (KQL)

// Front Door costs by route
AzureDiagnostics
| where Category == "FrontDoorAccessLog"
| summarize
Requests = count(),
BytesSent = sum(toint(sc_bytes_s)),
CacheHits = countif(cacheStatus_s == "HIT")
| extend
CacheHitRatio = (CacheHits * 100.0) / Requests,
EstimatedEgressGB = BytesSent / (1024 * 1024 * 1024)

💡 Cost Optimization Patterns

Pattern 1: Tiered Caching Strategy

Pattern 2: Development vs Production

EnvironmentTierCachingWAF Mode
DevelopmentStandardDisabledDetection
StagingStandardEnabledDetection
ProductionPremiumAggressivePrevention

Pattern 3: Cost-Effective Multi-Region

Instead of multiple Front Door instances:


📋 Cost Optimization Summary

StrategyImplementationSavings
Right tier selectionStandard for basic, Premium for Private LinkUp to $295/month
Maximize caching7+ day TTL for static content60-90% bandwidth
Enable compressionGzip/Brotli for text content60-80% bandwidth
Block bad trafficBot protection, rate limitingVariable
Monitor costsBudgets and alertsPrevents surprises

🔗 References

ResourceLink
PricingAzure Front Door Pricing
Pricing CalculatorAzure Pricing Calculator
Cost OptimizationWAF Cost Optimization
CachingFront Door Caching

Previous: 03 - Security | Next: 05 - Operational Excellence

📖Learn