Let me provide a comprehensive solution addressing all three key aspects: API gateway rate limit policy, batching status updates, and message queue buffering.
Architecture Overview:
Implement a three-tier approach: Edge → Message Queue → Batch Processor → Smart Factory API
1. API Gateway Rate Limit Policy:
Work with your Azure admin to configure appropriate rate limits. For 150 machines with bulk updates, you need roughly 400-500 API calls per hour (not per minute). Request a rate limit of at least 1000 calls/hour to provide headroom. Configure burst allowance for peak periods.
2. Batching Status Updates:
Implement batch collection with time and size triggers:
// Batch processor logic
List<StatusUpdate> batch = new ArrayList<>();
ScheduledExecutor.scheduleAtFixedRate(() -> {
if (batch.size() >= 50 || timeSinceLastBatch > 15000) {
sendBatchToAPI(batch);
batch.clear();
}
}, 5, TimeUnit.SECONDS);
Use the bulk endpoint:
POST /api/resource/status/bulk
{
"updates": [
{"equipmentId":"M-150","status":"running","timestamp":"2025-03-21T13:20:15Z"},
{"equipmentId":"M-151","status":"idle","timestamp":"2025-03-21T13:20:16Z"}
// ... up to 100 records
]
}
3. Message Queue Buffering:
Configure Azure Service Bus with these settings:
- Topic: equipment-status-updates
- Subscription: smart-factory-processor
- Max delivery count: 5
- Lock duration: 60 seconds
- Enable dead-lettering for failed messages
Edge device integration:
// Replace direct API calls with queue publishing
ServiceBusMessage message = new ServiceBusMessage(statusJson);
message.setPartitionKey(equipmentId); // Ensures ordering per equipment
serviceBusClient.send(message);
Implementation Steps:
- Deploy Azure Service Bus namespace and create topic
- Update edge device code to publish to Service Bus instead of API
- Deploy Azure Function or container-based consumer service
- Implement batch collection with 50-record or 15-second triggers
- Add retry logic with exponential backoff (1s, 2s, 4s, 8s, 16s)
- Configure dead letter queue monitoring and alerts
- Update API gateway rate limits to match new call patterns
Real-Time Dashboard Consideration:
For operators needing instant feedback, implement a dual-publish pattern. Equipment sends status to both Service Bus (for persistence) and Azure SignalR Service (for real-time display). This gives you sub-second dashboard updates while maintaining proper API rate compliance for data persistence.
Monitoring:
Set up alerts for:
- Service Bus queue depth > 1000 messages
- Dead letter queue message count > 0
- API 429 errors (should be zero after implementation)
- Batch processing lag > 30 seconds
Cost Impact:
Service Bus Standard tier runs about $10/month for this volume. Azure Functions consumption plan will be minimal ($5-15/month). Total added cost around $15-25/month versus the operational impact of missing equipment status updates.
This architecture handles your current 150 machines and scales to 500+ without API limit issues. The 10-15 second batching window is acceptable for most manufacturing operations while maintaining data integrity and system stability.