Multi-Source Fulfilment Routing 2026: Suppliers के बीच order routing
Production B2B digital-goods fulfilment single supplier पर depend नहीं कर सकता। Exclusive supplier एक single point of failure है: एक outage और हर order fail। सही architectural pattern है multi-source routing जो हर request पर best option automatically select करे।
FoxReload context: FoxReload POST /api/orders (https://public-api.foxreload.com) के through single API endpoint expose करता है — backend routing internally handle होती है। अगर आप FoxReload के अलावा अपने खुद के multiple suppliers manage करते हैं, तो यह article उसके लिए है।
1. Latency-weighted routing
Simplest variant — supplier को lowest p95 delivery latency से pick करना। Historical metrics Redis sliding window में store करें:
type SupplierStats = { p95Ms: number; failureRate: number; stock: number };
async function pickSupplier(productId: string): Promise<string> {
const candidates = await getSuppliersForProduct(productId);
const stats = await Promise.all(
candidates.map(s => redis.hgetall(`sup:${s.id}:stats`))
);
const scored = candidates.map((s, i) => ({
id: s.id,
score: 1 / (parseFloat(stats[i].p95Ms) + 1),
}));
return scored.sort((a, b) => b.score - a.score)[0].id;
}
यह 80% scenarios cover करता है।
2. Stock-aware routing
अगर supplier का inventory buffer से कम है (e.g., popular product के लिए <50 codes) — अच्छी latency होने पर भी इसे primary की तरह avoid करें।
function isViableSupplier(s: SupplierStats, qty: number): boolean {
const buffer = Math.max(50, qty * 3); // 3x safety margin
return s.stock >= buffer && s.failureRate < 0.05;
}
3. Cost-optimised routing
अगर SLA allow करे (e.g., 5 minutes के अंदर fulfilment B2B के लिए normal है), wholesale cost पर optimise करें:
score = (1 / wholesale_cost) * sla_multiplier
where sla_multiplier = 1 if p95 < target else 0
बड़े scale पर (>10k orders/day) यह marginal cost पर 1.5–3% बचाता है।
4. Failover और circuit breaker
Health-check pattern:
| Signal | Threshold | Action |
|---|---|---|
| 5xx rate 5 min में | >5% | Mark DEGRADED |
| Timeout rate | >2% | Mark DEGRADED |
| Heartbeat fail | लगातार 3 | Mark DOWN |
| Recovery | 5 successful | Mark HEALTHY |
Circuit breaker pattern:
import CircuitBreaker from 'opossum';
const breaker = new CircuitBreaker(callSupplier, {
timeout: 8000,
errorThresholdPercentage: 50,
resetTimeout: 120000, // 2 min
});
breaker.fallback(() => fallbackSupplier());
FoxReload API के साथ Order Polling
FoxReload (या किसी भी supplier) से order होने के बाद, delivery के लिए poll करें:
curl https://public-api.foxreload.com/api/orders/{order_id} \
-H "X-API-Key: YOUR_API_KEY"
status === "completed" होने पर items[].externalData[] में codes मिलते हैं। FoxReload में webhooks नहीं हैं — polling ही तरीका है।
CTA
FoxReload single API के नीचे suppliers auto-routing और failover के साथ aggregate करता है। Access पाएं और अपना fulfilment multi-source पर ले जाएँ।
