← 返回卡片

原书出处

Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…

08 Building Resilient Systems

First Edition · 核验版本的摘录快照 · 导入于 2026-11-13T03:44:47.336Z

Effective latency management requires the following: Concurrent processing of independent operations Prioritization of critical paths over optional features Caching strategies at multiple levels Dynamic timeout management based on system conditions Graceful degradation of non-essential features Following is how to handle latency properly: public List<Recommendation> getRecommendations(String userId) { // Use caching for relatively static data List<Product> trending = cache.get("trending", () -> analyticsService.getTrending(), Duration.ofMinutes(5)); // Parallel execution of necessary real-time calls CompletableFuture<UserProfile> profileFuture = CompletableFuture .supplyAsync(() -> userService.getProfile(userId)); CompletableFuture<List<Purchase>> historyFuture = CompletableFuture .supplyAsync(() -> orderService.getHistory(userId)); // Wait for all data with timeout try { UserProfile profile = profileFuture.get(200, TimeUnit.MILLISECONDS); List<Purchase> history = historyFuture.get(200, TimeUnit.MILLISECONDS); // Calculate recommendations asynchronously return CompletableFuture .supplyAsync(() -> calculateRecommendations(profile, history, trending)) .get(500, TimeUnit.MILLISECONDS); } catch (TimeoutException e) { return getFallbackRecommendations(userId); } } // Implement a circuit breaker for external service calls @CircuitBreaker(name = "similarityService", fallbackMethod = "getFallbackSimilar") private List<Product> getSimilarProducts(List<Purchase> history) { return similarityService.findSimilar(history); } private List<Product> getFallbackSimilar(List<Purchase> history, Exception e) { return cache.get("default_recommendations"); } Designing for limited and costly bandwidth While network bandwidth has increased dramatically since these fallacies were first articulated, so have the demands we place on our systems.

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…/_epub-src/OPS/ch08.xhtml

EPUB SHA-256:357a47122841cb03cd2ff1d58b4eb7ee46e4e6e2e56a004d65a18587568e05ff