Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
970acf1
Added build and deploy for non-linux user
ifew Apr 19, 2019
6cab222
Fixed docker build, not copy file to container
ifew Apr 19, 2019
9a85b24
Added more library
ifew Apr 19, 2019
edd39f7
Added build script for Docker build
ifew Apr 22, 2019
0ab97e1
Added note for user have existed docker image
ifew Apr 22, 2019
8de6e1d
Added script build by Docker and rollback build by script
ifew Apr 24, 2019
83e7bc3
Update .NET Core version
Nov 13, 2019
4631985
Change sample information
Nov 13, 2019
5e40a69
Added timeout httpclient for solved lambda connection timeout 100sec
Nov 13, 2019
4cbdc0d
Added build and deploy for non-linux user
ifew Apr 19, 2019
4aee5d5
Fixed docker build, not copy file to container
ifew Apr 19, 2019
e62eca9
Added more library
ifew Apr 19, 2019
f014694
Added build script for Docker build
ifew Apr 22, 2019
22c2200
Added note for user have existed docker image
ifew Apr 22, 2019
136574a
Added script build by Docker and rollback build by script
ifew Apr 24, 2019
4c9b6e7
Fixed for solve AWS Lambda Connection timeout 100ms
ifew Nov 13, 2019
7c09240
Updated to .NET Core 2.2
ifew Nov 13, 2019
d881d57
Publish package to Nuget
ifew Nov 13, 2019
0d82d6a
Updated readme
ifew Nov 13, 2019
829fd6f
Added name Benz
ifew Nov 13, 2019
6a73b64
Merge branch 'master' of https://github.com/ifew/lambda-native
Nov 14, 2019
842978f
Reference 12 Hours from AWS Custom Runtime Support
Nov 14, 2019
e83bd1d
Changed Package Name
Nov 14, 2019
f18ae1e
Update Readme
Nov 14, 2019
b5aa83a
Update Readme
Nov 14, 2019
19197be
Merge branch 'master' of https://github.com/ifew/lambda-native
Nov 14, 2019
b586de5
Update README.md
ifew Nov 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# ![](assets/logo-small.png) LambdaNative
Make .NET AWS Lambda functions start 10x faster using LambdaNative.

