You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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
+
}'
74
72
```
75
73
74
+
Expected output:
75
+
76
76
```bash title="Output"
77
77
Product added/updated successfully.
78
78
```
79
79
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
+
80
110
### Simulating the outage
81
111
82
112
Next, we will configure the Chaos API to target all DynamoDB operations.
@@ -197,32 +227,45 @@ Compact, powerful, and loaded with features."
197
227
}
198
228
```
199
229
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
+
200
244
### Introducing network latency
201
245
202
246
The LocalStack Chaos API can also introduce a network latency for all connections.
203
247
This can be done with the following configuration:
204
248
205
249
```bash
206
250
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
+
}'
211
255
```
212
256
213
257
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.
0 commit comments