Giter VIP home page Giter VIP logo

java-lambda-invoker's Introduction

Lambda Invoker Benchmark

This project contains test scripts to benchmark performance of the AWS Lambda invocation API usingversion 2.0 of the AWS Java SDK which is presently available as a preview release.

Building

Use Maven to build.

mvn package

Running

Make sure your AWS environment is configured

aws configure

Follow the prompts to configure your local aws client

Optional: If using a non-default profile set the environment variable, e.g.:

export AWS_DEFAULT_PROFILE=rise

Note that we have hardcoded the region to us-west-2. If you plan to run in a different region please edit the Java source code (class LambdaInvokeAsync).

Run the benchmark:

java -jar target/java-lambda-invoker-1.0-SNAPSHOT.jar [Function Name] [Sleep Argument] [Num Invocations] [Experiment Id]

Arguments are:

  • Function Name - name of the AWS Lambda function to execute
  • Sleep Argument - We pass a parameter "Sleep" = Sleep Argument to the function during invocation. The function may read this parameter and sleep in response.
  • Num Invocations - How many times to call the function
  • Experiment Id - We pass a parameter "ExperimentId" = Experiment Id to the function during invocation. The function may read this parameter and use it, e.g., in logs or other output.

For example:

java -jar target/java-lambda-invoker-1.0-SNAPSHOT.jar HelloPython .010 2 e200

This program will save the return values of function invocations in the file lambda_async_log.json.

Sample Lambda Source Code

Set up the function HelloPython as follows:

import json
import time
import random

lambda_id = '%016x' % random.getrandbits(64)

def lambda_handler(event, context):
    start_time = time.time()
    invocation_id = '%016x' % random.getrandbits(64)

    if "Sleep" in event:
        sleep_duration = float(event["Sleep"])
    else:
        sleep_duration = None

    if "ExperimentId" in event:
        experiment_id = event["ExperimentId"]
    else:
        experiment_id = None

    if sleep_duration:
        time.sleep(sleep_duration)
    end_time = time.time()
    return {
        "LambdaId" : lambda_id,
        "InvocationId" : invocation_id,
        "ExperimentId" : experiment_id,
        "StartTime" : start_time,
        "EndTime" : end_time,
        "SleepDuration" : sleep_duration,
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.