Skip to content

Commit 27fc574

Browse files
committed
add readme with instruction on how to compare snapstart times
1 parent 7bc5f90 commit 27fc574

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Comparing performance with SnapStart enabled or disabled
2+
3+
1. Navigate to code directory
4+
```
5+
C:\projects\aws-samples\serverless-dotnet-demo\src\NET8MinimalAPISnapSnart>
6+
```
7+
8+
2. Deploy this project using the SAM Cli:
9+
10+
```
11+
sam build && sam deploy
12+
```
13+
14+
3. SAM will output the root API Gateway endpoint URL:
15+
16+
```
17+
---------------------------------------------------------------------------------------------------------------------
18+
Outputs
19+
---------------------------------------------------------------------------------------------------------------------
20+
Key ApiUrl
21+
Description API Gateway endpoint URL
22+
Value https://123example.execute-api.us-west-2.amazonaws.com/
23+
24+
```
25+
4. Initialize Lambdas:
26+
```
27+
$baseUrl = "https://123example.execute-api.us-west-2.amazonaws.com/"
28+
29+
Invoke-WebRequest $baseUrl/regular/test
30+
Invoke-WebRequest $baseUrl/snapstart/test
31+
32+
Sleep -Seconds 1
33+
34+
Invoke-WebRequest $baseUrl/regular/test
35+
Invoke-WebRequest $baseUrl/snapstart/test
36+
```
37+
38+
5. Run Artillery
39+
40+
```
41+
cd ..\..\loadtest\
42+
43+
artillery run load-test.yml --target "$baseUrl/snapstart"
44+
45+
artillery run load-test.yml --target "$baseUrl/regular"
46+
```
47+
48+
6. Analyze the Results
49+
50+
In the AWS Console, navigate to Cloud Watch Log Insights.
51+
52+
Select the Log Groups for the `ApiWithSnapstart` and `ApiWithoutSnapstart` lambda functions.
53+
54+
Run the following Query:
55+
56+
```
57+
filter @type = "REPORT"
58+
| parse @log /\d+:\/aws\/lambda\/(?<function>.*)/
59+
| parse @message /Restore Duration: (?<restoreDuration>.*?) ms/
60+
| stats
61+
count(*) as invocations,
62+
pct(coalesce(@initDuration,0)+coalesce(restoreDuration,0), 50) as p50,
63+
pct(coalesce(@initDuration,0)+coalesce(restoreDuration,0), 90) as p90,
64+
pct(coalesce(@initDuration,0)+coalesce(restoreDuration,0), 99) as p99,
65+
pct(coalesce(@initDuration,0)+coalesce(restoreDuration,0), 99.9) as p99.9,
66+
pct(@duration, 50) as durP50,
67+
pct(@duration, 90) as durP90,
68+
pct(@duration, 99) as durP99,
69+
pct(@duration, 99.9) as durP99.9
70+
group by function, ispresent(restoreDuration) as restore, (ispresent(@initDuration) or ispresent(restoreDuration)) as coldstart
71+
| sort by coldstart desc
72+
```
73+
74+
The results table will show the difference in Duration and Initialization for coldstarts when Snapstart is disabled or enabled. It also shows warm start time for reference.

0 commit comments

Comments
 (0)