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
- Amazon Linux 2023 (provided.al2023) with x86_64 architecture
17
15
- Amazon Linux 2 (provided.al2) with x86_64 architecture
18
16
19
17
## Performance
20
18
21
-
Performance benchmarks reveal that Kotlin Native's "Hello World" Lambda function, executed on Amazon
22
-
Linux 2023 (x86_64) with 1024MB of memory, ranks among the top 5 fastest cold starts. Its
23
-
performance is on par with Python and .NET implementations. For a comparison with other languages (including Java), visit https://maxday.github.io/lambda-perf/.
19
+
Benchmarks show that Kotlin Native's "Hello World" Lambda function on Amazon Linux 2023 (x86_64) with 1024MB memory is among the top 5 fastest cold starts, comparable to Python and .NET. For more details, visit [lambda-perf](https://maxday.github.io/lambda-perf/).
@@ -83,13 +82,8 @@ class HelloWorldLambdaHandler : LambdaBufferedHandler<APIGatewayV2Request, APIGa
83
82
}
84
83
```
85
84
86
-
### Streaming
87
-
Streaming function, on the other hand, sends back data as soon as it's available, rather than
88
-
waiting for all the data to be ready. It processes and returns the response in chunks, piece by
89
-
piece, which can be useful when you want to start delivering results right away, especially for
90
-
large or ongoing tasks. This allows for faster responses and can handle data as it comes
91
-
in. [More details here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html).
92
-
For example, `SampleStreamingHandler` reads a large json file and streams it by chunks.
85
+
#### Streaming
86
+
A streaming function sends data as soon as it's available, instead of waiting for all the data. It processes and returns the response in chunks, which is useful for large or ongoing tasks. This allows for faster responses and can handle data as it comes in. [More details here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html). For example, `SampleStreamingHandler` reads a large json file and streams it in chunks.
@@ -122,21 +114,18 @@ For more examples refer to project's sample.
122
114
123
115
## Testing Runtime locally
124
116
125
-
To run runtime
126
-
locally [aws runtime emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) is
127
-
used. Here's how to run project's sample:
117
+
Use the [AWS runtime emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) to run the runtime locally.
128
118
129
-
1.`./gradlew build` to build lambda executable
130
-
2. Modify runtime-emulator/Dockerfile to set proper path to the generated executable (.kexe) file,
131
-
located in build/bin/linuxX64/releaseExecutable
119
+
1.`./gradlew build` to build the Lambda executable.
120
+
2. Modify `runtime-emulator/Dockerfile` to set the path to the generated executable (.kexe) file in `build/bin/linuxX64/releaseExecutable`.
132
121
3. Run `docker build -t sample:latest .`
133
122
4. Start server `docker run -p 9000:8080 sample:latest`
134
-
5. Execute function
123
+
5. Execute the function
135
124
using `curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'`
136
125
137
126
## Build and deploy to AWS
138
127
139
-
1. Apply plugin `id("io.github.trueangle.plugin.lambda") version "0.0.1"`
128
+
1. Apply the plugin `id("io.github.trueangle.plugin.lambda") version "0.0.1"`
140
129
2. Execute `./gradlew buildLambdaRelease`. The command will output the path to the archive containing lambda executable (YOUR_MODULE_NAME.kexe) located in (YOUR_MODULE_NAME/build/bin/lambda/release/YOUR_MODULE_NAME.zip)
141
130
3. Deploy .zip archive to AWS. If you have never used AWS Lambda
142
131
before, [learn how to deploy Lambda function as zip archive manually](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-zip.html)
To log lambda function code, use the global Log object with extension functions. The log message
178
-
accepts any object / primitive type.
166
+
Use the global Log object with extension functions. The log message accepts any object / primitive type.
179
167
180
168
```kotlin
181
169
Log.trace(message:T?) // The most fine-grained information used to trace the path of your code's execution
@@ -191,23 +179,14 @@ Log.error(message: T?) // Messages about problems that prevent the code from per
191
179
Log.fatal(message:T?) // Messages about serious errors that cause the application to stop functioning
192
180
```
193
181
194
-
## Troubleshoot
195
-
196
-
- If you're going to use Amazon Linux 2023 machine, you'll need to create
197
-
a [lambda layer](https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html) with
198
-
libcrypt.so dependency. This is a dynamic library and seems not included into Amazon Linux 2023
199
-
container. The lybcrypt.so can be taken directly from your linux machine (e.g. from
200
-
/lib/x86_64-linux-gnu/libcrypt.so.1 ) or via the
201
-
following [Github Action workflow](https://github.com/trueangle/kotlin-native-aws-lambda-runtime/actions/workflows/libcrypt.yml).
202
-
Once retrieved, zip it and upload as a layer to your lambda function.
182
+
## Troubleshooting
203
183
204
-
- For the time being, only x86-64 architecture is supported by the runtime. LinuxArm64 is not
205
-
supported by Kotlin Native still, details:
184
+
- For Amazon Linux 2023, create a [Lambda layer](https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html) with the libcrypt.so dependency. This library can be taken from your Linux machine or via the [Github Action workflow](https://github.com/trueangle/kotlin-native-aws-lambda-runtime/actions/workflows/libcrypt.yml).
185
+
- Currently, only x86-64 architecture is supported by the runtime. LinuxArm64 is not supported by Kotlin Native yet, For more details, see:
206
186
1. The list of supported targets for Kotlin Native (
- If you are running the project build on MacOS you might come across a set of errors connected with
211
190
curl linking e.g. `ld.lld: error: undefined symbol: curl_global_init`. This means that your local
212
191
machine [uses different curl version from what is requested by the runtime](https://youtrack.jetbrains.com/issue/KTOR-6361/Curl-Error-linking-curl-in-linkDebugExecutableLinuxX64-on-macOS).
0 commit comments