AWS Lambda long HTTP requests

I have an AWS Lambda function that calls the Algorithmia deep learning function , does some post-processing on the results, and then returns some data. The algorithm is provided by a python client that I am using, which makes it easy to submit an algorithm request on the Algorithmia framework.

The problem is as follows: when the Algorithm function is not called for some time, it is unloaded, and the first call to warm it up (cold start) takes some time, perhaps 30 seconds. If my Lambda function waits 30 seconds for a response when this happens when the Algorithm from cold start function is triggered, which would be very expensive and wasteful.

Is there a way to send an HTTP request to Lambda, and when the request is complete, the results will be piped to a new Lambda function so that the Lambda function doesn't have to wait all the time and waste resources? I wouldn't expect that since I'm not sure how this would practically work, does anyone have any other ideas on how to avoid waiting for a response and wasting Lambda resources?

Edit: In most cases (except, obviously, those where the Algorithm takes a while to boot from a cold start), latency is an issue and I cannot afford to increase the latency by doing some workaround method with Algorithm's function recording his answer to S3 (for example) and then running the lambda function.

+3


source to share


2 answers


Many of the algorithm functions that output the file allow you to specify the location of the output (often a parameter of the output

input JSON). If this assumption is correct for your case, you can write the Algorithmia function directly into the S3 bucket and run S3 a separate lambda function. The process will look like this:

  • Add S3 datasource to your Algorithmia account and configure the permissions according to your needs.

  • When calling the algorithm, set an output parameter to use this S3 data source, for example. "output": "s3://algorithm-name/sample-0001.png"

  • Configure the python Algorithmia client to ignore the output. This makes the request return immediately rather than waiting for the function to complete:



from Algorithmia.algorithm import OutputType

client.algo("username/algoname")
    .set_options(output=OutputType.void)
    .pipe(input)

      

+1


source


You can only create a Lambda function to call the Algorithm API from time to time, just to "keep warm" for your main processing function. You can use the Lambda scheduled event for this.



0


source







All Articles