Amazon Simple Queue Service (SQS)
What is it? Amazon Simple Queue Service (SQS) is a managed,
message-queue service that enables us to build scalable and reliable
systems. Queues allow services to be decoupled. They can
communicate with each other asynchronously and are especially
useful when the throughput of the producing service is different from
the throughput of the consuming service. How does it work? SQS
provides a message-queue service. To use SQS, you need the
following components: Producer(s): Producers are responsible for
sending messages to a particular queue. Messages are stored in the
queue when they are sent by the producer. Consumer(s): Consumers
are responsible for retrieving and processing the messages from a
particular queue. Messages must be deleted by the consumer after
processing to ensure they aren't processed by any other consumers.
AWS Lambda What is it?
AWS Lambda is a service that lets developers run their code in the
cloud without having to host any servers. AWS Lambda is a
foundational service in the serverless paradigm where code is only
run when needed and developers only pay for the resources used.
Some of the reasons why AWS Lambda is one of the most popular
AWS services: No need to manage any servers Your application scales
automatically to handle the size of the workload How does it work?
AWS Lambda provides Functions as a service (FaaS) which
developers leverage to deploy functions that are run in response to
various events.
Key concepts
Function A function is code provided by the developer that runs in
AWS Lambda. A function processes the invocation events sent by
AWS Lambda. The function takes two arguments: Event object:
contains details about the invocation event. Context object: contains
information about the Lambda runtime, such as the function name,
memory limit etc. Execution environment Lambda provides a secure
and isolated runtime environment where your function is invoked.
The execution environment manages the resources required to run the
function. Additional information is available here. Runtime AWS
Lambda supports functions in multiple languages through the use of
runtimes. A runtime is chosen when a function is created. Additional
information about Lambda runtimes is available here. Trigger Lambda
functions are invoked as a response to certain actions. These actions
are called triggers. Lambda functions can be triggered by other AWS
services or your own applications. For e.g. you could trigger a
function for a new object in S3.
Resource Limits AWS Lambda has some resource limits which are
useful to know about. Some of the more common resource limits are:
Maximum execution time is 15 minutes Maximum memory allowed
is 3008 MB Maximum deployment package size is 50 MB (zipped)
Amazon DynamoDB What is it? Amazon DynamoDB is a managed
NoSQL database service. DynamoDB provides a simple API to store,
access, and retrieve data. Some of the reasons why DynamoDB is
popular: Schemaless: To create a new table, only the primary key
attributes need to be defined. On-demand capacity: DynamoDB scales
up/down automatically to handle the traffic How does it work? Key
concepts Tables A table is a collection of items. For e.g. you could
have an Employee table which stores information about every
employee at a company.
Items An Item is a single record in a table. An item is uniquely
identified by its Primary Key. In our previous example, an Employee
would be an item in the Employees table. The primary key or unique
identifier could be their Employee ID. Attributes An attribute is a field
or piece of data attached to an item. Examples of attributes attached to
an Employee item could be Name, Age, Office Location, etc. Primary
Key A primary key is a unique identifier and is used to uniquely
identify each item in the table. The primary key is the only required
attribute when creating a new table. It can not be empty or null. There
are two types of primary key: Partition key: This is a simple primary
key that is unique to each item in the table. Composite primary key:
This is a combination of partition and sort key, which together is
unique to each item in the table. Choosing the right primary key is
critical for the optimal performance of DynamoDB. This guide
provides good insight into how to choose the right key for your
application.
Secondary Index Secondary indices provide the ability to query a
table without using the primary key. An application generally benefits
from different access patterns and secondary indices enable efficient
data access without using the primary key. A secondary index consists
of a subset of attributes from the table. Provisioned & On-Demand
DynamoDB provides multiple pricing models: On-demand capacity:
The simplest or most straightforward pricing model. Pricing is based
on storage and requests. Provisioned capacity: In the provisioned
mode, read and write throughput capacity needs to be set for each
table. The read and write capacity specify the allowed operations per
second on the table.