Skip to content

an experiment for letting serverless functions communicate with each other

Notifications You must be signed in to change notification settings

endersuu/SoftwareForwarder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This project implements a middleware working as a switch in AWS Lambda platform. Serverless function instances simply send messages with the receiver's id to an input interface, then the receiver, another serverless function instance, will receive messages automatically.

Software-Forwarder

Example

import softwareforwarder


def lambda_handler(event, context):
    @softwareforwarder.SoftwareForwarder(url=event['server_url'])
    def user_function(event, context):
        send: Callable = event['sen']
        receive: Callable = event['rec']
        uid: int = event['uid']
        peers: List[int] = event['peers']
        # send message to other instances
        message: Picklable = ...
        peer_id: int = ...
        send(peer_id, message)
        # receive message
        message = receive()
        ...

    user_function(event, context)
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!'),
    }

High view of Software-Forwarder

SoftwareForwarder

Simple Distributed PageRank

A task of simple distributed Pagerank is deployed as a demonstration of this project. Simple Distributed Algorithm

First, Partition an immense graph into small sub-tasks by leveraging metis. Then sub-tasks are sent to different workers, each worker takes the responsibility for its sub-task. During the Pagerank calculation, necessary states will be exchanged among workers in each iteration

What states of Pagerank need to be exchanged?

If we look at Pagerank equation (Ignore damping here, to make Pagerank calculation simpler)
equation
equation is Pagerank of vertex m in the iteration n

equation is any vertex that edge equation exists
e.g. equation

All the states a worker X needs to know are equation and equation . equation are constant, but equation will be updated in each iteration. Worse, worker X is probably not responsible for equation. So other workers have to send calculated equation back to worker X. E.g. worker A sends equation to worker B, worker C sends equation to worker B in iteration n.
As long as worker B has collected equation and equation, worker B can start iteration n+1.

Depolyment

equation preprocess.py, invoker.py, server.py can be deployed on different ec2 instances. client.py and softwareforwarder.py should be deployed to the same AWS Lambda function.

  1. Download data from Stanford Large Network Dataset Collection
  2. Put preprocess.py, invoker.py, server.py in an ec2 instance with enough performance, check configuration. Create a S3 bucket.
  3. Deploy client.py and softwareforwarder.py to AWS Lambda

Execution

  1. Run preprocess.py to generate dataset from raw data download from Stanford Large Network Dataset Collection, if preprocess.py can not parse the raw data, adjust it. Dataset generated will be uploaded to S3.
  2. Run server.py
  3. Run invoker.py

About

an experiment for letting serverless functions communicate with each other

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages