5-Minute Crash Course on Cloud Pattern #2 – Retry

Here is another buzz cloud pattern Retry. What is Retry? Yes, it’s just a retry after a failure. What is important is how we retry base on different scenarios.

Let’s look at some of its applications that immediately popped up in my head.

TCP / IP solved this problem long time ago. I won’t go into details here. But if you are interested, please search for ISO TCP stack. Internet / HTTP was then built on top of TCP/IP. Now we re-solve this problem on cloud applications level.

Retry in CDMA / Ethernet [2]. When there is a collision, the retry logic will wait x 2 time and try again, and then repeats.

If you’d like to know more about this cloud pattern, visit references [1].

References:

  1. https://docs.microsoft.com/en-us/azure/architecture/patterns/retry
  2. https://en.wikipedia.org/wiki/Code-division_multiple_access
Advertisements

Why Is It So Important to Avoid Configuration Drift?

What is configuration drift? Configuration Drift is the inconsistent configuration items among different environments [1, 2].

Configuration drift happens naturally among developers’ machines, dev / QA/ Staging/ Production environment servers. How many times do we remember something doesn’t work or fails just because a config setting is NOT set up correctly across different environments? Too many times that I just cannot remember.

The consequence of configuration drift increases dramatically from developers’ machines to DEV/ QA/ Staging / Prod / DR environments.

The consequence of configuration drift in the scenario of losing a data center is un-imaginable. In this scenario, the full set of DEV / QA / Staging / Prod environments in the fail-over data center doesn’t function fully. Can you imagine the chaos and re-sync efforts afterwards?

References:

  1. https://www.continuitysoftware.com/blog/what-is-configuration-drift/
  2. https://searchwindowsserver.techtarget.com/definition/configuration-drift

5-Minute Crash Course on Cloud Pattern – Circuit Breaker

Let’s look at a physical circuit breaker first from Wikipedia. A circuit breaker is an automatically operated electrical switch designed to protect an electrical circuit from damage caused by excess current from an overload or short circuit. Its basic function is to interrupt current flow after a fault is detected. Unlike a fuse, which operates once and then must be replaced, a circuit breaker can be reset (either manually or automatically) to resume normal operation [1].

What about our cloud pattern Circuit Breaker? Cloud pattern Circuit Breaker is an automatically operated software switch designed to protect the operations of internal resource from the interruption of transient failure of external resources. Its basic function is to stop calling external resources after a fault is detected, return an exception to the application, and application can choose to give users a graceful degradation experience instead of a total failure. The software circuit breaker can be reset (either by a timer or ping external sources periodically) to resume normal operations.

Circuit breaker can be represented with a state machine with three states [2]:

  1. Closed. The request from the application is routed to the operation.
  2. Half-Open. A limited number of requests from the application are allowed to pass through and invoke the operation.
  3. Open. The request from the application fails immediately and an exception is returned to the application.

For more details about the pattern, please refer to references.

References:

  1. https://en.wikipedia.org/wiki/Circuit_breaker
  2. https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker

Azure Availability Set, Availability Zone, VM Scale Sets and AWS Equivalents

Azure Availability Set, Availability Zone, and VM Scale Sets provide redundancy and availability. However, they are different and often confused.

An availability set is a logical grouping of VMs within a datacenter
[1]. It has two subgrouping, Fault Domain and Update Domain. After Fault Domain and Update Domain are defined, Azure then understands your requirements, and automatically manages your VMs across the Fault Domain and Update Domain.

An Availability Zone is a physically separate zone within an Azure region. There are three Availability Zones per supported Azure region. Each Availability Zone has a distinct power source, network, and cooling. [1]

Azure virtual machine scale sets let you create and manage a group of identical, load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule [2].

 Availability SetAvailability ZoneVM Scale Sets 
Logic
Concept
Logic
grouping
Kind ofLogic grouping of identical VMs
Physical locationWithin a datacenter a physically separate zone within an Azure regionwithin a single datacenter or across multiple datacenters
Number of VMs>= 2N/AAuto increase or decrease
Load BalancerYes N/AYes

AWS equivalents:

AzureAWS
Availability SetN/A
Availability ZoneAvailability Zone
VM Scale Sets Auto Scale Group

References:

  1. https://docs.microsoft.com/en-us/azure/virtual-machines/windows/regions-and-availability
  2. https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/overview

Desired State, Why Is It So Important?

We all want to move from current state to desired state. This problem can be simplified into the following notations:

S -> T1 -> T2 -> T3 -> … -> Tn -> D

(S: Start state, T: Transition state, D: Desired state)

