SlideShare a Scribd company logo
1 of 75
Download to read offline
Byte Sized RustByte Sized Rust
Chicago Rust Meetup
January 2020
-Steve Hoffman @bacoboy
1
Motivation...Motivation...
https://xkcd.com/149/2 . 1
Motivation...Motivation...
https://xkcd.com/149/
Me: Run my code
2 . 1
Motivation...Motivation...
https://xkcd.com/149/
Me: Run my code
Cloud: Okay
2 . 1
Less Stuff I Gotta Do...Less Stuff I Gotta Do...
https://blogs.oracle.com/developers/functions­as­a­service:­evolution,­use­cases,­and­getting­started2 . 2
Idle Servers Cost $$$Idle Servers Cost $$$
Type vCPU Mem GB Hourly on
demand
Monthly on
demand
Reserved 3yr
all upfront
t3.nano 2 0.5 $0.0052 $3.75 $1.41
t3.small 2 2 $0.0208 $14.98 $5.72
m5.large 2 8 $0.096 $69.12 $26.89
c5.large 2 4 $0.085 $61.20 $23.39
r5.large 2 16 $0.126 $90.72 $36.31
c5n.2xlarge 8 21 $0.432 $311.04 $119.67
c5n.18xlarge 72 192 $3.888 $2,799.36 $896.97
https://aws.amazon.com/ec2/pricing/on­demand/2 . 3
Deploying Faster...Deploying Faster...
2 . 4
What is a λ?What is a λ?
3 . 1
AWS Says...AWS Says...
https://aws.amazon.com/lambda/3 . 2
A λ is a "handler" function YOU provideA λ is a "handler" function YOU provide
  
that runs in an AWS container "somewhere"that runs in an AWS container "somewhere"
so you focus on your code not plumbingso you focus on your code not plumbing
 
