Implementing retry pattern in ASP.Net application

We have moved to cloud to leverage the benefits of Agile infrastructure​. We can scale our infrastructure​ based on current load they are serving. It gives us ability to meet the hardware need during peak hours and also to save on cost during off-peak hours. But often we do not know in advance when ​​​​will our resource be overwhelmed by user requests. Take the example of a database in cloud. We can scale it, but scaling during a business hour will disconnect the users, at least for a fraction of a moment. Assume our database was already on high usage, which automatically triggered the scale activity, means many users are connected and all of their connections are impacted due to scale up (or down). Some users might retry, but some might not and contact the support to look into the issue. We do not want to give a bad user experience to our customers, hence avoiding scaling activities during business hours.

But this does not allow us to fully utilize the scaling capabilities of cloud infra, if it be to meet the infra need ​or to save the cost at that moment.

What if we implemented a retry logic in our application to do the same thing a user would do in such case i.e. retry?

Below is the code which I tried and it can be used to establish connection to a database: Below is the code for the Retrier: This can not only be used for a database connection but for any other such external service with scaling capabalities or having connection issues due to a high latency.

Comments

Make Money from Surveys

Popular posts from this blog

The current master key cannot be decrypted

Schema.Object has an unresolved reference to Schema

Remove dateModified related warning appearing during Structured data testing