Polly is a popular open-source .NET library that provides a resiliency framework for building robust and fault-tolerant applications. It is designed to help developers handle transient faults and failures gracefully, such as network issues, database problems, or service unavailability. Polly allows you to implement various resilience and fault-handling policies in our .NET applications.
2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive feedback for all sessions as it is very
helpful for the presenter.
Silent Mode
Keep your mobile devices in silent mode, feel free to move out of session
in case you need to attend an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during the session.
3. 1. Introduction to Resiliency
2. Challenges in Distributed Systems
3. Introduction to Polly
4. Polly's Key Features
Circuit Breaker pattern
Retry pattern
Timeout pattern
Fallback pattern
5. Use cases
6. Best Practices
7. Demo
4. Definition: Resiliency in software development
refers to the ability of a system to withstand and
recover gracefully from failures, ensuring
continuous operation even when components fail.
5. Importance of Resiliency
In today's distributed and complex software architectures,
applications are prone to various challenges such as network
failures, service outages, and latency issues.
Building resilient applications is crucial to ensure reliability, user
satisfaction, and business continuity. So here, we will explore
Polly, a powerful .NET Resiliency Framework, and how it helps
developers address these challenges effectively.
6. Challenges in Distributed Systems
• Network Failures: In distributed systems, network failures are
common, leading to communication issues between services
and components.
• Service Outages: Services may go down due to
maintenance, updates, or unexpected issues, affecting the
overall application.
• Latency Issues: High latency can impact user experience,
especially in scenarios where real-time responsiveness is
crucial.
Addressing these challenges requires a resilient approach in
software design and implementation.
7. Introduction to Polly
What is Polly?
• Polly is an open-source .NET library that helps developers
implement resiliency patterns in their applications.
• It provides a set of policies for handling transient faults and
other resiliency concerns in a flexible and configurable
manner.
8. Polly as a .NET Resiliency framework
• Specifically designed for .NET applications, Polly integrates
seamlessly with various .NET frameworks and libraries.
• Polly allows developers to handle faults and build resilient
systems through well-established patterns.
9. Overview of Polly’s Features and Capabilities
Circuit Breaker Pattern: Prevents repeated calls to a failing operation, reducing the
impact of transient faults.
Retry Pattern: Enables automatic retries with customizable policies to handle
transient failures.
Timeout Pattern: Sets a maximum execution time for an operation, preventing it from
running indefinitely.
Fallback Pattern: Defines alternative actions to be taken when an operation fails,
ensuring graceful degradation.
With Polly, developers can enhance the robustness of their applications in the face of
various challenges.
10. Polly’s Key Features
Circuit Breaker Pattern:
• Polly implements the Circuit Breaker pattern to avoid repeated calls to a
failing operation.
• This pattern helps to reduce the impact of transient faults by temporarily
blocking the execution of the failing operation.
• Configurable parameters allow developers to fine-tune the behavior of
the Circuit Breaker.
11. Retry Pattern:
• Polly's Retry pattern enables automatic retries of operations in the
presence of transient failures.
• Developers can specify retry policies, including the number of retries,
delay between retries, and conditions triggering retries.
• This feature is essential for handling scenarios where temporary issues
may affect service availability.
12. Timeout Pattern:
• Polly provides the Timeout pattern to set a maximum execution time for
an operation.
• Prevents operations from running indefinitely, helping to manage system
resources effectively.
• Developers can define the maximum allowed duration for an operation.
13. Fallback Pattern:
• Polly's Fallback pattern allows developers to define alternative actions
when an operation fails.
• Ensures graceful degradation by providing a backup plan in case the
primary operation fails.
• Configurable fallback strategies for different scenarios.
14.
15. Explanation of the Circuit Breaker Pattern
• The Circuit Breaker pattern prevents a system from repeatedly trying to
execute an operation that is likely to fail.
• It operates like an electrical circuit breaker, blocking the execution of a
faulty operation for a defined period.
• This helps in minimizing the impact of transient faults and allows the
system to recover.
16. How Polly implements the Circuit Breaker Pattern
• Polly provides a straightforward API for implementing the
Circuit Breaker pattern.
• Developers can configure the circuit breaker with parameters
such as failure threshold, duration of the open state, and
settings for resetting.
• Polly monitors the success and failure of operations and
dynamically adjusts the circuit state based on the configured
policies.
17. Benefits of Using the Circuit Breaker Pattern
• Improved system stability during periods of increased load or
service instability.
• Reduced resource consumption by avoiding unnecessary
retries on failing operations.
• Enhanced resilience by preventing cascading failures in
distributed systems.
18.
19. Explanation of the Retry Pattern
• Purpose: Polly's Retry pattern is designed to handle transient
failures by automatically retrying a failed operation.
• Flexibility: Developers can customize retry policies based on
the specific needs of their application.
• Retrying Strategies: Polly supports various retry strategies,
including fixed retries, exponential backoff, and jittered retries.
20. How Polly Implements the Retry Pattern
• Policy Configuration: Developers can define the number of
retries, the duration between retries, and conditions triggering
retries.
• Automatic Retries: Polly intelligently manages retries, allowing
applications to recover from transient issues without manual
intervention.
• Exponential Backoff: Polly can be configured to use
exponential backoff strategies, reducing the frequency of
retries over time.
21. Use Cases for the Retry Pattern
• Network Transient Failures: Retry pattern is effective in
scenarios where network issues cause transient failures.
• Service Dependencies: Handling temporary unavailability of
external services through automatic retries.
• Resource Availability: Ensuring resource availability by
retrying operations that might initially fail.
22.
23. Explanation of the Timeout Pattern
• Purpose: Polly's Timeout pattern helps prevent operations
from running indefinitely, ensuring timely responses.
• Importance: In distributed systems, unexpected delays can
occur; setting a maximum execution time is crucial for
resource management.
24. How Polly Helps in Handling Timeouts
• Configuration: Developers can set a maximum allowed
duration for an operation using Polly's timeout policy.
• Fail-Fast Approach: Polly ensures a fail-fast approach,
terminating operations that exceed the defined time limit.
• Resource Management: Timeout policies contribute to
effective resource utilization by avoiding prolonged execution
times.
25. Preventing Long-Running Operations
• Scenario: Long-running operations can impact system
responsiveness and resource availability.
• Benefits: Polly's Timeout pattern prevents operations from
tying up resources, contributing to the overall stability of the
system.
By incorporating Polly's Timeout pattern, developers can
proactively manage operation durations, enhance system
responsiveness, and improve the overall efficiency of their
applications.
26.
27. Explanation of the Fallback Pattern
• Purpose: Polly's Fallback pattern allows developers to define
alternative actions when the primary operation fails.
• Graceful Degradation: Fallback strategies ensure graceful
degradation by providing a backup plan in case of failure.
• Enhanced Resilience: Applications can continue to function
with reduced functionality even when certain operations
encounter issues.
28. Implementing Fallback Strategies with Polly
• Configurable Fallbacks: Developers can configure specific
fallback actions to execute when the primary operation fails.
• Conditional Fallbacks: Polly enables the definition of
conditions under which fallback actions should be triggered.
• Example: For a web service call, a fallback could involve
returning cached data if the service is temporarily unavailable.
29. Ensuring Graceful Degradation
• Use Cases: Fallbacks are valuable in scenarios where the
failure of an operation does not necessarily mean the entire
system is compromised.
• User Experience: Fallback strategies contribute to maintaining
a positive user experience by handling failures transparently.
Polly's Fallback pattern provides a safety net for applications,
allowing them to gracefully handle failures and maintain a level
of functionality even under challenging conditions.
30.
31. Benefits Observed
• Improved Uptime: Highlight instances where Polly contributed
to minimizing downtime and ensuring continuous service
availability.
• Enhanced User Satisfaction: Explore cases where the use of
Polly resulted in improved user satisfaction due to reduced
service disruptions.
• Operational Efficiency: Discuss how Polly positively affected
operational efficiency by automating resiliency measures.
32. Real World Examples
• Scalability Challenges
• Service Dependencies
• Dynamic Environments
35. Customization Strategies
• Tailor Policies: Customize retry, timeout, and fallback policies
to align with application requirements.
• Dynamic Adjustments: Leverage Polly's dynamic policy
adjustments based on runtime conditions.
• Feedback Loops: Establish feedback loops for continuous
improvement, considering insights from monitoring
36. Scalability Considerations
• Scaling Policies: Adjust Polly policies to accommodate varying
levels of system load and demand.
• Parallelization: Explore parallelization strategies to enhance
performance during periods of increased traffic.
• Graceful Scaling: Ensure that Polly gracefully scales with
application growth without compromising resiliency.
37. Error Handling and Recovery
• Graceful Error Handling: Implement detailed error handling to
provide meaningful feedback to users and operators.
• Recovery Strategies: Define recovery strategies for scenarios
where Polly's resiliency measures are invoked.
• Fallback Optimization: Optimize fallback strategies to maintain
a seamless user experience during failures.