Imagine that we watch a person (P) or an organization (O) going through the transitions from S to D step by step, we also like to go to D. We have two options:

  1. We follow exact steps as P or O did
  2. or we can optimize the transitions so that the problem can be solved by:

S -> Tm -> D

We can optimize, streamline, and cut cost in option 2 as long as we can reach Desired State. This is why it’s so important.

I am sure there are many real world applications of Desired State. But I only remember these following:

  1. In enterprise architecture and strategic planning, we all want to know the road map from start state to desired state
  2. Powershell uses Desired State Configuration
  3. DAC / DACPAK use Desire State concept

References:

https://docs.microsoft.com/en-us/powershell/dsc/overview/overview

https://docs.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications?view=sql-server-2017

C# Async / Await Revisit #2 – It Causes Deadlock!

In my previous post, we revisited Async / Await.

Today, I say please add ConfigureAwait(false) to your Async task. Otherwise, you might have a potential deadlock situation. For how and why it might cause a deadlock, please read the excellent articles in references.

public async Task DoWorkAsync()
{
    var task = ...;
    await task.ConfigureAwait(false);
}

References:

http://www.tugberkugurlu.com/archive/the-perfect-recipe-to-shoot-yourself-in-the-foot-ending-up-with-a-deadlock-using-the-c-sharp-5-0-asynchronous-language-features

https://stackoverflow.com/questions/37129427/api-request-waitingforactivation-not-yet-computed-error

https://stackoverflow.com/questions/20830998/async-always-waitingforactivation

https://msdn.microsoft.com/en-us/magazine/jj991977.aspx

https://stackoverflow.com/questions/13489065/best-practice-to-call-configureawait-for-all-server-side-code

Don’t Confuse Azure DevOps Project with Azure DevOps or VSTS

I used to think VSTS is renamed to Azure DevOps. Azure DevOps Project is just another name for a project in Azure DevOps. Today, I attended Azure Global Azure Boot Camp. As I sat through the topic “Azure DevOps Projects”, I began to realize that Azure DevOps Projects are different from Azure DevOps and VSTS. It builds upon Azure DevOps and source control, supports popular application frameworks, has full cloud-based CI/CD pipeline, and can be deployed to popular platforms [1]. And all these can be done in a few minutes. What impresses me is that it provides a unified view into code repository, the CI/CD pipeline, and applications in Azure in a single dashboard.

It is said to be a good choice for quick prototype and POC. But I cannot wait to use it in real world scenarios.

References:

  1. https://azure.microsoft.com/en-us/features/devops-projects/
  2. https://docs.microsoft.com/en-us/azure/devops-project/azure-devops-project-aspnet-core
  3. https://docs.microsoft.com/en-us/azure/devops-project/azure-devops-project-sql-database?toc=%2Fen-us%2Fazure%2Fdevops-project%2Ftoc.json&bc=%2Fen-us%2Fazure%2Fbread%2Ftoc.json

Debug Tip – Using Excel ‘Text To Columns’

Today I debugged and captured the following t-sql insert statement

insert into Table1 (col1, col2, col3, ..., colN) 
values (val1, val2, val3, ..., valN)

I had around 200 columns, and I’d like to check colM and colP’s values. I taught to myself I just cannot count the numbers of columns. It’s so cumbersome that I must find a way to do it automatically. I challenged a DBA / Data guru nearby.

He was so eager and exciting, basically grabbed keyboard from my hand, and quickly showed me how to do it. Basically there is a ‘Data’ tab in excel, we can choose ‘Text to Columns’, and set the delimiter to ‘,’ in this case. In less than 10 seconds, we can see a table like this that we can find any column and value easily.

col1col2col3colN
val1val2val3valN

We All Know 24×7. But Do You Know 996?

We all know what 24×7 means? But do you know what 996 means? I just heard about it a few days ago. 996 is a work schedule that you work from 9am to 6pm every day and 6 days a week [3]. Some red-hot tech companies in China adopt this kind of work schedule or something similar. Some Chinese tech tycoon such as Jack Ma endorsed this kind of work culture [1], [2].

Here is some background. Before 1994, the official government labor law in China was 48 hours per week (8 hours per day x 6 days per week). After 1994, the labor law was changed to 40 hours per week (8 hours per day x 5 days per week), and it’s the same as US.

Reference [3] from quora is resourceful and reflects explanations and opinions from different angles.

References:

  1. http://fortune.com/2019/04/15/jack-ma-996-culture/
  2. https://www.cnn.com/2019/04/15/business/jack-ma-996-china/index.html
  3. https://www.quora.com/Is-it-really-common-in-China-to-work-on-a-996-schedule-from-9am-to-9pm-6-days-a-week