If I:
Trigger an AWS Lambda deployment/update
Trigger a request to AWS Lambda prior to step #1 finishing
Will the request just hit the old lambda? Will it error out?
So far in my testing it seems like there is no "downtime", that it swaps out the old for the new almost instantly--although the first request on the new lambda does have to do a cold start.
You are correct. IIRC, each function invocation uses a specific function ARN, which changes when you update the function. When you invoke the function, you're using the new ARN, which invokes only the new version.
I believe it's possible to continue using the old function, using the old ARN explicitly (though you might not be able to do this from the Lambda console.)
For more info, see http://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html
It is now possible to have even more fine-grained control over how requests are handled between lambda function versions using the new traffic shifting feature announced recently at AWS's re:Invent conference:
https://aws.amazon.com/about-aws/whats-new/2017/11/aws-lambda-supports-traffic-shifting-and-phased-deployments-with-aws-codedeploy/
Related
GCP has a service called "GCP Cloud Scheduler". I can simply call an api to schedule a REST endpoint call in 45 minutes OR can call the api to schedule a recurring call every 24 hours.
What is the AWS equivalent here? I see a bunch of stuff with lambdas but don't really want the added complexity of needing a lamba (ie. GCP functions == lambdas and I don't need a GCP function to do what I need in GCP). A lambda would be 1 more point of failure I do not want to really monitor.
TWO main questions
is there an equivalent (preferably without lambdas)?
if lambdas is the only way to go, what is the service to call to make sure I can feed the REST endpoint through to the lambda to call? (I am really hoping I don't have to create a lambda PER job as that is even more work).
I am considering just using GCP's service and having it call our AWS endpoints as that may be a ton easier unless anyone knows of an AWS equivalent?
I have not tried anything yet as I can't quite find the correct API in AWS.
Create an EventBridge Rule with an API Destination
Unfortunately, there is no other equivalent in AWS if your endpoint cannot respond within 5s.
As you mentioned, you'd need a lambda to call your endpoint. This lambda can be triggered at a regular interval using EventBridge. When creating the rule, you can specify a custom input (that could be your endpoint).
I have two lambda functions in my AWS. One acts as a custom authorizer and the other acts as a notification service which calls the firebase FCM notification service.
When a request is made first time in a day to the notification lambda there is no response. The lambda does not work and hence does not call the firebase service.
It seemed like a cold start problem to me so I added the provisioned concurrency for both auth and notification lambda to 1 in the hope that it will work. But the problem persists.
Cloudwatch logs are of no help at all since nothing gets printed to it which I can use to figure out the issue. Either the authorizer lambda goes cold and does not response or the primary notification lambda goes cold and does not response or even both of them have issues.
After the first call to lambda fails any subsequent calls then work smoothly like a charm.
I do not want to install any plugin which will keep the lambda warm (not an option from the client) so is there some other way I can diagnose this problem and fix it?
I have been researching AWS Documentation on how to invoke lambda functions, and I've come across different ways to do that. Mainly, Lambda invocation is done by calling Invoke() function which can be used to invoke lambda functions synchronously or asynchronously.
Currently I am invoking my Lambda functions via HTTP Request (as REST API), but, HTTP Request times out after 30 seconds, while asynchronous calls as far as I know times out after 15min.
What are the advantages, besides time that I have already mentioned, of asynchronous lambda invocation compared to invoking lambda with HTTP Request. Also, what are best (recommended) ways to invoke lambdas in production? On AWS docs (SDK for Go - https://docs.aws.amazon.com/sdk-for-go/api/service/lambda/#InvokeAsyncInput) I see that InvokeAsyncInput and InvokeAsyncOutput have been depricated. So I am wondering how async implementation would actually look like.
Lambda really is about event-driven-computing. This means Lambda always gets triggered in response to an event. This event can originate from a wide range of AWS Services as well as the AWS CLI and SDK.
All of these events invoke the Lambda function and pass some kind of information in the form of an event and context object. How this event looks like depends on the service that triggered lambda. You can find more information about the context in this documentation.
There is no real "best" way to invoke Lambda - this mostly depends on your use case - if you're building a webservice, let API Gateway invoke Lambda for you. If you want to process new files on S3 - let S3 trigger Lambda. If you're just testing the Lambda function you can invoke it via the CLI. If you have custom software that needs to trigger a Lambda function you can use the SDK. If you want to run Lambda on a schedule, configure CloudWatch events...
Please provide more information about your use case if you require a more detailed evaluation of the available options - right now this is very broad.
I have an aws-lambda that I can not except downtime even for a little time that it takes to rebuild the stack.
I want to update the lambda trigger by adding a new SNS trigger to it. How do I do that with aws cli?
Check Using AWS Lambda with Amazon Simple Notification Service for cli example.
However, best practice would be to use Lambda Versioning and Aliases
Create new version of your function with updated configuration, test it, pre-warm it, and shift traffic to new version without any downtime.
Let's say my service is live in production using AWS Lambda in place? Now, I find that there is a bug in AWS Lambda, say I fix it and update lambda function, will some messages during the update would fail? How does it handle it internally?
Messages would continue going to the old version until the new version is fully deployed.
Since Lambda is distributed and stateless, no messages will be lost. Depending on the size of your Lambda function, it may take a few seconds for AWS to deploy, but it won't be accepting requests until it is ready to do so (has uploaded and validated successfully).
Worst case scenario, the moment you push the update, there may be several seconds where your Lambda is accepting requests on your old version.