3 . 3
Python HandlerPython Handler
def my_handler(event, context):
message = 'Hello {} {}!'.format(event['first_name'],
event['last_name'])
return {
'message' : message
}
1
2
3
4
5
6
3 . 4
Reacts to Events...Reacts to Events...
(sync like HTTP or async like message on queue)
FunctionTrigger Does things to.. 3 . 5
All The Clouds Have ThemAll The Clouds Have Them
3 . 6
Cheap!Cheap!
3 . 7
Cheap!Cheap!
In Theory...
3 . 7
Cheap!Cheap!
In Theory...
First million invocations free...
Then $0.20/million after that...
3 . 7
Cheap!Cheap!
In Theory...
Then $0.0000166667 GB/Second after that...
First million invocations free...
Then $0.20/million after that...
400,000 GB-Seconds free...
Plus
3 . 7
Cheap!Cheap!
In Theory...
Then $0.0000166667 GB/Second after that...
First million invocations free...
Then $0.20/million after that...
400,000 GB-Seconds free...
Plus
Plus
Other AWS Costs (Databases, Data
Transfer...)
3 . 7
Mo RAM Mo $Mo RAM Mo $
https://aws.amazon.com/lambda/pricing/3 . 8
Pricing is "complicated"...Pricing is "complicated"...
https://medium.com/@zackbloom/serverless­pricing­and­costs­aws­lambda­and­lambda­edge­169bfb58db75
Just Lambda Lambda + API GW
263 Billiable Line Items Per Region Just for Lambda before you add the "other stuff"
3 . 9
Node HandlerNode Handler
exports.myHandler = function(event, context, callback) {
callback(null, "some success message");
// or
// callback("some error type");
}
1
2
3
4
5
3 . 10
Old HacksOld Hacks
https://aws.amazon.com/lambda/faqs/
exports.myHandler = function(event, context, callback) {
const execFile = require('child_process').execFile;
execFile('./myprogram', (error, stdout, stderr) => {
if (error) {
callback(error);
}
callback(null, stdout);
});
}
1
2
3
4
5
6
7
8
9
First Go apps would use this to run any
Amazon Linux compatible binary/shell script:
3 . 11
Go HandlerGo Handler
type MyEvent struct {
Name string `json:"name"`
}
func HandleRequest(ctx context.Context, name MyEvent)
(string, error) {
return fmt.Sprintf("Hello %s!", name.Name ), nil
}
1
2
3
4
5
6
7
Eventually Go got official support:
3 . 12
Supported LanguagesSupported Languages
https://aws.amazon.com/lambda/faqs/3 . 13
Cold StartCold Start
REPORT RequestId: 6f127cc4-c2d7-4422-9490-774092cf5042 Duration:
1.36 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory
Used: 35 MB Init Duration: 28.56 ms
1
REPORT RequestId: 6ad595b5-d679-42e2-b790-ab48811cf9cb Duration:
0.87 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory
Used: 35 MB
1
First invocation add Startup Time
Additional runs don't incur overhead
3 . 14
Always logs to CloudwatchAlways logs to Cloudwatch
Each instance gets its own Log
Stream in Cloudwatch Logs
https://aws.amazon.com/cloudwatch/pricing/
Don't be noisy,
CWL are $$$$
3 . 15
First Try...First Try...
https://github.com/srijs/rust­aws­lambda
First Rust Lambdas were
pretending to be Go binaries
4 . 1
Became AWS Open SourceBecame AWS Open Source
ProjectProject
https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/4 . 2
Events Survived...Events Survived...
https://github.com/LegNeato/aws­lambda­events4 . 3
Building off the Golang SDKBuilding off the Golang SDK
type S3Bucket struct {
Name string `json:"name"`
OwnerIdentity S3UserIdentity `json:"ownerIdentity"`
Arn string `json:"arn"`
}
1
2
3
4
5
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct S3Bucket {
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
pub name: Option<String>,
#[serde(rename = "ownerIdentity")]
pub owner_identity: S3UserIdentity,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
pub arn: Option<String>,
}
1
2
3
4
5
6
7
8
9
10
11
https://github.com/aws/aws­lambda­go/tree/master/events
https://github.com/LegNeato/aws­lambda­events/tree/master/aws_lambda_events_codegen
4 . 4
Well Documented AWS APIsWell Documented AWS APIs
and Eventsand Events
https://docs.aws.amazon.com/lambda/latest/dg/lambda­services.html
{
"Records": [
{
"eventVersion": "2.1",
"eventSource": "aws:s3",
"awsRegion": "us-east-2",
"eventTime": "2019-09-03T19:37:27.192Z",
"eventName": "ObjectCreated:Put",
"userIdentity": {
"principalId": "AWS:AIDAINPONIXQXHT3IKHL2"
},
"requestParameters": {
"sourceIPAddress": "205.255.255.255"
},
"responseElements": {
"x-amz-request-id": "D82B88E5F771F645",
"x-amz-id-2": "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo="
},
"s3": {
"s3SchemaVersion": "1.0",
"configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1",
"bucket": {
"name": "lambda-artifacts-deafc19498e3f2df",
"ownerIdentity": {
"principalId": "A3I5XTEXAMAI3E"
},
"arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df"
},
"object": {
"key": "b21b84d653bb07b05b1e6b33684dc11b",
"size": 1305107,
"eTag": "b21b84d653bb07b05b1e6b33684dc11b",
"sequencer": "0C0F6F405D6ED209E1"
}
}
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
4 . 5
https://www.rusoto.org/usage­and­example.html
AWS SDK in RustAWS SDK in Rust
extern crate rusoto_core;
extern crate rusoto_dynamodb;
use std::default::Default;
use rusoto_core::Region;
use rusoto_dynamodb::{DynamoDb, DynamoDbClient, ListTablesInput};
fn main() {
let client = DynamoDbClient::new(Region::UsEast1);
let list_tables_input: ListTablesInput = Default::default();
match client.list_tables(list_tables_input).sync() {
Ok(output) => {
match output.table_names {
Some(table_name_list) => {
println!("Tables in database:");
for table_name in table_name_list {
println!("{}", table_name);
}
}
None => println!("No tables in database!"),
}
}
Err(error) => {
println!("Error: {:?}", error);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Client for service
specific API
Build the
Request
Call the API
Process the
response
4 . 6
https://docs.rs/aws_lambda_events/0.2.5/aws_lambda_events/event/sqs/struct.SqsEvent.html
Sample SQS EventSample SQS Event
{
"Records": [
{
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"receiptHandle": "MessageReceiptHandle",
"body": "Hello from SQS!",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000",
"SenderId": "123456789012",
"ApproximateFirstReceiveTimestamp": "1523232000001"
},
"messageAttributes": {},
"md5OfBody": "7b270e59b47ff90a553787216d55d91d",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:us-east-1:123456789012:MyQueue",
"awsRegion": "us-east-1"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct SqsEvent {
#[serde(rename = "Records")]
pub records: Vec<SqsMessage>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct SqsMessage {
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
#[serde(rename = "messageId")]
pub message_id: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
#[serde(rename = "receiptHandle")]
pub receipt_handle: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
pub body: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
#[serde(rename = "md5OfBody")]
pub md5_of_body: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
#[serde(rename = "md5OfMessageAttributes")]
pub md5_of_message_attributes: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub attributes: HashMap<String, String>,
#[serde(deserialize with = "deserialize lambda map")]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
4 . 7
https://docs.rs/aws_lambda_events/0.2.5/aws_lambda_events/event/apigw/struct.ApiGatewayProxyRequest.html
Even HTTP is an EventEven HTTP is an Event
{
"body": "eyJ0ZXN0IjoiYm9keSJ9",
"resource": "/{proxy+}",
"path": "/path/to/resource",
"httpMethod": "POST",
"isBase64Encoded": true,
"queryStringParameters": {
"foo": "bar"
},
"multiValueQueryStringParameters": {
"foo": [
"bar"
]
},
"pathParameters": {
"proxy": "/path/to/resource"
},
"stageVariables": {
"baz": "qux"
},
"headers": {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pub struct ApiGatewayProxyRequest {
/// The resource path defined in API Gateway
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
pub resource: Option<String>,
/// The url path for the caller
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
pub path: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_string")]
#[serde(default)]
#[serde(rename = "httpMethod")]
pub http_method: Option<String>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub headers: HashMap<String, String>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
#[serde(rename = "multiValueHeaders")]
pub multi_value_headers: HashMap<String, Vec<String>>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
#[serde(rename = "queryStringParameters")]
pub query_string_parameters: HashMap<String, String>,
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
#[serde(rename = "multiValueQueryStringParameters")]
pub multi_value_query_string_parameters: HashMap<String, Vec<Strin
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
#[serde(rename = "pathParameters")]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
4 . 8
Rust HandlerRust Handler
pub trait Handler<E, O> {
fn run(&mut self, event: E, ctx: Context) ->
Result<O, HandlerError>;
}
#[derive(Debug, Clone)]
pub struct HandlerError {
msg: String,
backtrace: Option<backtrace::Backtrace>,
}
1
2
3
4
5
6
7
8
9
10
5 . 1
Digging Deeper - SerDe!Digging Deeper - SerDe!
pub type Handler<E, O> = fn(E, Context) -> Result<O, HandlerError>1
You implement:
E  JSON that you want to provide to your Lambda function as
input.
O It is the JSON representation of the object returned by the
Lambda function. This is present only if the invocation type is
RequestResponse.
5 . 2
Our Hander FunctionOur Hander Function
#[derive(Deserialize, Clone)]
struct CustomEvent {
#[serde(rename = "firstName")]
first_name: String,
}
#[derive(Serialize, Clone)]
struct CustomOutput {
message: String,
}
fn my_handler(e: CustomEvent, c: lambda::Context) -> Result<CustomOutput, HandlerError> {
if e.first_name == "" {
error!("Empty first name in request {}", c.aws_request_id);
return Err(c.new_error("Empty first name"));
}
Ok(CustomOutput {
message: format!("Hello, {}!", e.first_name),
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/5 . 3
main starts runtime w/handlermain starts runtime w/handler
#[macro_use]
extern crate lambda_runtime as lambda;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate simple_logger;
use lambda::error::HandlerError;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
simple_logger::init_with_level(log::Level::Info)?;
lambda!(my_handler);
Ok(())
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Stuff outside handler persists between runs on same lambda instance
(Think reusing connections or other "costly" things) 5 . 4
Cargo ChangesCargo Changes
[dependencies]
lambda_runtime = "^0.1"
serde = "^1"
serde_json = "^1"
serde_derive = "^1"
log = "^0.4"
simple_logger = "^1"
[[bin]]
name = "bootstrap"
path = "src/main.rs"
1
2
3
4
5
6
7
8
9
10
11
Lambdas using "provided" runttimes must be named:
bootstrap
5 . 5
So what can youSo what can you
build with this?build with this?
6 . 1
https://apievangelist.com/2017/11/06/a­simple­api­using­aws­rds­lambda­and­api­gateway/
Synchronous ApplicationSynchronous Application
Like a public API or marketing tracking pixel
6 . 2
https://github.com/aws­samples/lambda­refarch­webapp
More Complicated VersionMore Complicated Version
6 . 3
https://github.com/aws­samples/lambda­refarch­fileprocessing
Asynchronous File ProcessingAsynchronous File Processing
6 . 4
https://github.com/aws­samples/lambda­refarch­streamprocessing
Asynchronous Stream ProcessingAsynchronous Stream Processing
6 . 5
Manual/SAM/ServerlessManual/SAM/Serverless
6 . 6
On a Mac crossOn a Mac cross
compile with Dockercompile with Docker
$ docker pull clux/muslrust
$ docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release
$ zip -j hello-world.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
1
2
3
4
Can be kinda slow...
7 . 1
On a Mac crossOn a Mac cross
compile directlycompile directly
$ rustup target add x86_64-unknown-linux-musl
$ brew install filosottile/musl-cross/musl-cross
$ ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc
$ cat .cargo/config
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
$ cargo build --target=x86_64-unknown-linux-musl --release
$ file target/x86_64-unknown-linux-musl/release/bootstrap
.../bootstrap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically l
$ zip -j hello-world.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
^--  Correct!
<--  Takes 30 min - get coffee!
https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/7 . 2
Upload functionUpload function
with AWS CLIwith AWS CLI
$ aws lambda create-function 
--function-name hello-world 
--runtime provided 
--zip-file fileb://hello-world.zip 
--handler NOTUSED 
--role arn:aws:iam::123456789012:role/service-role/hello-world
1
2
3
4
5
6
7 . 3
Or deploy with fav toolsOr deploy with fav tools
resource "aws_lambda_function" "hello-world" {
function_name = "hello-world"
filename = "hello-world.zip"
source_code_hash = "${base64sha256(file("hello-world.zip"))}"
runtime = "provided"
handler = "NOTUSED"
role = aws_iam_role.hello-world.arn
}
1
2
3
4
5
6
7
8
7 . 4
Manually invokeManually invoke
$ aws lambda invoke 
--function-name hello-world 
--payload '{"firstName":"Steve"}' response.json
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
$ cat response.json
{"message":"Hello, Steve!"}
1
2
3
4
5
6
7
8
9
10
7 . 5
Invoke in AWS ConsoleInvoke in AWS Console
7 . 6
Must Grant PermissionsMust Grant Permissions
for Services to invokefor Services to invoke
$ aws lambda add-permission 
--function-name hello-world 
--action lambda:InvokeFunction 
--statement-id sqs 
--principal sqs.amazonaws.com
$ aws lambda get-policy --function-name hello-world | jq -r '.Policy' | prettier --stdin --parser json
{
"Version": "2012-10-17",
"Id": "default",
"Statement": [
{
"Sid": "sqs",
"Effect": "Allow",
"Principal": { "Service": "sqs.amazonaws.com" },
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:us-east-2:123456789012:function:hello-world"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Default rules are nobody has permissions
to do anything - even AWS Services 7 . 7
Or deploy with fav toolsOr deploy with fav tools
resource "aws_lambda_permission" "sqs-invokes-hello-world" {
function_name = aws_lambda_function.hello-world.function_name
action = "lambda:InvokeFunction"
statement_id = "sqs"
principal = "sqs.amazonaws.com"
}
1
2
3
4
5
6
7 . 8
Serverless Application ModelServerless Application Model
https://aws.amazon.com/serverless/sam/
Command Line Tools
Processes YAML-ish files into CloudFormation Templates
Builds, packages, uploads to s3 for deployment, deploys via
CloudFormation
AWS Only
Local Execution Environment via Docker
brew tap aws/tap
brew install aws-sam-cli
1
2
8 . 1
SAM Deploy TemplatesSAM Deploy Templates
https://aws.amazon.com/serverless/sam/
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Hello World Function
Resources:
HelloRustFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: sam-hello-world
Handler: NOTUSED
Runtime: provided
CodeUri: hello-world.zip
Role: arn:aws:iam::123456789012:role/service-role/hello-world
1
2
3
4
5
6
7
8
9
10
11
12
13
deploy-hello-world.yaml
8 . 2
SAM Packaging/S3SAM Packaging/S3
https://aws.amazon.com/serverless/sam/
sam package
--template-file deploy-hello-world.yaml 
--s3-bucket chicago-rust-s3 
--output-template-file cf-deploy-hello-world.yaml
1
2
3
4
5
cf-deploy-hello-world.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Hello World Function
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: sam-hello-world
Handler: NOTUSED
Runtime: provided
MemorySize: 128
CodeUri: s3://chicago-rust-s3/cebcadfd6fbdd2b1bc570f18ec1b562c
Role: arn:aws:iam::123456789012:role/service-role/hello-world
1
2
3
4
5
6
7
8
9
10
11
12
13 8 . 3
SAM Deploy CloudformationSAM Deploy Cloudformation
https://aws.amazon.com/serverless/sam/
sam deploy 
--template-file cf-deploy-hello-world.yaml 
--stack-name sam-hello-world 
--capabilities CAPABILITY_NAMED_IAM
1
2
3
4
8 . 4
SAM Local TestingSAM Local Testing
https://aws.amazon.com/serverless/sam/
$ sam local generate-event sqs receive-message
{
"Records": [
{
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"receiptHandle": "MessageReceiptHandle",
"body": "Hello from SQS!",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000",
"SenderId": "123456789012",
"ApproximateFirstReceiveTimestamp": "1523232000001"
},
"messageAttributes": {},
"md5OfBody": "7b270e59b47ff90a553787216d55d91d",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:us-east-1:123456789012:MyQueue",
"awsRegion": "us-east-1"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
8 . 5
SAM Local TestingSAM Local Testing
https://aws.amazon.com/serverless/sam/
Uses Docker lambci/lambda:provided container as 
runtime environment
8 . 6
Using Docker DirectlyUsing Docker Directly
https://hub.docker.com/r/lambci/lambda/
$ docker run --rm 
-v "$PWD/target/x86_64-unknown-linux-musl/release/":/var/task:ro,delegated 
lambci/lambda:provided 
handler 
'{"firstName": "Steve"}'
START RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64 Version: $LATEST
2020-01-27 17:29:55,923 INFO [lambda_runtime::runtime] Received new event with AWS req
2020-01-27 17:29:55,924 INFO [lambda_runtime::runtime] Response for a7ac181c-ded5-1b6
END RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64
REPORT RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64 Init Duration: 59.08 ms Duratio
{"message":"Hello, Steve!"}
1
2
3
4
5
6
7
8
9
10
11
12
Can still use Docker environments to test if using
other means of deployment (i.e. terraform, etc)
8 . 7
LocalStackLocalStack
https://localstack.cloud/
Mock AWS Services for local development
(override API endpoints to point at local Docker containers)
Free and Pro Tiers
(Pro gets more services, tools, and supports a great project)
Can also be used to
run your Lambdas
8 . 8
ServerlessServerless
 https://serverless.com/
Command Line Tools
Processes (more) YAML-ish files into CloudFormation
Templates - mixed syntax since cf functions can be used
Builds, packages, uploads to s3 for deployment
Multi-Cloud Support
Local Execution Environment via Docker
Paid PRO version includes:
dashboard
monitoring
alerts
ci/cd
rainbows
unicorns
9 . 1
Serverless vs SAMServerless vs SAM
 https://sanderknape.com/2018/02/comparing­aws­sam­with­serverless­framework/
Check out Sander's blog post for great
comparison
In the end its all just
json/yaml
representations
9 . 2
Other Resources ToOther Resources To
Read/WatchRead/Watch
10 . 1
Step FunctionsStep Functions
https://aws.amazon.com/getting­started/tutorials/create­a­serverless­workflow­step­functions­lambda/10 . 2
NEW: Lambda DestinationsNEW: Lambda Destinations
for simple flowsfor simple flows
https://aws.amazon.com/blogs/compute/introducing­aws­lambda­destinations/10 . 3
HTTP API GatewayHTTP API Gateway
https://aws.amazon.com/blogs/compute/announcing­http­apis­for­amazon­api­gateway/
Cheaper Option
Fewer Dials to Set
https://docs.aws.amazon.com/apigateway/latest/developerguide/http­api­vs­rest.htmlv1 vs v2:
10 . 4
AWS XRay TracingAWS XRay Tracing
https://docs.aws.amazon.com/xray/latest/devguide/aws­xray.html
Lots of moving parts!
Know what's going on!
 
Can configure lambda to have xray - just
use the SDK to send data
 
Or use some non-AWS alternative
(i.e. Espagon)
10 . 5
Map Reduce in λMap Reduce in λ
http://pywren.io/
S3 instead of HDFS
Lambdas instead of
Servers
10 . 6
Big Data with ServerlessBig Data with Serverless
https://www.slideshare.net/AmazonWebServices/building­big­data­applications­with­serverless­architectures­june­2017­aws­online­tech­talks10 . 7
Big Data on a Budget...Big Data on a Budget...
https://github.com/awslabs/lambda­refarch­mapreduce
|-----------------------|---------|---------|--------------|
| Technology | Scan 1a | Scan 1b | Aggregate 2a |
|-----------------------|---------|---------|--------------|
| Amazon Redshift (HDD) | 2.49 | 2.61 | 25.46 |
|-----------------------|---------|---------|--------------|
| Impala - Disk - 1.2.3 | 12.015 | 12.015 | 113.72 |
|-----------------------|---------|---------|--------------|
| Impala - Mem - 1.2.3 | 2.17 | 3.01 | 84.35 |
|-----------------------|---------|---------|--------------|
| Shark - Disk - 0.8.1 | 6.6 | 7 | 151.4 |
|-----------------------|---------|---------|--------------|
| Shark - Mem - 0.8.1 | 1.7 | 1.8 | 83.7 |
|-----------------------|---------|---------|--------------|
| Hive - 0.12 YARN | 50.49 | 59.93 | 730.62 |
|-----------------------|---------|---------|--------------|
| Tez - 0.2.0 | 28.22 | 36.35 | 377.48 |
|-----------------------|---------|---------|--------------|
| Serverless MapReduce | 39 | 47 | 200 |
|-----------------------|---------|---------|--------------|
Serverless MapReduce Cost:
|---------|---------|--------------|
| Scan 1a | Scan 1b | Aggregate 2a |
|---------|---------|--------------|
| 0.00477 | 0.0055 | 0.1129 |
|---------|---------|--------------|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
10 . 8
Honeycomb primary storageHoneycomb primary storage
https://www.honeycomb.io/blog/secondary­storage­to­just­storage/10 . 9
re:Invent 2018 - SRV409re:Invent 2018 - SRV409
Lambda Deep Dive
https://www.youtube.com/embed/QdzV04T_kec?enablejsapi=1
10 . 10
More Isn't Always BetterMore Isn't Always Better
Figure out the best bang for the buck -- don't guess, use data!
https://github.com/alexcasalboni/aws­lambda­power­tuning
And figure out your POST-free-tier costs before you go too far down this path
Google: lambda hidden costs 10 . 11
Thanks!Thanks!
Questions?Questions?
11

More Related Content

What's hot

(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cqlzznate
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stackBram Vogelaar
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015Fernando Hamasaki de Amorim
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2NAVER D2
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShellDale Lane
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceKonrad Malawski
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceAmazon Web Services
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...zznate
 
Stampede con 2014 cassandra in the real world
Stampede con 2014   cassandra in the real worldStampede con 2014   cassandra in the real world
Stampede con 2014 cassandra in the real worldzznate
 
Algebird : Abstract Algebra for big data analytics. Devoxx 2014
Algebird : Abstract Algebra for big data analytics. Devoxx 2014Algebird : Abstract Algebra for big data analytics. Devoxx 2014
Algebird : Abstract Algebra for big data analytics. Devoxx 2014Samir Bessalah
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchMichael Lange
 

What's hot (20)

Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 
Meetup cassandra for_java_cql
Meetup cassandra for_java_cqlMeetup cassandra for_java_cql
Meetup cassandra for_java_cql
 
About Data::ObjectDriver
About Data::ObjectDriverAbout Data::ObjectDriver
About Data::ObjectDriver
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2[263] s2graph large-scale-graph-database-with-hbase-2
[263] s2graph large-scale-graph-database-with-hbase-2
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShell
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
 
Stampede con 2014 cassandra in the real world
Stampede con 2014   cassandra in the real worldStampede con 2014   cassandra in the real world
Stampede con 2014 cassandra in the real world
 
Algebird : Abstract Algebra for big data analytics. Devoxx 2014
Algebird : Abstract Algebra for big data analytics. Devoxx 2014Algebird : Abstract Algebra for big data analytics. Devoxx 2014
Algebird : Abstract Algebra for big data analytics. Devoxx 2014
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job Dispatch
 

Similar to Byte Sized Rust

Middy.js - A powerful Node.js middleware framework for your lambdas​
Middy.js - A powerful Node.js middleware framework for your lambdas​ Middy.js - A powerful Node.js middleware framework for your lambdas​
Middy.js - A powerful Node.js middleware framework for your lambdas​ Luciano Mammino
 
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps_Fest
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Codemotion
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016Amazon Web Services Korea
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkLuciano Mammino
 
Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Andrea Scuderi
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020Matt Raible
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Curscatalyst
CurscatalystCurscatalyst
CurscatalystKar Juan
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale Subbu Allamaraju
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyFabio Akita
 
Serverless, The Middy Way - Workshop
Serverless, The Middy Way - WorkshopServerless, The Middy Way - Workshop
Serverless, The Middy Way - WorkshopLuciano Mammino
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaManish Pandit
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 

Similar to Byte Sized Rust (20)

Middy.js - A powerful Node.js middleware framework for your lambdas​
Middy.js - A powerful Node.js middleware framework for your lambdas​ Middy.js - A powerful Node.js middleware framework for your lambdas​
Middy.js - A powerful Node.js middleware framework for your lambdas​
 
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Going Serverless
Going ServerlessGoing Serverless
Going Serverless
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
 
Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
 
Us 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimesUs 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimes
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale
 
AWS Serverless Workshop
AWS Serverless WorkshopAWS Serverless Workshop
AWS Serverless Workshop
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
Serverless, The Middy Way - Workshop
Serverless, The Middy Way - WorkshopServerless, The Middy Way - Workshop
Serverless, The Middy Way - Workshop
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and Java
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 

More from Steve Hoffman

Nerd Out with Hadoop: A Not-So-Basic Introduction to the Platform
Nerd Out with Hadoop: A Not-So-Basic Introduction to the PlatformNerd Out with Hadoop: A Not-So-Basic Introduction to the Platform
Nerd Out with Hadoop: A Not-So-Basic Introduction to the PlatformSteve Hoffman
 
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018Steve Hoffman
 
Combating DNS Exfiltration in AWS - BSidesChicago 2018
Combating DNS Exfiltration in AWS - BSidesChicago 2018Combating DNS Exfiltration in AWS - BSidesChicago 2018
Combating DNS Exfiltration in AWS - BSidesChicago 2018Steve Hoffman
 
How Open Source is Transforming the Internet. Again.
How Open Source is Transforming the Internet. Again.How Open Source is Transforming the Internet. Again.
How Open Source is Transforming the Internet. Again.Steve Hoffman
 
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017flAWS Walkthrough - AWS Chicago Meetup 8/8/2017
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017Steve Hoffman
 
Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016Steve Hoffman
 
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015Enabling Microservices @Orbitz - DevOpsDays Chicago 2015
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015Steve Hoffman
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzEnabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzSteve Hoffman
 
Enabling Microservices @Orbitz - DockerCon 2015
Enabling Microservices @Orbitz - DockerCon 2015Enabling Microservices @Orbitz - DockerCon 2015
Enabling Microservices @Orbitz - DockerCon 2015Steve Hoffman
 
Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Steve Hoffman
 
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014Steve Hoffman
 
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...Steve Hoffman
 

More from Steve Hoffman (12)

Nerd Out with Hadoop: A Not-So-Basic Introduction to the Platform
Nerd Out with Hadoop: A Not-So-Basic Introduction to the PlatformNerd Out with Hadoop: A Not-So-Basic Introduction to the Platform
Nerd Out with Hadoop: A Not-So-Basic Introduction to the Platform
 
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018
Combating DNS Exfiltration in AWS - AWS Midwest Community Day 2018
 
Combating DNS Exfiltration in AWS - BSidesChicago 2018
Combating DNS Exfiltration in AWS - BSidesChicago 2018Combating DNS Exfiltration in AWS - BSidesChicago 2018
Combating DNS Exfiltration in AWS - BSidesChicago 2018
 
How Open Source is Transforming the Internet. Again.
How Open Source is Transforming the Internet. Again.How Open Source is Transforming the Internet. Again.
How Open Source is Transforming the Internet. Again.
 
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017flAWS Walkthrough - AWS Chicago Meetup 8/8/2017
flAWS Walkthrough - AWS Chicago Meetup 8/8/2017
 
Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016Enabling Microservice @ Orbitz - GOTO Chicago 2016
Enabling Microservice @ Orbitz - GOTO Chicago 2016
 
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015Enabling Microservices @Orbitz - DevOpsDays Chicago 2015
Enabling Microservices @Orbitz - DevOpsDays Chicago 2015
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzEnabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
 
Enabling Microservices @Orbitz - DockerCon 2015
Enabling Microservices @Orbitz - DockerCon 2015Enabling Microservices @Orbitz - DockerCon 2015
Enabling Microservices @Orbitz - DockerCon 2015
 
Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015Enabling Microservices @Orbitz - Velocity Conf 2015
Enabling Microservices @Orbitz - Velocity Conf 2015
 
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014
Chicago Hadoop User Group (CHUG) Presentation on Apache Flume - April 9, 2014
 
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...
TS-2614 - Jini™ Network Technology-Enabled Service-Oriented Architecture, A L...
 

Recently uploaded

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Byte Sized Rust

  • 1. Byte Sized RustByte Sized Rust Chicago Rust Meetup January 2020 -Steve Hoffman @bacoboy 1
  • 5. Less Stuff I Gotta Do...Less Stuff I Gotta Do... https://blogs.oracle.com/developers/functions­as­a­service:­evolution,­use­cases,­and­getting­started2 . 2
  • 6. Idle Servers Cost $$$Idle Servers Cost $$$ Type vCPU Mem GB Hourly on demand Monthly on demand Reserved 3yr all upfront t3.nano 2 0.5 $0.0052 $3.75 $1.41 t3.small 2 2 $0.0208 $14.98 $5.72 m5.large 2 8 $0.096 $69.12 $26.89 c5.large 2 4 $0.085 $61.20 $23.39 r5.large 2 16 $0.126 $90.72 $36.31 c5n.2xlarge 8 21 $0.432 $311.04 $119.67 c5n.18xlarge 72 192 $3.888 $2,799.36 $896.97 https://aws.amazon.com/ec2/pricing/on­demand/2 . 3
  • 8. What is a λ?What is a λ? 3 . 1
  • 10. A λ is a "handler" function YOU provideA λ is a "handler" function YOU provide    that runs in an AWS container "somewhere"that runs in an AWS container "somewhere" so you focus on your code not plumbingso you focus on your code not plumbing   3 . 3
  • 11. Python HandlerPython Handler def my_handler(event, context): message = 'Hello {} {}!'.format(event['first_name'], event['last_name']) return { 'message' : message } 1 2 3 4 5 6 3 . 4
  • 12. Reacts to Events...Reacts to Events... (sync like HTTP or async like message on queue) FunctionTrigger Does things to.. 3 . 5
  • 13. All The Clouds Have ThemAll The Clouds Have Them 3 . 6
  • 16. Cheap!Cheap! In Theory... First million invocations free... Then $0.20/million after that... 3 . 7
  • 17. Cheap!Cheap! In Theory... Then $0.0000166667 GB/Second after that... First million invocations free... Then $0.20/million after that... 400,000 GB-Seconds free... Plus 3 . 7
  • 18. Cheap!Cheap! In Theory... Then $0.0000166667 GB/Second after that... First million invocations free... Then $0.20/million after that... 400,000 GB-Seconds free... Plus Plus Other AWS Costs (Databases, Data Transfer...) 3 . 7
  • 19. Mo RAM Mo $Mo RAM Mo $ https://aws.amazon.com/lambda/pricing/3 . 8
  • 20. Pricing is "complicated"...Pricing is "complicated"... https://medium.com/@zackbloom/serverless­pricing­and­costs­aws­lambda­and­lambda­edge­169bfb58db75 Just Lambda Lambda + API GW 263 Billiable Line Items Per Region Just for Lambda before you add the "other stuff" 3 . 9
  • 21. Node HandlerNode Handler exports.myHandler = function(event, context, callback) { callback(null, "some success message"); // or // callback("some error type"); } 1 2 3 4 5 3 . 10
  • 22. Old HacksOld Hacks https://aws.amazon.com/lambda/faqs/ exports.myHandler = function(event, context, callback) { const execFile = require('child_process').execFile; execFile('./myprogram', (error, stdout, stderr) => { if (error) { callback(error); } callback(null, stdout); }); } 1 2 3 4 5 6 7 8 9 First Go apps would use this to run any Amazon Linux compatible binary/shell script: 3 . 11
  • 23. Go HandlerGo Handler type MyEvent struct { Name string `json:"name"` } func HandleRequest(ctx context.Context, name MyEvent) (string, error) { return fmt.Sprintf("Hello %s!", name.Name ), nil } 1 2 3 4 5 6 7 Eventually Go got official support: 3 . 12
  • 25. Cold StartCold Start REPORT RequestId: 6f127cc4-c2d7-4422-9490-774092cf5042 Duration: 1.36 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 35 MB Init Duration: 28.56 ms 1 REPORT RequestId: 6ad595b5-d679-42e2-b790-ab48811cf9cb Duration: 0.87 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 35 MB 1 First invocation add Startup Time Additional runs don't incur overhead 3 . 14
  • 26. Always logs to CloudwatchAlways logs to Cloudwatch Each instance gets its own Log Stream in Cloudwatch Logs https://aws.amazon.com/cloudwatch/pricing/ Don't be noisy, CWL are $$$$ 3 . 15
  • 27. First Try...First Try... https://github.com/srijs/rust­aws­lambda First Rust Lambdas were pretending to be Go binaries 4 . 1
  • 28. Became AWS Open SourceBecame AWS Open Source ProjectProject https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/4 . 2
  • 30. Building off the Golang SDKBuilding off the Golang SDK type S3Bucket struct { Name string `json:"name"` OwnerIdentity S3UserIdentity `json:"ownerIdentity"` Arn string `json:"arn"` } 1 2 3 4 5 #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct S3Bucket { #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] pub name: Option<String>, #[serde(rename = "ownerIdentity")] pub owner_identity: S3UserIdentity, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] pub arn: Option<String>, } 1 2 3 4 5 6 7 8 9 10 11 https://github.com/aws/aws­lambda­go/tree/master/events https://github.com/LegNeato/aws­lambda­events/tree/master/aws_lambda_events_codegen 4 . 4
  • 31. Well Documented AWS APIsWell Documented AWS APIs and Eventsand Events https://docs.aws.amazon.com/lambda/latest/dg/lambda­services.html { "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "us-east-2", "eventTime": "2019-09-03T19:37:27.192Z", "eventName": "ObjectCreated:Put", "userIdentity": { "principalId": "AWS:AIDAINPONIXQXHT3IKHL2" }, "requestParameters": { "sourceIPAddress": "205.255.255.255" }, "responseElements": { "x-amz-request-id": "D82B88E5F771F645", "x-amz-id-2": "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=" }, "s3": { "s3SchemaVersion": "1.0", "configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1", "bucket": { "name": "lambda-artifacts-deafc19498e3f2df", "ownerIdentity": { "principalId": "A3I5XTEXAMAI3E" }, "arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" }, "object": { "key": "b21b84d653bb07b05b1e6b33684dc11b", "size": 1305107, "eTag": "b21b84d653bb07b05b1e6b33684dc11b", "sequencer": "0C0F6F405D6ED209E1" } } } ] } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 4 . 5
  • 32. https://www.rusoto.org/usage­and­example.html AWS SDK in RustAWS SDK in Rust extern crate rusoto_core; extern crate rusoto_dynamodb; use std::default::Default; use rusoto_core::Region; use rusoto_dynamodb::{DynamoDb, DynamoDbClient, ListTablesInput}; fn main() { let client = DynamoDbClient::new(Region::UsEast1); let list_tables_input: ListTablesInput = Default::default(); match client.list_tables(list_tables_input).sync() { Ok(output) => { match output.table_names { Some(table_name_list) => { println!("Tables in database:"); for table_name in table_name_list { println!("{}", table_name); } } None => println!("No tables in database!"), } } Err(error) => { println!("Error: {:?}", error); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Client for service specific API Build the Request Call the API Process the response 4 . 6
  • 33. https://docs.rs/aws_lambda_events/0.2.5/aws_lambda_events/event/sqs/struct.SqsEvent.html Sample SQS EventSample SQS Event { "Records": [ { "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", "receiptHandle": "MessageReceiptHandle", "body": "Hello from SQS!", "attributes": { "ApproximateReceiveCount": "1", "SentTimestamp": "1523232000000", "SenderId": "123456789012", "ApproximateFirstReceiveTimestamp": "1523232000001" }, "messageAttributes": {}, "md5OfBody": "7b270e59b47ff90a553787216d55d91d", "eventSource": "aws:sqs", "eventSourceARN": "arn:aws:sqs:us-east-1:123456789012:MyQueue", "awsRegion": "us-east-1" } ] } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct SqsEvent { #[serde(rename = "Records")] pub records: Vec<SqsMessage>, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct SqsMessage { #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] #[serde(rename = "messageId")] pub message_id: Option<String>, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] #[serde(rename = "receiptHandle")] pub receipt_handle: Option<String>, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] pub body: Option<String>, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] #[serde(rename = "md5OfBody")] pub md5_of_body: Option<String>, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] #[serde(rename = "md5OfMessageAttributes")] pub md5_of_message_attributes: Option<String>, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] pub attributes: HashMap<String, String>, #[serde(deserialize with = "deserialize lambda map")] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 4 . 7
  • 34. https://docs.rs/aws_lambda_events/0.2.5/aws_lambda_events/event/apigw/struct.ApiGatewayProxyRequest.html Even HTTP is an EventEven HTTP is an Event { "body": "eyJ0ZXN0IjoiYm9keSJ9", "resource": "/{proxy+}", "path": "/path/to/resource", "httpMethod": "POST", "isBase64Encoded": true, "queryStringParameters": { "foo": "bar" }, "multiValueQueryStringParameters": { "foo": [ "bar" ] }, "pathParameters": { "proxy": "/path/to/resource" }, "stageVariables": { "baz": "qux" }, "headers": { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 pub struct ApiGatewayProxyRequest { /// The resource path defined in API Gateway #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] pub resource: Option<String>, /// The url path for the caller #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] pub path: Option<String>, #[serde(deserialize_with = "deserialize_lambda_string")] #[serde(default)] #[serde(rename = "httpMethod")] pub http_method: Option<String>, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] pub headers: HashMap<String, String>, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] #[serde(rename = "multiValueHeaders")] pub multi_value_headers: HashMap<String, Vec<String>>, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] #[serde(rename = "queryStringParameters")] pub query_string_parameters: HashMap<String, String>, #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] #[serde(rename = "multiValueQueryStringParameters")] pub multi_value_query_string_parameters: HashMap<String, Vec<Strin #[serde(deserialize_with = "deserialize_lambda_map")] #[serde(default)] #[serde(rename = "pathParameters")] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 4 . 8
  • 35. Rust HandlerRust Handler pub trait Handler<E, O> { fn run(&mut self, event: E, ctx: Context) -> Result<O, HandlerError>; } #[derive(Debug, Clone)] pub struct HandlerError { msg: String, backtrace: Option<backtrace::Backtrace>, } 1 2 3 4 5 6 7 8 9 10 5 . 1
  • 36. Digging Deeper - SerDe!Digging Deeper - SerDe! pub type Handler<E, O> = fn(E, Context) -> Result<O, HandlerError>1 You implement: E  JSON that you want to provide to your Lambda function as input. O It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse. 5 . 2
  • 37. Our Hander FunctionOur Hander Function #[derive(Deserialize, Clone)] struct CustomEvent { #[serde(rename = "firstName")] first_name: String, } #[derive(Serialize, Clone)] struct CustomOutput { message: String, } fn my_handler(e: CustomEvent, c: lambda::Context) -> Result<CustomOutput, HandlerError> { if e.first_name == "" { error!("Empty first name in request {}", c.aws_request_id); return Err(c.new_error("Empty first name")); } Ok(CustomOutput { message: format!("Hello, {}!", e.first_name), }) } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/5 . 3
  • 38. main starts runtime w/handlermain starts runtime w/handler #[macro_use] extern crate lambda_runtime as lambda; #[macro_use] extern crate serde_derive; #[macro_use] extern crate log; extern crate simple_logger; use lambda::error::HandlerError; use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { simple_logger::init_with_level(log::Level::Info)?; lambda!(my_handler); Ok(()) } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Stuff outside handler persists between runs on same lambda instance (Think reusing connections or other "costly" things) 5 . 4
  • 39. Cargo ChangesCargo Changes [dependencies] lambda_runtime = "^0.1" serde = "^1" serde_json = "^1" serde_derive = "^1" log = "^0.4" simple_logger = "^1" [[bin]] name = "bootstrap" path = "src/main.rs" 1 2 3 4 5 6 7 8 9 10 11 Lambdas using "provided" runttimes must be named: bootstrap 5 . 5
  • 40. So what can youSo what can you build with this?build with this? 6 . 1
  • 46. On a Mac crossOn a Mac cross compile with Dockercompile with Docker $ docker pull clux/muslrust $ docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release $ zip -j hello-world.zip ./target/x86_64-unknown-linux-musl/release/bootstrap 1 2 3 4 Can be kinda slow... 7 . 1
  • 47. On a Mac crossOn a Mac cross compile directlycompile directly $ rustup target add x86_64-unknown-linux-musl $ brew install filosottile/musl-cross/musl-cross $ ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc $ cat .cargo/config [target.x86_64-unknown-linux-musl] linker = "x86_64-linux-musl-gcc" $ cargo build --target=x86_64-unknown-linux-musl --release $ file target/x86_64-unknown-linux-musl/release/bootstrap .../bootstrap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically l $ zip -j hello-world.zip ./target/x86_64-unknown-linux-musl/release/bootstrap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ^--  Correct! <--  Takes 30 min - get coffee! https://aws.amazon.com/blogs/opensource/rust­runtime­for­aws­lambda/7 . 2
  • 48. Upload functionUpload function with AWS CLIwith AWS CLI $ aws lambda create-function --function-name hello-world --runtime provided --zip-file fileb://hello-world.zip --handler NOTUSED --role arn:aws:iam::123456789012:role/service-role/hello-world 1 2 3 4 5 6 7 . 3
  • 49. Or deploy with fav toolsOr deploy with fav tools resource "aws_lambda_function" "hello-world" { function_name = "hello-world" filename = "hello-world.zip" source_code_hash = "${base64sha256(file("hello-world.zip"))}" runtime = "provided" handler = "NOTUSED" role = aws_iam_role.hello-world.arn } 1 2 3 4 5 6 7 8 7 . 4
  • 50. Manually invokeManually invoke $ aws lambda invoke --function-name hello-world --payload '{"firstName":"Steve"}' response.json { "StatusCode": 200, "ExecutedVersion": "$LATEST" } $ cat response.json {"message":"Hello, Steve!"} 1 2 3 4 5 6 7 8 9 10 7 . 5
  • 51. Invoke in AWS ConsoleInvoke in AWS Console 7 . 6
  • 52. Must Grant PermissionsMust Grant Permissions for Services to invokefor Services to invoke $ aws lambda add-permission --function-name hello-world --action lambda:InvokeFunction --statement-id sqs --principal sqs.amazonaws.com $ aws lambda get-policy --function-name hello-world | jq -r '.Policy' | prettier --stdin --parser json { "Version": "2012-10-17", "Id": "default", "Statement": [ { "Sid": "sqs", "Effect": "Allow", "Principal": { "Service": "sqs.amazonaws.com" }, "Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:us-east-2:123456789012:function:hello-world" } ] } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Default rules are nobody has permissions to do anything - even AWS Services 7 . 7
  • 53. Or deploy with fav toolsOr deploy with fav tools resource "aws_lambda_permission" "sqs-invokes-hello-world" { function_name = aws_lambda_function.hello-world.function_name action = "lambda:InvokeFunction" statement_id = "sqs" principal = "sqs.amazonaws.com" } 1 2 3 4 5 6 7 . 8
  • 54. Serverless Application ModelServerless Application Model https://aws.amazon.com/serverless/sam/ Command Line Tools Processes YAML-ish files into CloudFormation Templates Builds, packages, uploads to s3 for deployment, deploys via CloudFormation AWS Only Local Execution Environment via Docker brew tap aws/tap brew install aws-sam-cli 1 2 8 . 1
  • 55. SAM Deploy TemplatesSAM Deploy Templates https://aws.amazon.com/serverless/sam/ AWSTemplateFormatVersion : '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Hello World Function Resources: HelloRustFunction: Type: AWS::Serverless::Function Properties: FunctionName: sam-hello-world Handler: NOTUSED Runtime: provided CodeUri: hello-world.zip Role: arn:aws:iam::123456789012:role/service-role/hello-world 1 2 3 4 5 6 7 8 9 10 11 12 13 deploy-hello-world.yaml 8 . 2
  • 56. SAM Packaging/S3SAM Packaging/S3 https://aws.amazon.com/serverless/sam/ sam package --template-file deploy-hello-world.yaml --s3-bucket chicago-rust-s3 --output-template-file cf-deploy-hello-world.yaml 1 2 3 4 5 cf-deploy-hello-world.yaml AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Hello World Function Resources: HelloWorldFunction: Type: AWS::Serverless::Function Properties: FunctionName: sam-hello-world Handler: NOTUSED Runtime: provided MemorySize: 128 CodeUri: s3://chicago-rust-s3/cebcadfd6fbdd2b1bc570f18ec1b562c Role: arn:aws:iam::123456789012:role/service-role/hello-world 1 2 3 4 5 6 7 8 9 10 11 12 13 8 . 3
  • 57. SAM Deploy CloudformationSAM Deploy Cloudformation https://aws.amazon.com/serverless/sam/ sam deploy --template-file cf-deploy-hello-world.yaml --stack-name sam-hello-world --capabilities CAPABILITY_NAMED_IAM 1 2 3 4 8 . 4
  • 58. SAM Local TestingSAM Local Testing https://aws.amazon.com/serverless/sam/ $ sam local generate-event sqs receive-message { "Records": [ { "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78", "receiptHandle": "MessageReceiptHandle", "body": "Hello from SQS!", "attributes": { "ApproximateReceiveCount": "1", "SentTimestamp": "1523232000000", "SenderId": "123456789012", "ApproximateFirstReceiveTimestamp": "1523232000001" }, "messageAttributes": {}, "md5OfBody": "7b270e59b47ff90a553787216d55d91d", "eventSource": "aws:sqs", "eventSourceARN": "arn:aws:sqs:us-east-1:123456789012:MyQueue", "awsRegion": "us-east-1" } ] } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 8 . 5
  • 59. SAM Local TestingSAM Local Testing https://aws.amazon.com/serverless/sam/ Uses Docker lambci/lambda:provided container as  runtime environment 8 . 6
  • 60. Using Docker DirectlyUsing Docker Directly https://hub.docker.com/r/lambci/lambda/ $ docker run --rm -v "$PWD/target/x86_64-unknown-linux-musl/release/":/var/task:ro,delegated lambci/lambda:provided handler '{"firstName": "Steve"}' START RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64 Version: $LATEST 2020-01-27 17:29:55,923 INFO [lambda_runtime::runtime] Received new event with AWS req 2020-01-27 17:29:55,924 INFO [lambda_runtime::runtime] Response for a7ac181c-ded5-1b6 END RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64 REPORT RequestId: a7ac181c-ded5-1b69-5f5e-a7f1f3d30c64 Init Duration: 59.08 ms Duratio {"message":"Hello, Steve!"} 1 2 3 4 5 6 7 8 9 10 11 12 Can still use Docker environments to test if using other means of deployment (i.e. terraform, etc) 8 . 7
  • 61. LocalStackLocalStack https://localstack.cloud/ Mock AWS Services for local development (override API endpoints to point at local Docker containers) Free and Pro Tiers (Pro gets more services, tools, and supports a great project) Can also be used to run your Lambdas 8 . 8
  • 62. ServerlessServerless  https://serverless.com/ Command Line Tools Processes (more) YAML-ish files into CloudFormation Templates - mixed syntax since cf functions can be used Builds, packages, uploads to s3 for deployment Multi-Cloud Support Local Execution Environment via Docker Paid PRO version includes: dashboard monitoring alerts ci/cd rainbows unicorns 9 . 1
  • 63. Serverless vs SAMServerless vs SAM  https://sanderknape.com/2018/02/comparing­aws­sam­with­serverless­framework/ Check out Sander's blog post for great comparison In the end its all just json/yaml representations 9 . 2
  • 64. Other Resources ToOther Resources To Read/WatchRead/Watch 10 . 1
  • 66. NEW: Lambda DestinationsNEW: Lambda Destinations for simple flowsfor simple flows https://aws.amazon.com/blogs/compute/introducing­aws­lambda­destinations/10 . 3
  • 67. HTTP API GatewayHTTP API Gateway https://aws.amazon.com/blogs/compute/announcing­http­apis­for­amazon­api­gateway/ Cheaper Option Fewer Dials to Set https://docs.aws.amazon.com/apigateway/latest/developerguide/http­api­vs­rest.htmlv1 vs v2: 10 . 4
  • 68. AWS XRay TracingAWS XRay Tracing https://docs.aws.amazon.com/xray/latest/devguide/aws­xray.html Lots of moving parts! Know what's going on!   Can configure lambda to have xray - just use the SDK to send data   Or use some non-AWS alternative (i.e. Espagon) 10 . 5
  • 69. Map Reduce in λMap Reduce in λ http://pywren.io/ S3 instead of HDFS Lambdas instead of Servers 10 . 6
  • 70. Big Data with ServerlessBig Data with Serverless https://www.slideshare.net/AmazonWebServices/building­big­data­applications­with­serverless­architectures­june­2017­aws­online­tech­talks10 . 7
  • 71. Big Data on a Budget...Big Data on a Budget... https://github.com/awslabs/lambda­refarch­mapreduce |-----------------------|---------|---------|--------------| | Technology | Scan 1a | Scan 1b | Aggregate 2a | |-----------------------|---------|---------|--------------| | Amazon Redshift (HDD) | 2.49 | 2.61 | 25.46 | |-----------------------|---------|---------|--------------| | Impala - Disk - 1.2.3 | 12.015 | 12.015 | 113.72 | |-----------------------|---------|---------|--------------| | Impala - Mem - 1.2.3 | 2.17 | 3.01 | 84.35 | |-----------------------|---------|---------|--------------| | Shark - Disk - 0.8.1 | 6.6 | 7 | 151.4 | |-----------------------|---------|---------|--------------| | Shark - Mem - 0.8.1 | 1.7 | 1.8 | 83.7 | |-----------------------|---------|---------|--------------| | Hive - 0.12 YARN | 50.49 | 59.93 | 730.62 | |-----------------------|---------|---------|--------------| | Tez - 0.2.0 | 28.22 | 36.35 | 377.48 | |-----------------------|---------|---------|--------------| | Serverless MapReduce | 39 | 47 | 200 | |-----------------------|---------|---------|--------------| Serverless MapReduce Cost: |---------|---------|--------------| | Scan 1a | Scan 1b | Aggregate 2a | |---------|---------|--------------| | 0.00477 | 0.0055 | 0.1129 | |---------|---------|--------------| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 10 . 8
  • 72. Honeycomb primary storageHoneycomb primary storage https://www.honeycomb.io/blog/secondary­storage­to­just­storage/10 . 9
  • 73. re:Invent 2018 - SRV409re:Invent 2018 - SRV409 Lambda Deep Dive https://www.youtube.com/embed/QdzV04T_kec?enablejsapi=1 10 . 10
  • 74. More Isn't Always BetterMore Isn't Always Better Figure out the best bang for the buck -- don't guess, use data! https://github.com/alexcasalboni/aws­lambda­power­tuning And figure out your POST-free-tier costs before you go too far down this path Google: lambda hidden costs 10 . 11