[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
[![Build status](https://ci.appveyor.com/api/projects/status/5x6prdi6oeonxbm7/branch/master?svg=true)](https://ci.appveyor.com/project/zaccharles/lambda-native/branch/master)
[![nuget](https://img.shields.io/nuget/v/LambdaNative.svg)](https://www.nuget.org/packages/LambdaNative/)
Make .NET AWS Lambda functions start 10x faster using LambdaNative and custom for solved AWS Lambda connection timeout (Based on [LambdaNative](https://github.com/zaccharles/lambda-native) by @zaccharles)

[![Build status](https://ci.appveyor.com/api/projects/status/i8h933ig07xin5r7/branch/master?svg=true)](https://ci.appveyor.com/project/ifew/lambda-native/branch/master)
[![nuget](https://img.shields.io/nuget/v/LambdaNative.svg)](https://www.nuget.org/packages/LambdaNativeCustom/)

# Change Log

#### Fixed AWS Lambda Connection Timeout

After the invocating first time (Cold Start) and then waiting for 100 seconds its get error message because of AWS Lambda has default connection timeout at 100 seconds (reference https://aws.amazon.com/premiumsupport/knowledge-center/lambda-function-retry-timeout-sdk/)

Found this solution: Suratchanan Kraidech

# Usage

To use LambdaNative in your own project, please see the README in the [example](example) directory.
Expand All @@ -28,13 +34,13 @@ For more information and comparisons, please read [this Medium post](https://med

## Prerequisites

* [.NET Core SDK 2.1.503](https://dotnet.microsoft.com/download/dotnet-core/2.1)
* [.NET Core SDK 2.2.402](https://dotnet.microsoft.com/download/dotnet-core/2.2)

## Building

Clone repository
```bash
> git clone https://github.com/zaccharles/lambda-native.git
> git clone https://github.com/ifew/lambda-native.git
```

Restore NuGet packages
Expand Down
7 changes: 7 additions & 0 deletions example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# docker build -t lambdanative .
# docker run --rm -v $(pwd):/app lambdanative

FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
RUN apt-get update && apt-get install cmake clang-3.9 libicu-dev uuid-dev libcurl4-openssl-dev zlib1g-dev libkrb5-dev -y
ENTRYPOINT ["dotnet", "publish", "-c", "Release", "-r", "linux-x64"]
15 changes: 15 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ Here are instructions on how to compile the example project on Ubuntu using EC2.

You now have a native executable file named `bootstrap`.

# Compiling with Docker (For Non-Linux User)

* Create Docker image
```bash
sh build-docker.sh
```
* Run script to compile
```bash
sh build.sh
```

And we have `package.zip` in folder `publish` for ready to deploy

If your source code changed, you can run only "build.sh" for generate native file

# Deployment

Now that you have a native executable named `bootstrap`, you can deploy it to AWS Lambda. It's important that the file is named `bootstrap` as this is a convention that lets AWS Lambda know which file to execute.
Expand Down
13 changes: 13 additions & 0 deletions example/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

#
# SHOULD BUILD IMAGE BEFORE
# docker build -t lambdanative .
#

rm -f $(pwd)/bootstrap
rm -f $(pwd)/package.zip
docker run --rm -v $(pwd):/app lambdanative
cp bin/Release/netcoreapp2.1/linux-x64/native/LambdaNative.Example bootstrap
zip package.zip bootstrap
# aws s3 cp package.zip s3://backend-layer [--profile [PROFILE-NAME]]
2 changes: 1 addition & 1 deletion example/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
dotnet publish -r linux-x64 -c release
cp bin/release/netcoreapp*/linux-x64/native/* bootstrap
# zip package.zip bootstrap
# aws s3 cp package.zip s3://<bucket>/package.zip
# aws s3 cp package.zip s3://<bucket>/package.zip
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.503"
"version": "2.2.402"
}
}
8 changes: 7 additions & 1 deletion src/LambdaNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ public static class LambdaNative

private static void Run(IHandlerRunner runner)
{
ILambdaRuntime runtime = new LambdaRuntime(new SystemEnvironment(), new SystemDateTime(), new HttpClient());
// The Lambda container freezes the process at a point where an HTTP request is in progress.
// We need to make sure we don't timeout waiting for the next invocation.
// Reference 12 Hours from AWS Custom Runtime Support
HttpClient httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromHours(12);

ILambdaRuntime runtime = new LambdaRuntime(new SystemEnvironment(), new SystemDateTime(), httpClient);
ILambdaBootstrap bootstrap = new LambdaBootstrap(runtime, runner);

bootstrap.Initialize();
Expand Down
16 changes: 8 additions & 8 deletions src/LambdaNative.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<VersionPrefix>1.0.0</VersionPrefix>
<AssemblyName>LambdaNative</AssemblyName>
<Authors>Zac Charles</Authors>
<Description>Make .NET AWS Lambda functions start 10x faster using LambdaNative</Description>
<PackageId>LambdaNative</PackageId>
<AssemblyName>LambdaNativeCustom</AssemblyName>
<Authors>iFew</Authors>
<Description>Make .NET AWS Lambda functions start 10x faster using LambdaNative and custom for solved AWS Lambda connection timeout (Based on LambdaNative by zaccharles)</Description>
<PackageId>LambdaNativeCustom</PackageId>
<PackageTags>aws,lambda,native,performance</PackageTags>
<PackageProjectUrl>https://github.com/zaccharles/lambda-native</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/zaccharles/lambda-native/master/assets/logo.png</PackageIconUrl>
<PackageLicense>https://github.com/zaccharles/lambda-native/blob/master/LICENSE</PackageLicense>
<PackageProjectUrl>https://github.com/ifew/lambda-native</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/ifew/lambda-native/master/assets/logo.png</PackageIconUrl>
<PackageLicense>https://github.com/ifew/lambda-native/blob/master/LICENSE</PackageLicense>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/zaccharles/lambda-native</RepositoryUrl>
<RepositoryUrl>https://github.com/ifew/lambda-native</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
Expand Down