Distributed .NET with Microsoft Orleans

Book description

Adopt an effortless approach to avoid the hassles of complex concurrency and scaling patterns when building distributed applications in .NET

Key Features

  • Explore the Orleans cross-platform framework for building robust, scalable, and distributed applications
  • Handle concurrency, fault tolerance, and resource management without complex programming patterns
  • Work with essential components such as grains and silos to write scalable programs with ease

Book Description

Building distributed applications in this modern era can be a tedious task as customers expect high availability, high performance, and improved resilience. With the help of this book, you'll discover how you can harness the power of Microsoft Orleans to build impressive distributed applications.

Distributed .NET with Microsoft Orleans will demonstrate how to leverage Orleans to build highly scalable distributed applications step by step in the least possible time and with minimum effort. You'll explore some of the key concepts of Microsoft Orleans, including the Orleans programming model, runtime, virtual actors, hosting, and deployment. As you advance, you'll become well-versed with important Orleans assets such as grains, silos, timers, and persistence. Throughout the book, you'll create a distributed application by adding key components to the application as you progress through each chapter and explore them in detail.

By the end of this book, you'll have developed the confidence and skills required to build distributed applications using Microsoft Orleans and deploy them in Microsoft Azure.

What you will learn

  • Get to grips with the different cloud architecture patterns that can be leveraged for building distributed applications
  • Manage state and build a custom storage provider
  • Explore Orleans key design patterns and understand when to reuse them
  • Work with different classes that are created by code generators in the Orleans framework
  • Write unit tests for Orleans grains and silos and create mocks for different parts of the system
  • Overcome traditional challenges of latency and scalability while building distributed applications

Who this book is for

This book is for .NET developers and software architects looking for a simplified guide for creating distributed applications, without worrying about complex programming patterns. Intermediate web developers who want to build highly scalable distributed applications will also find this book useful. A basic understanding of .NET Classic or .NET Core with C# and Azure will be helpful.

Table of contents

  1. Distributed .NET with Microsoft Orleans
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Section 1 - Distributed Applications Architecture
  7. Chapter 1: An Introduction to Distributed Applications
    1. Technical requirements
    2. Monolithic applications versus distributed applications
      1. Common issues with monolithic apps
      2. N-tier distributed applications
    3. Challenges with distributed applications
      1. Design and implementation
      2. Data management
      3. Messaging
    4. Designing applications for scalability
      1. Vertical scaling or scaling up
      2. Horizontal scaling or scaling out
      3. Load balancers
      4. Caching
      5. Distributed caching
      6. Sharding
    5. Designing applications for high availability
      1. Azure data centers
      2. Azure regions
      3. Azure paired regions
      4. Azure Traffic Manager
      5. Availability sets and availability zones
      6. SQL Always On availability groups
      7. Architecture for high availability
    6. Summary
    7. Questions
  8. Chapter 2: Cloud Architecture and Patterns for Distributed Applications
    1. Technical requirements
    2. A primer on common design principles
      1. Design principles
    3. Understanding cloud architecture styles
      1. Microservices architecture
      2. Event-driven architecture
    4. Understanding cloud design patterns
      1. The gateway aggregation pattern
      2. The CQRS pattern
      3. The cache-aside pattern
      4. The priority queue pattern
      5. The external configuration store pattern
      6. The pipes and filters pattern
    5. Summary
    6. Questions
  9. Section 2 - Working with Microsoft Orleans
  10. Chapter 3: Introduction to Microsoft Orleans
    1. Understanding the actor model for distributed systems
    2. The origin of Microsoft Orleans
    3. The Orleans runtime
      1. The messaging system
      2. The hosting system
      3. The execution system
    4. Orleans design choices
      1. Serialization
      2. Strong isolation
      3. Asynchrony
      4. The distributed directory
      5. Eventual consistency
      6. Message guarantees
      7. Reliability
      8. Cooperative multitasking
      9. Single threading
    5. Why should I learn about Orleans?
    6. When to choose Orleans
    7. Summary
    8. Questions
  11. Chapter 4: Understanding Grains and Silos
    1. Technical requirements
    2. Say hello to Orleans
      1. Cloud-native objects – grains
      2. Hosting silos
    3. Creating your first Orleans application
      1. What is happening behind the scenes?
    4. Naming a grain
    5. Stateless worker grains
    6. Request scheduling in Orleans
      1. Interleaving grain code execution
    7. Co-hosting silos with ASP.NET core
    8. Summary
    9. Questions
  12. Chapter 5: Persistence in Grains
    1. Technical requirements
    2. Understanding grain state persistence
      1. Adding grain state persistence using Azure Cosmos DB
    3. Custom persistence provider
    4. Grains with multiple states
    5. Grains directly interacting with storage
    6. Summary
    7. Further reading
    8. Questions
  13. Chapter 6: Scheduling and Notifying in Orleans
    1. Technical requirements
    2. Understanding and implementing timers
      1. Implementing a timer in a HotelGrain
    3. Understanding and implementing reminders
      1. Configuration
      2. Implementing reminders in a grain
    4. Understanding and implementing notifications
      1. Implementing notifications in a grain
    5. Summary
    6. Questions
  14. Chapter 7: Engineering Fundamentals in Orleans
    1. Technical requirements
    2. Setting up the Orleans dashboard
      1. Dashboard features
      2. Dashboard APIs
      3. Silo Stats
    3. Understanding unit testing in Orleans
    4. Adding real-time telemetry
      1. Enabling application logging in Application Insights
    5. Summary
    6. Questions
  15. Section 3 - Building Patterns in Orleans
  16. Chapter 8: Advanced Concepts in Orleans
    1. Technical requirements
    2. Streaming in Orleans
      1. Implicit subscriptions
    3. Looking into heterogeneous silos
    4. Understanding grain interface versioning
      1. Grain activation with versions
      2. How to deploy new versions of grains
    5. Summary
    6. Questions
  17. Chapter 9: Design Patterns in Orleans
    1. Technical requirements
    2. Distributed cache
    3. Batch message processing with Dispatcher
    4. Cadence with timers
    5. Aggregating with the Reduce pattern
    6. Summary
    7. Questions
  18. Section 4 - Hosting and Deploying Orleans Applications to Azure
  19. Chapter 10: Deploying an Orleans Application in Azure Kubernetes
    1. Technical requirements
    2. Understanding Azure Kubernetes
      1. Steps to run an Orleans application in Azure Kubernetes
    3. Leveraging Azure Kubernetes hosting
    4. Creating a Docker image
    5. Pushing the Docker image to Azure Container Registry
    6. Deploying to Azure Kubernetes
    7. Summary
    8. Questions
    9. Further reading
  20. Chapter 11: Deploying an Orleans Application to Azure App Service
    1. Technical requirements
    2. Introduction to Azure App Service
      1. What is included in an App Service plan?
    3. Creating the required Azure resources
    4. Configuring the application to run on App Service
      1. Geographically distributing the application
    5. Deploying an Orleans application to App Service
    6. Summary
    7. Questions
    8. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you

Product information

  • Title: Distributed .NET with Microsoft Orleans
  • Author(s): Bhupesh Guptha Muthiyalu, Suneel Kumar Kunani
  • Release date: May 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781801818971