Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Microservices with Dapr and .NET

You're reading from   Practical Microservices with Dapr and .NET A developer's guide to building cloud-native applications using the Dapr event-driven runtime

Arrow left icon
Product type Paperback
Published in Dec 2020
Publisher Packt
ISBN-13 9781800568372
Length 280 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Davide Bedin Davide Bedin
Author Profile Icon Davide Bedin
Davide Bedin
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Section 1: Introduction to Dapr
2. Chapter 1: Introducing Dapr FREE CHAPTER 3. Chapter 2: Debugging Dapr Solutions 4. Section 2: Building Microservices with Dapr
5. Chapter 3: Service-to-Service Invocation 6. Chapter 4: Introducing State Management 7. Chapter 5: Publish and Subscribe 8. Chapter 6: Resource Bindings 9. Chapter 7: Using Actors 10. Section 3: Deploying and Scaling Dapr Solutions
11. Chapter 8: Deploying to Kubernetes 12. Chapter 9: Tracing Dapr Applications 13. Chapter 10: Load Testing and Scaling Dapr 14. Other Books You May Enjoy Appendix – Microservices Architecture with Dapr

An overview of Dapr

Dapr is an event-driven, portable runtime created by Microsoft with an open source approach and, at the time of writing this book, is still in active development.

Being event-driven, which is emphasized in the definition of Dapr, plays an important role in microservices as an application can be designed to efficiently react to events from external systems or other parts of the solution, and to produce events as well, in order to inform other services of new facts or to continue processing elsewhere or at a later stage.

Dapr is portable, as it can run locally on your development machine in self-hosted mode; it can also be deployed to the edge, or it can run on Kubernetes.

The following diagram shows the many building blocks of a Dapr architecture:

Figure 1.1 – Dapr architecture

Figure 1.1 – Dapr architecture

Portability does also extend beyond the hosting environment—while Dapr is an initiative that was started by Microsoft, it can also run on Kubernetes on-premises or in the cloud, with Microsoft Azure, Amazon Web Services (AWS), Google Cloud Platform (GCP), or any other cloud vendor.

Dapr has been built on the experience gained by Microsoft in developing hyperscale cloud-native applications. It has been inspired by the design of Orleans and Service Fabric, which in turn enables many Microsoft Azure cloud services to operate resiliently and at a large scale.

Dapr offers developers an approach to design the tools to build and the runtime to operate applications, based on a microservice architecture style.

Microservices offer a vast array of benefits balanced by increased complexities in team and product management, usually with a significant burden on the developer and the team in order to get started.

What if you could leverage a runtime such as Dapr to help you get through the common patterns you will likely need to adopt, and thus ease your operations?

This diagram shows the two Dapr hosting modes:

Figure 1.2 – Dapr sidecar

Figure 1.2 – Dapr sidecar

As depicted in Figure 1.2, the Dapr runtime operates in sidecar processes, lifting most of the complexity from the application to a separate environment, greatly simplifying development and operations as well. These sidecar processes are run locally in your development environment or as containers in a Pod on Kubernetes.

From an application perspective, Dapr is an application programming interface (API) that can be directly reached via HyperText Transfer Protocol (HTTP) or gRPC Remote Procedure Call (gRPC) calls or, even more simply, via any of the software development kits (SDKs) available. At the time of writing this book, these SDKs are .NET, Java, Go, Python, C++, JavaScript, and Rust.

As we will experience later, it is not necessary to adopt the Dapr SDK in your application: a call to a Dapr service can be as simple as an HTTP call to an endpoint such as http://localhost:3500/v1.0/invoke/<app-id>/method/<method name>. Nevertheless, using the SDK does provide many benefits if you are writing a Dapr service or leveraging the Dapr actor model.

What Dapr is not

While I hope the overview of Dapr has informed and intrigued you enough to spend time on this book, when I have the chance to talk about Dapr, I often find myself in need of clarifying what Dapr is not. This makes it easier to eliminate any misconceptions we may have about what Dapr does, as follows:

  • Dapr's goal is not to force the developer to embrace a programming model with strict rules and constraints. On the contrary—while the application developer is freed by Dapr of the many complexities of a microservice architecture, the developer is not mandated on how to write the application. As an example, the management of the connection pooling to the database where the state is stored is a responsibility of Dapr and, as we will see in the following chapters, it is transparent to the microservice application code.
  • Dapr is not a service mesh. While many similarities can be found in the general objectives of Dapr and service meshes, Dapr does provide these benefits at the application level while a service mesh operates on the infrastructure. For instance, Dapr applies retry logic in its interaction with state stores and services, but it is the developer's responsibility to decide how to handle errors Dapr might return if there is a conflict or an intermittent issue: whether raising an error back to the client, compensating an operation, or adopting a retry policy (maybe leveraging Polly in .NET), these are explicit choices only the developer can make.
  • Dapr is meant to be integrated with service meshes such as Istio, which is out of the scope of this book.
  • Dapr is not a Microsoft cloud service: it does help the developer build microservice applications in the cloud, and it surely provides many integrations with Azure cloud services, but it also has as many components for AWS, GCP, and other services.

    It is also true that Dapr does not run better on Azure than on any other Kubernetes environment in the cloud. I would hope to convince you that Azure Kubernetes Service (AKS) is the best-managed Kubernetes offering in the cloud space, but this is a different conversation for another time.

    Important note

    While this book is heavily skewed toward .NET, Dapr does provide the same benefits to Python developers (just as an example) as it provides SDKs for Dapr and Dapr Actor, working on macOS, and with Kubernetes as the deployment target—Dapr welcomes all developers in a vendor-neutral and open approach.

The next section will be dedicated to understanding the architectures that Dapr can enable.

You have been reading a chapter from
Practical Microservices with Dapr and .NET
Published in: Dec 2020
Publisher: Packt
ISBN-13: 9781800568372
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image