Lab complete!
Now that you have completed this lab, make sure to update your Well-Architected review if you have implemented these changes in your workload.
Click here to access the Well-Architected Tool
In this section we will update the architectural design of the workload and implement sharding. Similar to sharding a database where a large database or table is broken up into smaller chunks distributed across multiple servers, we will shard the overall capacity of the workload and segment it so that each shard is responsible for handling a subset of customers only. By minimizing the number of “components” a single customer is able to interact with within the workload, we will be able to reduce the impact of a potential posion pill. This will result in a much smaller scope of impact depending on the number of shards within the workload. In a sharded system, scope of impact of failures can be calculated using the following formula:
For example if there were 100 customers, and the workload was divided into 10 shards, then the failure of any 1 shard will only impact 10% of customers.
Go to the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation and select the stack that was created as part of this lab - Shuffle-sharding-lab
Click on Update
Under Prerequisite - Prepare template, select Replace current template
https://aws-well-architected-labs-virginia.s3.amazonaws.com/Reliability/300_Fault_Isolation_with_Shuffle_Sharding/sharding.yaml
Click Next
No changes are required for Parameters. Click Next
For Configure stack options click Next
On the Review page:
Note: The template creates an IAM role and Instance Profile for EC2. These are the minimum permissions necessary for the instances to be managed by AWS Systems Manager. These permissions can be reviewed in the CloudFormation template under the “Resources” section - InstanceRole.
This will take you to the CloudFormation stack status page, showing the stack update in progress. The stack takes about 1 minute to go through all the updates. Periodically refresh the page until you see that the Stack Status is in UPDATE_COMPLETE.
With this stack update, the architecture of the workload has been updated by introducing 2 Application Load Balancer listener rules and Target Groups. These listener rules have been configured to inspect the incoming request for a query-string name. Depending on the value provided, the request is routed to one of two target groups where each target group consists of 2 EC2 instances.
Now that the application has been deployed, it is time to test it to understand how it works. The sample application used in this lab is the same as before, a simple web application that returns a message with the Worker that responded to the request. Customers pass in a query string with the request to identify themselves. The query string used here is name.
Copy the URL provided in the Outputs section of the CloudFormation stack created in the previous string.
Append the query string /?name=Alpha
to the URL and paste it into a web browser. The full string should look similar to this - http://shuffle-alb-1p2xbmzo541rr-1602891463.us-east-1.elb.amazonaws.com/?name=Alpha
.
Refresh the web browser a few times to see that responses are being returned from different EC2 instances on the back-end. Notice that after implementing sharding, you are seeing responses being returned from only 2 instances for customer Alpha’s requests. No matter how many times you refresh the page or try a different browser, customer Alpha will only receive responses from 2 EC2 instances. This is because we have created Application Load Balancer listener rules that divert traffic to a specific subset of the overall capacity of the workload, also known as a shard. In this case, customers Alpha, Bravo, and Charlie are mapped to Shard 1 containing Worker 1 and Worker 2, and customers Delta, Echo, and Foxtrot are mapped to Shard 2 containing Worker 3 and Worker 4.
Update the value for the query string to one of the other customers, the possible values are - Alpha, Bravo, Charlie, Delta, Echo, and Foxtrot
Refresh the web browser multiple times to verify that customers are receiving responses only from EC2 instances in the shard they are mapped to
Now that you have completed this lab, make sure to update your Well-Architected review if you have implemented these changes in your workload.
Click here to access the Well-Architected Tool