Compare the true cost of MQTT persistent connections vs HTTP polling:
viewof compDevices = Inputs.range([1000, 50000], { value: 10000, step: 1000, label: “Number of devices:”, width: 300 })
viewof compPollRate = Inputs.range([1, 60], { value: 1, step: 1, label: “Polls per minute:”, width: 300 })
viewof compCloudCost = Inputs.range([0.5, 3], { value: 1, step: 0.1, label: “Cost per 1M messages ($):”, width: 300 })
viewof compAlbCost = Inputs.range([100, 500], { value: 200, step: 50, label: “Monthly ALB/Gateway cost ($):”, width: 300 })
// MQTT: 1 message per poll compMqttMonthlyMsgs = compDevices * compPollRate * 1440 * 30 compMqttMonthlyCost = (compMqttMonthlyMsgs / 1000000) * compCloudCost
// HTTP: request + response = 2 messages per poll, plus ALB compHttpMonthlyMsgs = compMqttMonthlyMsgs * 2 compHttpMonthlyCost = (compHttpMonthlyMsgs / 1000000) * compCloudCost + compAlbCost
compSavings = compHttpMonthlyCost - compMqttMonthlyCost compSavingsPercent = (compSavings / compHttpMonthlyCost) * 100 compYearlySavings = compSavings * 12 html<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 15px 0;"> <div style="background: linear-gradient(135deg, #16A085 0%, #2C3E50 100%); color: white; padding: 20px; border-radius: 8px;"> <div style="font-size: 1.1em; font-weight: bold; margin-bottom: 10px;">MQTT (Persistent)</div> <div style="font-size: 0.85em; opacity: 0.9;">Messages: ${(compMqttMonthlyMsgs / 1000000).toFixed(1)}M/month</div> <div style="font-size: 2.2em; font-weight: bold; margin: 15px 0; color: #8ff3cc;">$${compMqttMonthlyCost.toFixed(2)}</div> <div style="font-size: 0.85em; opacity: 0.9;">Monthly cost</div> </div> <div style="background: linear-gradient(135deg, #E67E22 0%, #E74C3C 100%); color: white; padding: 20px; border-radius: 8px;"> <div style="font-size: 1.1em; font-weight: bold; margin-bottom: 10px;">HTTP (Polling)</div> <div style="font-size: 0.85em; opacity: 0.9;">Messages: ${(compHttpMonthlyMsgs / 1000000).toFixed(1)}M/month</div> <div style="font-size: 2.2em; font-weight: bold; margin: 15px 0;">$${compHttpMonthlyCost.toFixed(2)}</div> <div style="font-size: 0.85em; opacity: 0.9;">Monthly cost incl. ALB</div> </div> </div> <div style="background: #2C3E50; color: white; padding: 20px; border-radius: 8px; margin: 15px 0; text-align: center;"> <div style="font-size: 0.9em; opacity: 0.9;">Monthly savings with MQTT</div> <div style="font-size: 2.1em; font-weight: bold; margin: 8px 0; color: #8ff3cc;">$${compSavings.toFixed(2)}</div> <div style="font-size: 1em; opacity: 0.9;">${compSavingsPercent.toFixed(1)}% reduction • $${compYearlySavings.toFixed(2)}/year saved</div> </div> <div style="margin: 12px 0 4px; padding: 12px 14px; border-radius: 8px; background: #eef5f7; color: #2C3E50; font-size: 0.95em;"> <strong>Key Insight:</strong> MQTT saves $${compSavings.toFixed(2)}/month (${compSavingsPercent.toFixed(1)}%) by using persistent connections instead of HTTP polling, eliminating ALB costs and halving message traffic. </div>