-
Notifications
You must be signed in to change notification settings - Fork 946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New serverless pattern - dynamodb-lambda-elasticache #1735
New serverless pattern - dynamodb-lambda-elasticache #1735
Conversation
|
||
This project contains an event-driven microservices design pattern that is influenced by the [CQRS Pattern](https://microservices.io/patterns/data/cqrs.html). | ||
|
||
This pattern will write data into a DDB table and then create a stream from it. Lambda is then used to process the change events in the database and replicate the data in Elasticache for faster reads.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DDB -> change to DynamoDB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults. | ||
|
||
1. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error: Unable to upload artifact OrderPublisher referenced by CodeUri parameter of OrderPublisher resource.
Parameter CodeUri of resource OrderPublisher refers to a file or folder that does not exist /serverless-patterns/dynamodb-lambda-elasticache/OrderPublisher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
## Testing | ||
|
||
Invoke the OrderPublisher lambda function with the following payload, which will create the new order in the DynamoDB table. Note the order id received as a response from the Lambda function, which can be used to query the order data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
{"cliendId":"123456789","productId":"abc-def-ghi"} | ||
``` | ||
|
||
Invoke the OrderQueryService lambda function with the following payload. Replace the ```<order-id>``` with the Order Id returned by the previous Lambda function, to view the order details fetched from the Elasticache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
## Cleanup | ||
|
||
1. Delete the stack | ||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sam delete instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,78 @@ | |||
# CQRS pattern with Amazon DynamoDB, AWS Lambda and Amazon Elasticache for Redis | |||
|
|||
This project contains an event-driven microservices design pattern that is influenced by the [CQRS Pattern](https://microservices.io/patterns/data/cqrs.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im just dont know how this pattern makes it faster than a normal read to DynamoDB. Have you tested that? DynamoDB has a single milisecond performance and doesnt need to be behind a VPC to work. It would be great to get this pattern backed by some data before creating it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern focuses on microservices architecture use-cases where each microservice owns one or more sub-domains and a database dedicated to the domain. Due to this architecture pattern, it's no longer starightforward to implement queries and join data from multiple services. For example, for ordering service, each service is responsible for different writes like create-order service. And to "get order order details" we might need to join from multiple tables like order, payment, customer details etc. Since both reading and writing have different approaches, we can employ different strategies for each operation. CQRS (Command and Query Responsibility Segregation) uses “separation of concern” principle to separate the read database from the write database.
Commands perform mutation operations such as “create order” or “update order”. Queries perform ready-only operations such as “Get order details”. By this isolation, we can design purpose-built database based on the usage requirement. With the CQRS pattern, we could implement multiple denormalised views that make the application scalable and performant by simplifying the command query models because of its separation of concern principle.
In this pattern we are using DynamoDB for the high-performant writes and Elasticache for building materialised views for the application reads
87f96a6
to
f3c65cf
Compare
all review comments have been addressed |
Getting an error when doing sam deploy
|
@mavi888 just checking if you have performed a Maven build before doing sam deploy? If not, you would have to run the command "mvn clean install" to build the project which will create the jar file in the target folder, which can then be deployed using sam |
f3c65cf
to
826f46d
Compare
@mavi888 could you please provide an ETA for the code review, since its open since 3 weeks and is blocking our other tasks that are dependent on this repo. Thanks |
* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. | ||
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured | ||
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java and maven should be listed here
Just run the maven clean build and Im getting an error
Make sure that all the prerequistes are listed, maybe im missing something. |
@mavi888 it seems to be an issue with the Java version. the compiler version is 11, as mentioned in the pom. can we have a working session, so we can resolve all issues in a single go? |
826f46d
to
ed69f63
Compare
ed69f63
to
d377058
Compare
Unfortunately we don't have the resources to help troubleshoot this. Patterns should be simple, low-code, IaC frameworks to connect services. I would recommend submitting this as a pattern instead if you are able to fix the issues. |
Closing this PR, as we have published as a repo instead |
Issue #1734, if available:
Description of changes:
New serverless pattern submission for implementing CQRS pattern using AWS serverless services
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.