Debian Codegraph @

crt/aws-c-s3/README.md

raw symbols SCIP
1 ## AWS C S3
2
3 The AWS-C-S3 library is an asynchronous AWS S3 client focused on maximizing throughput and network utilization.
4
5 ### Key features:
6
7 * **Automatic Request Splitting**: Improves throughput by automatically splitting the request into part-sized chunks and performing parallel uploads/downloads of these chunks over multiple connections. There's a cap on the throughput of single S3 connection, the only way to go faster is multiple parallel connections.
8 * **Automatic Retries**: Increases resilience by retrying individual failed chunks of a file transfer, eliminating the need to restart transfers from scratch after an intermittent error.
9 * **DNS Load Balancing**: DNS resolver continuously harvests Amazon S3 IP addresses. When load is spread across the S3 fleet, overall throughput more reliable than if all connections are going to a single IP.
10 * **Advanced Network Management**: The client incorporates automatic request parallelization, effective timeouts and retries, and efficient connection reuse. This approach helps to maximize throughput and network utilization, and to avoid network overloads.
11 * **Thread Pools and Async I/O**: Avoids bottlenecks associated with single-thread processing.
12 * **Parallel Reads**: When uploading a large file from disk, reads from multiple parts of the file in parallel. This is faster than reading the file sequentially from beginning to end.
13
14 ### Documentation
15
16 * [GetObject](docs/GetObject.md): A visual representation of the GetObject request flow.
17 * [Memory Aware Requests Execution](docs/memory_aware_request_execution.md): An in-depth guide on optimizing memory usage during request executions.
18
19 ### Configuration
20
21 #### Environment Variables
22
23 1. **Memory Limit - `AWS_CRT_S3_MEMORY_LIMIT_IN_GIB`**
24
25 The S3 client uses a buffer pool to manage memory for concurrent transfers.
26
27 Example Usage:
28
29 ```bash
30 export AWS_CRT_S3_MEMORY_LIMIT_IN_GIB=4 # 4 GiB limit
31 ```
32
33 **Default Behavior**:
34 When nothing is set, the client sets a default memory limit based on the target throughput.
35
36 **Notes**:
37 * The limit applies per client. If multiple clients created, limit will apply to each separately.
38 * The environment variable value must be a valid positive integer representing gigabytes (GiB).
39 * The value is converted from GiB to bytes internally (1 GiB = 1024³ bytes).
40 * Invalid values or overflow conditions will cause client creation to fail with `AWS_ERROR_INVALID_ARGUMENT`.
41
42 > [!TIP]
43 > You can also control memory limit *in bytes* using client config. The client config takes precedence over the environment variable (memory_limit_in_bytes needs to be set to a non-zero value).
44 > ```c
45 > struct aws_s3_client_config config = {
46 > .memory_limit_in_bytes = GB_TO_BYTES(4), // 4 GiB limit
47 > // ... other configuration
48 > };
49 > ```
50
51 2. **Maximum Parts Pending Read - `AWS_CRT_S3_MAX_PARTS_PENDING_READ`**
52
53 Controls the maximum number of parts that can be pending read from the input stream during an individual multipart upload. Higher values may improve upload throughput for large files by allowing more parts to be read in parallel, only if the disk read speed can benefit from more concurrent reading of parts.
54
55 Example Usage:
56
57 ```bash
58 export AWS_CRT_S3_MAX_PARTS_PENDING_READ=20
59 ```
60
61 **Default Behavior**:
62 If not set, the default value is 5.
63
64 **Notes**:
65 * Only affects multipart uploads. Small files that fit in a single part are not affected.
66 * If there are multiple parallel multipart upload requests, each upload is limited by the value individually (not cumulatively).
67 * Setting this too low may introduce delays between reads, as the meta-request waits for the client to schedule more work.
68 * Setting this too high may cause a single upload to hog work tokens, starving other concurrent uploads.
69 * The value must be a positive integer (1–4294967295). Invalid or zero values are ignored with a warning, and the default is used.
70 * The value is read once on first use and cached for the lifetime of the process.
71 * If the network bandwidth of the device is too low, even a higher value of pending read might not be respected due to having maximum allowed requests in flight.
72
73 3. **Test Bucket - `CRT_S3_TEST_BUCKET_NAME`**
74
75 The S3 bucket name used for running unit tests. See the [test_helper documentation](./tests/test_helper/) for setup instructions.
76
77 ## License
78
79 This library is licensed under the Apache 2.0 License.
80
81 ## Usage
82
83 ### Building
84
85 CMake 3.9+ is required to build.
86
87 `<install-path>` must be an absolute path in the following instructions.
88
89 #### Linux-Only Dependencies
90
91 If you are building on Linux, you will need to build aws-lc and s2n-tls first.
92
93 ```
94 git clone [email protected]:aws/aws-lc.git
95 cmake -S aws-lc -B aws-lc/build -DCMAKE_INSTALL_PREFIX=<install-path>
96 cmake --build aws-lc/build --target install
97
98 git clone [email protected]:aws/s2n-tls.git
99 cmake -S s2n-tls -B s2n-tls/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
100 cmake --build s2n-tls/build --target install
101 ```
102
103 #### Building aws-c-s3 and Remaining Dependencies
104
105 ```
106 git clone [email protected]:awslabs/aws-c-common.git
107 cmake -S aws-c-common -B aws-c-common/build -DCMAKE_INSTALL_PREFIX=<install-path>
108 cmake --build aws-c-common/build --target install
109
110 git clone [email protected]:awslabs/aws-checksums.git
111 cmake -S aws-checksums -B aws-checksums/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
112 cmake --build aws-checksums/build --target install
113
114 git clone [email protected]:awslabs/aws-c-cal.git
115 cmake -S aws-c-cal -B aws-c-cal/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
116 cmake --build aws-c-cal/build --target install
117
118 git clone [email protected]:awslabs/aws-c-io.git
119 cmake -S aws-c-io -B aws-c-io/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
120 cmake --build aws-c-io/build --target install
121
122 git clone [email protected]:awslabs/aws-c-compression.git
123 cmake -S aws-c-compression -B aws-c-compression/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
124 cmake --build aws-c-compression/build --target install
125
126 git clone [email protected]:awslabs/aws-c-http.git
127 cmake -S aws-c-http -B aws-c-http/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
128 cmake --build aws-c-http/build --target install
129
130 git clone [email protected]:awslabs/aws-c-sdkutils.git
131 cmake -S aws-c-sdkutils -B aws-c-sdkutils/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
132 cmake --build aws-c-sdkutils/build --target install
133
134 git clone [email protected]:awslabs/aws-c-auth.git
135 cmake -S aws-c-auth -B aws-c-auth/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
136 cmake --build aws-c-auth/build --target install
137
138 git clone [email protected]:awslabs/aws-c-s3.git
139 cmake -S aws-c-s3 -B aws-c-s3/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
140 cmake --build aws-c-s3/build --target install
141 ```
142
143 #### Running S3 sample
144
145 After installing all the dependencies, and building aws-c-s3, you can run the sample directly from the s3 build directory.
146
147 To download:
148
149 ```
150 aws-c-s3/build/samples/s3/s3 cp s3://<bucket-name>/<object-name> <download-path> --region <region>
151 ```
152
153 To upload:
154
155 ```
156 aws-c-s3/build/samples/s3/s3 cp <upload-path> s3://<bucket-name>/<object-name> --region <region>
157 ```
158
159 To list objects:
160
161 ```
162 aws-c-s3/build/samples/s3/s3 ls s3://<bucket-name> --region <region>
163 ```
164
165 ## Testing
166
167 The unit tests require an AWS account with S3 buckets set up in a particular way.
168 Use the [test_helper script](./tests/test_helper/) to set this up.