in Technology by
Is it possible to design applications that handle connection failure in Azure?

1 Answer

0 votes
by

Yes, it is possible and is done by means of the Transient Fault Handling Block. There can be multiple causes of transient failures while using the cloud environment:

  • Due to the presence of more load balancers, we can see that the application to database connections fail periodically.
  • While using multi-tenant services, the calls get slower and eventually time out because other applications are using resources to hit the same resource heavily.
  • The last cause can be we ourselves as the user trying to hit the resource very frequently which causes the service to deliberately deny the connection to us to support other tenants in the architecture.

Instead of showing errors to the user periodically, the application can recognize the errors that are transient and automatically try to perform the same operation again typically after some seconds with the hope of establishing the connection. By making use of the Transient Fault Handling Application Block mechanism, we can generate the retry intervals and make the application perform retries. In the majority of the cases, the error would be resolved on the second try and hence the user need not be made aware of these errors unnecessarily.

Following is the sample code that can be used for the retry policy. Here, if the connection is not successful, then the action is retried based on the retry policy defined. There are 3 retry strategies - Fixed Interval, Incremental Interval, Exponential Backoff Strategy.

/***
* Class to detect Transient Blocks - Here
* OperationCancelledException is 
* detected and then the retry strategy is employed.
*/
internal class AppTransientDetection : ITransientErrorDetectionStrategy
{
    bool IsTransient(Exception exception) => 
        exception is OperationCanceledException;
}

/***
* Retry Strategy - Here Fixed Interval Strategy is employed and is retried for 5 times.
*/
RetryStrategy retryStrategy = new FixedInterval(retryCount: 5, retryInterval: TimeSpan.FromSeconds(2));

RetryPolicy retryPolicy = new RetryPolicy(new AppTransientDetection(), retryStrategy);
retryPolicy.ExecuteAction(() => { 
    try { 
        string commandText = @”USE FEDERATION User_Federation(ShardId =” + shardId + “) WITH RESET, FILTERING=ON”; 
        userEntity.Connection.Open();
        userEntity.ExecuteStoreCommand(commandText); 
    } catch (Exception e) {
        userEntity.Connection.Close();
        SqlConnection.ClearAllPools(); 
    } 
});

Related questions

0 votes
    I made an application in react and i'm using ADAL to authenticate in Azure Active Directory, so every ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    State what should be done in case of a service failure in Azure?...
asked Dec 29, 2020 in Technology by JackTerrance
0 votes
    State what will you do in case of a drive failure in Azure?...
asked Dec 29, 2020 in Technology by JackTerrance
0 votes
    Which value of Socket.readyState atribute of WebSocket indicates that the connection is established and communication is possible? A - 0 B - 1 C - 2 D - 3...
asked Dec 2, 2020 in Technology by JackTerrance
+1 vote
    Is it possible to create a custom domain name, or use your organisation's domain name such as eduforum.in, in Azure Active Directory?...
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    Which of the following option helps Azure maintain a high availability and fault tolerance when deploying and upgrading applications ... IP address 4. Scale set 5. Replica set...
asked Sep 22, 2021 in Technology by JackTerrance
0 votes
    Access Azure services from .NET applications?...
asked Dec 31, 2020 in Technology by JackTerrance
0 votes
    Which of the following web applications can be deployed with Azure? a) ASP.NET b) PHP c) WCF d) All of the mentioned...
asked Dec 23, 2020 in Technology by JackTerrance
+1 vote
    Which of the following helps Azure maintain high availability and fault tolerance when deploying and upgrading applications?...
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    The capability of your build system to handle an increase in the amount of code that it integrates and ... Build performance Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    The failure occurred sufficiently early during the transfer that the destination block remains intact. (a) ... topic in portion Recovery System of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    VM creation is possible using Azure Resource Manager in a Virtual Network which was created by means of classic deployment. ?...
asked Jul 30, 2021 in Technology by JackTerrance
0 votes
    Apache cannot handle 10K connections because it is a _____________ webserver....
asked Mar 7, 2021 in Technology by JackTerrance
0 votes
    This is my code: import SimpleITK as sitk reader = sitk.ImageFileReader() reader.SetFileName(filePath) reader.ReadImageInformation() img ... meta = { "a": reader.GetMetaData('0'),...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    To publish a Webi report created on the top of Universe in BO repository, it should be created on which connection?...
asked Mar 13, 2021 in Technology by JackTerrance
...