Skip to content

Commit d17c37c

Browse files
authored
Item:223 Simulating outages documentation updated (#263)
1 parent cd6919c commit d17c37c

File tree

1 file changed

+68
-25
lines changed

1 file changed

+68
-25
lines changed

src/content/docs/aws/tutorials/simulating-outages.mdx

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,58 @@ The following diagram shows the architecture that this application builds and de
5555

5656
![Architecture](/images/aws/arch-1.png)
5757

58-
### Preflight checks
5958

60-
Before starting any outages, it's important to verify that our application is functioning correctly.
61-
Start by creating an entity and saving it.
62-
To do this, use curl to call the API Gateway endpoint for the POST method:
59+
## Testing the application
60+
61+
Before simulating outages, verify that the application is working as expected:
6362

6463
```bash
6564
curl --location 'http://12345.execute-api.localhost.localstack.cloud:4566/dev/productApi' \
66-
--header 'Content-Type: application/json' \
67-
--data '{
68-
"id": "prod-2004",
69-
"name": "Ultimate Gadget",
70-
"price": "49.99",
71-
"description": "The Ultimate Gadget is the perfect tool for tech enthusiasts looking for the next level in gadgetry.
72-
Compact, powerful, and loaded with features."
73-
}'
65+
--header 'Content-Type: application/json' \
66+
--data '{
67+
"id": "prod-2004",
68+
"name": "Ultimate Gadget",
69+
"price": "49.99",
70+
"description": "The Ultimate Gadget is the perfect tool for tech enthusiasts looking for the next level in gadgetry. Compact, powerful, and loaded with features."
71+
}'
7472
```
7573

74+
Expected output:
75+
7676
```bash title="Output"
7777
Product added/updated successfully.
7878
```
7979

80+
After ending the outage, confirm that previously failed items are stored successfully:
81+
82+
```bash
83+
awslocal dynamodb scan --table-name Products
84+
```
85+
86+
Expected output:
87+
88+
```json
89+
{
90+
"Items": [
91+
{
92+
"name": { "S": "Super Widget" },
93+
"description": { "S": "A versatile widget that can be used for a variety of purposes. Durable, reliable, and affordable." },
94+
"id": { "S": "prod-1003" },
95+
"price": { "N": "29.99" }
96+
},
97+
{
98+
"name": { "S": "Ultimate Gadget" },
99+
"description": { "S": "The Ultimate Gadget is the perfect tool for tech enthusiasts looking for the next level in gadgetry. Compact, powerful, and loaded with features." },
100+
"id": { "S": "prod-2004" },
101+
"price": { "N": "49.99" }
102+
}
103+
],
104+
"Count": 2,
105+
"ScannedCount": 2,
106+
"ConsumedCapacity": null
107+
}
108+
```
109+
80110
### Simulating the outage
81111

82112
Next, we will configure the Chaos API to target all DynamoDB operations.
@@ -197,32 +227,45 @@ Compact, powerful, and loaded with features."
197227
}
198228
```
199229

230+
231+
## Conclusion
232+
233+
Simulating outages with the Chaos API helps uncover weaknesses in application error handling and data durability. To mitigate outages:
234+
235+
- Implement retry logic for failed operations
236+
- Use queues (e.g., SQS) to buffer writes during downtime
237+
- Employ Lambda functions to process and retry queued items
238+
- Monitor system health and automate recovery actions
239+
240+
By proactively testing and designing for failure, you can build resilient cloud applications that gracefully handle disruptions and minimize data loss.
241+
242+
---
243+
200244
### Introducing network latency
201245

202246
The LocalStack Chaos API can also introduce a network latency for all connections.
203247
This can be done with the following configuration:
204248

205249
```bash
206250
curl --location --request POST 'http://localhost.localstack.cloud:4566/_localstack/chaos/effects' \
207-
--header 'Content-Type: application/json' \
208-
--data '{
209-
"latency": 5000
210-
}'
251+
--header 'Content-Type: application/json' \
252+
--data '{
253+
"latency": 5000
254+
}'
211255
```
212256

213257
With this configured, you can use the same sample stack to observe and understand the effects of a 5-second delay on each service call.
214258

215259
```bash
216260
curl --location 'http://12345.execute-api.localhost.localstack.cloud:4566/dev/productApi' \
217-
--max-time 2 \
218-
--header 'Content-Type: application/json' \
219-
--data '{
220-
"id": "prod-1088",
221-
"name": "Super Widget",
222-
"price": "29.99",
223-
"description": "A versatile widget that can be used for a variety of purposes.
224-
Durable, reliable, and affordable."
225-
}'
261+
--max-time 2 \
262+
--header 'Content-Type: application/json' \
263+
--data '{
264+
"id": "prod-1088",
265+
"name": "Super Widget",
266+
"price": "29.99",
267+
"description": "A versatile widget that can be used for a variety of purposes. Durable, reliable, and affordable."
268+
}'
226269
```
227270

228271
```bash title="Output"

0 commit comments

Comments
 (0)