# Synchronous & Asynchronous Lambda

* Several AWS services, such as S3 and SNS, **invoke functions asynchronously to process events**.<br>
* When you invoke a function asynchronously, you don't wait for a response from the function code.<br>
* You hand off the event to Lambda and Lambda handles the rest.<br>
* You can configure how Lambda handles errors, and can send invocation records to a downstream resource to chain together components of your application.

![](https://1720417355-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPZQSmHKLs82TRAPZ78%2F-MPfEycT6FXpVy9kzYVA%2F-MPfTIIjKR6-xuFeiL0U%2Fimage.png?alt=media\&token=4e2f53d9-0a17-456a-bf67-c9614f711ae7)

* **Lambda supports the synchronous and asynchronous invocation** of a Lambda function.<br>

* You can **control the invocation type only when you invoke a Lambda function**.<br>

* **When you use an AWS service as a trigger, the invocation type is predetermined for each service**.<br>

* You have **no control over the invocation type that these event sources use when they invoke your Lambda function**.<br>

* **For short-term, Lambda is a very cost-effective choice**.<br>

* You can **use a Lambda function to process messages in an SQS queue**.<br>
  * **Lambda event source mappings support standard queues and FIFO queues**.<br>

* **With SQS, you can offload tasks from one component of your application** by sending them to a queue and **processing them asynchronously**.

* **Kinesis Data Streams is a real-time data streaming service** that **requires the provisioning of shards**.<br>
  * **With SQS only pay for what you use**, so it is a cheaper alternative.<br>

* **If you don't need real-time processing, replacing Kinesis Data Streams with SQS would lower costs**.
