O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cloud Native

Book Description

Developers often struggle when first encountering the cloud. Learning about distributed systems, becoming familiar with technologies such as containers and functions, and knowing how to put everything together can be daunting. With this practical guide, you’ll get up to speed on patterns for building cloud native applications and best practices for common tasks such as messaging, eventing, and DevOps.

Authors Boris Scholl, Trent Swanson, and Peter Jausovec describe the architectural building blocks for a modern cloud native application. You’ll learn how to use microservices, containers, serverless computing, storage types, portability, and functions. You’ll also explore the fundamentals of cloud native applications, including how to design, develop, and operate them.

  • Explore the technologies you need to design a cloud native application
  • Distinguish between containers and functions, and learn when to use them
  • Architect applications for data-related requirements
  • Learn DevOps fundamentals and practices for developing, testing, and operating your applications
  • Use tips, techniques, and best practices for building and managing cloud native applications
  • Understand the costs and trade-offs necessary to make an application portable

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. O’Reilly Online Learning
    3. How to Contact Us
    4. Acknowledgments
  2. 1. Introduction to Cloud Native
    1. Distributed Systems
      1. Fallacies of Distributed Systems
      2. CAP Theorem
    2. The Twelve-Factor App
    3. Availability and Service-Level Agreements
    4. Summary
  3. 2. Fundamentals
    1. Containers
      1. Container Isolation Levels
      2. Container Orchestration
      3. Kubernetes Overview
      4. Kubernetes and Containers
    2. Serverless Computing
    3. Functions
    4. From VMs to Cloud Native
      1. Lift-and-Shift
      2. Application Modernization
      3. Application Optimization
    5. Microservices
      1. Benefits of a Microservices Architecture
      2. Challenges with a Microservices Architecture
    6. Summary
  4. 3. Designing Cloud Native Applications
    1. Fundamentals of Cloud Native Applications
      1. Operational Excellence
      2. Security
      3. Reliability and Availability
      4. Scalability and Cost
    2. Cloud Native versus Traditional Architectures
    3. Functions versus Services
      1. Function Scenarios
      2. Considerations for Using Functions
      3. Composite of Functions and Services
    4. API Design and Versioning
      1. API Backward and Forward Compatibility
      2. Semantic Versioning
    5. Service Communication
      1. Protocols
      2. Messaging Protocols
      3. Serialization Considerations
      4. Idempotency
      5. Request/Response
      6. Publisher/Subscriber
      7. Choosing Between Pub/Sub and Request Response
      8. Synchronous versus Asynchronous
    6. Gateways
      1. Routing
      2. Aggregation
      3. Offloading
      4. Implementing Gateways
    7. Egress
    8. Service Mesh
    9. Example Architecture
    10. Summary
  5. 4. Working with Data
    1. Data Storage Systems
      1. Objects, Files, and Disks
      2. Databases
      3. Streams and Queues
      4. Blockchain
      5. Selecting a Datastore
    2. Data in Multiple Datastores
      1. Change Data Capture
      2. Write Changes as an Event to a Change Log
      3. Transaction Supervisor
      4. Compensating Transactions
      5. Extract, Transform, and Load
      6. Microservices and Data Lakes
    3. Client Access to Data
      1. Restricted Client Tokens (Valet-Key)
      2. Database Services with Fine-Grained Access Control
      3. GraphQL Data Service
    4. Fast Scalable Data
      1. Sharding Data
      2. Caching Data
      3. Content Delivery Networks
    5. Analyzing Data
      1. Streams
      2. Batch
      3. Data Lakes on Object Storage
      4. Data Lakes and Data Warehouses
      5. Distributed Query Engines
    6. Databases on Kubernetes
      1. Storage Volumes
      2. StatefulSets
      3. DaemonSets
    7. Summary
  6. 5. DevOps
    1. What Is DevOps?
      1. Collaboration
      2. Automation
      3. Lean Principles and Processes
      4. Measurement
      5. Sharing
    2. Testing
      1. Test Doubles
      2. Test Automation Pyramid
      3. When to Run Which Types of Tests
      4. Testing Cadence
      5. Testing in Production
    3. Development Environments and Tools
      1. Development Tools
      2. Development Environments
      3. Local Development Environments
      4. Local Development with a Remote Cluster
      5. Skaffold Development Workflow
      6. Remote Cluster Routed to Local Development
      7. Cloud Development Environments
    4. CI/CD
      1. Source Code Control
      2. Build Stage (CI)
      3. Test Stage (CI)
      4. Deploy Stage (CD)
      5. Release Stage (CD)
      6. Post-Release Stage
    5. Monitoring
      1. Collecting Metrics
      2. Observable Services
    6. Configuration Management
      1. Single-Environment Variable
      2. Multiple-Environment Variables
      3. Adding ConfigMap Data to a Volume
      4. Storing Secrets
      5. Deployment Configuration
    7. Sample CI/CD Flows
    8. Summary
  7. 6. Best Practices
    1. Moving to Cloud Native
      1. Breaking Up the Monolith for the Right Reasons
      2. Decouple Simple Services First
      3. Learn to Operate on a Small Scale
      4. Use an Anticorruption Layer Pattern
      5. Use a Strangler Pattern
      6. Come Up with a Data Migration Strategy
      7. Rewrite Any Boilerplate Code
      8. Reconsider Frameworks, Languages, Data Structures, and Datastores
      9. Retire Code
    2. Ensuring Resiliency
      1. Handle Transient Failures with Retries
      2. Use a Finite Number of Retries
      3. Use Circuit Breakers for Nontransient Failures
      4. Graceful Degradation
      5. Use a Bulkhead Pattern
      6. Implement Health Checks and Readiness Checks
      7. Define CPU and Memory Limits for Your Containers
      8. Implement Rate Limiting and Throttling
    3. Ensuring Security
      1. Treat Security Requirements the Same as Any Other Requirements
      2. Incorporate Security in Your Designs
      3. Grant Least-Privileged Access
      4. Use Separate Accounts/Subscriptions/Tenants
      5. Securely Store All Secrets
      6. Obfuscate Data
      7. Encrypt Data in Transit
      8. Use Federated Identity Management
      9. Use Role-Based Access Control
      10. Isolate Kubernetes Pods
    4. Working with Data
      1. Use Managed Databases and Analytics Services
      2. Use a Datastore That Best Fits Data Requirements
      3. Keep Data in Multiple Regions or Zones
      4. Use Data Partitioning and Replication for Scale
      5. Avoid Overfetching and Chatty I/O
      6. Don’t Put Business Logic in the Database
      7. Test with Production-like Data
      8. Handle Transient Failures
    5. Performance and Scalability
      1. Design Stateless Services That Scale Out
      2. Use Platform Autoscaling Features
      3. Use Caching
      4. Use Partitioning to Scale Beyond Service Limits
    6. Functions
      1. Write Single-Purpose Functions
      2. Don’t Chain Functions
      3. Keep Functions Light and Simple
      4. Make Functions Stateless
      5. Separate Function Entry Point from the Function Logic
      6. Avoid Long-Running Functions
      7. Use Queues for Cross-Function Communication
    7. Operations
      1. Deployments and Releases Are Separate Activities
      2. Keep Deployments Small
      3. CI/CD Definition Lives with the Component
      4. Consistent Application Deployment
      5. Use Zero-Downtime Releases
      6. Don’t Modify Deployed Infrastructure
      7. Use Containerized Build
      8. Describe Infrastructure Using Code
      9. Use Namespaces to Organize Services in Kubernetes
      10. Isolate the Environments
      11. Separate Function Source Code
      12. Correlate Deployments with Commits
    8. Logging, Monitoring, and Alerting
      1. Use a Unified Logging System
      2. Use Correlation IDs
      3. Include Context with Log Entries
      4. Common and Structured Logging Format
      5. Tag Your Metrics Appropriately
      6. Avoid Alert Fatigue
      7. Define and Alert on Key Performance Indicators
      8. Continuous Testing in Production
      9. Start with Basic Metrics
    9. Service Communication
      1. Design for Backward and Forward Compatibility
      2. Define Service Contracts That Do Not Leak Internal Details
      3. Prefer Asynchronous Communication
      4. Use Efficient Serialization Techniques
      5. Use Queues or Streams to Handle Heavy Loads and Traffic Spikes
      6. Batch Requests for Efficiency
      7. Split Up Large Messages
    10. Containers
      1. Store Images in a Trusted Registry
      2. Utilize the Docker Build Cache
      3. Don’t Run Containers in Privileged Mode
      4. Use Explicit Container Image Tags
      5. Keep Container Images Small
      6. Run One Application per Container
      7. Use Verified Images from Trusted Repositories
      8. Use Vulnerability Scanning Tools on Images
      9. Don’t Store Data in Containers
      10. Never Store Secrets or Configuration Inside an Image
    11. Summary
  8. 7. Portability
    1. Why Make Applications Portable?
    2. The Costs of Portability
      1. Data Gravity and Portability
    3. When and How to Implement Portability
      1. Standardized Interfaces
      2. Common Services and Features
      3. Abstractions and Layers
      4. Managed Services from Other Vendors
      5. Portability Tooling
      6. Kubernetes as a Portability Layer
    4. Summary
  9. Index