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
Copy file name to clipboardExpand all lines: bottlecap/README.md
+156-1Lines changed: 156 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ One time setup:
9
9
Then: `./runBottlecap.sh`
10
10
11
11
## Developing using Codespaces
12
-
Step 1: Create a codespace (code > codespaces > create codespace on main)
12
+
Step 1: Create a codespace (code > codespaces > create codespace on main)
13
13
14
14

15
15
@@ -18,3 +18,158 @@ Step 2: Hack in the `bottlecap` folder
18
18
Step 3: Test your change running `./runBottlecap.sh`
19
19
20
20

21
+
22
+
## Flush Strategies
23
+
24
+
Bottlecap supports several flush strategies that control when and how observability data (metrics, logs, traces) is sent to Datadog. The strategy is configured via the `DD_SERVERLESS_FLUSH_STRATEGY` environment variable.
25
+
26
+
**Important**: Flush strategies behave differently depending on the Lambda execution mode:
27
+
-**Managed Instance**: Uses continuous background flushing (flush strategies are ignored)
Lambda Managed Instances run your functions on EC2 instances (managed by AWS) with multi-concurrent invocations. This requires setting up a **capacity provider** - a configuration that defines VPC settings, instance requirements, and scaling parameters for the managed instances.
34
+
35
+
-**Activation**: Detected automatically via the `AWS_LAMBDA_INITIALIZATION_TYPE` environment variable. When this equals `"lambda-managed-instances"`, Bottlecap enters Managed Instance mode
36
+
-**Flush Behavior**:
37
+
- A dedicated background task continuously flushes data at regular intervals (default: 30 seconds)
38
+
- All flushes are **non-blocking** and run concurrently with invocation processing
39
+
- Prevents resource buildup by skipping a flush cycle if the previous flush is still in progress
40
+
-`DD_SERVERLESS_FLUSH_STRATEGY` is **ignored** in this mode
41
+
-**Shutdown Behavior**:
42
+
- Background flusher waits for pending flushes to complete before shutdown
43
+
- Final flush ensures all remaining data is sent before the execution environment terminates
44
+
-**Execution Model**: Multi-concurrent invocations where one execution environment handles multiple invocations simultaneously (unlike traditional Lambda's one-invocation-per-environment model)
45
+
-**Use case**: Steady-state, high-volume workloads where optimizing costs with predictable capacity is desired
46
+
-**Key advantage**: Zero flush overhead per invocation - flushing happens independently in the background
47
+
-**Infrastructure**: Lambda launches 3 instances by default for availability zone resiliency when a function version is published to a capacity provider
48
+
49
+
#### On-Demand Mode (Traditional Mode)
50
+
-**Activation**: Default mode for standard Lambda execution (one invocation at a time)
51
+
-**Flush Behavior**:
52
+
- Respects the configured `DD_SERVERLESS_FLUSH_STRATEGY`
53
+
- Flush timing is tied to invocation lifecycle events
54
+
- Can be blocking or non-blocking depending on the chosen strategy
55
+
-**Use case**: Standard Lambda functions with sequential invocation processing
56
+
-**Key advantage**: Fine-grained control over flush timing and behavior
57
+
58
+
### Available Strategies (On-Demand Mode Only)
59
+
60
+
#### `Default` (Recommended)
61
+
-**Configuration**: Set automatically when no strategy is specified, or explicitly via `DD_SERVERLESS_FLUSH_STRATEGY=default`
62
+
-**Behavior**: Adaptive - changes based on invocation frequency
63
+
-**Initial behavior** (first ~20 invocations): Flushes at end of each invocation (blocking)
64
+
-**After 20 invocations**: Switches to non-blocking continuous flushes
65
+
-**Interval**: 60 seconds
66
+
-**Use case**: Recommended for most serverless workloads - automatically optimizes for your traffic pattern
0 commit comments