Enrique
Enrique

Reputation: 4833

DynamoDB vs MySQL with Amazon Lambda

Is better to use DynamoDB with Lambda functions? (and if yes why? is the connection faster for some reason, maybe Lambda is designed to be more compatible with DynamoDB than MySQL or other databases?)

Because in Amazon Lambda official main page it makes reference to "DynamoDB" but not to "MySQL" or any other DB system:
https://aws.amazon.com/lambda/?nc1=h_ls
But I've found some tutorials tu connect MySQL from Lambda functions:
https://aws.amazon.com/blogs/database/query-your-aws-database-from-your-serverless-application/

NOTE: I'm not asking for the difference between DynamoDB and MySQL, relational vs non-relational DB, etc. This is about "Lambda and Databases". I need my Lambda function to read and write in some DB, I was thinking in MySQL first but because the only reference on the main page is to DynamoDB I'm a bit confused if I should choose that for some reason (performance, connection speed, or some other limitations).

Upvotes: 2

Views: 2415

Answers (2)

tamil
tamil

Reputation: 391

  • The AWS Dynamodb is complete managed service in which there is no minimum fee to use DynamoDB.you will pay only for the resources you provision.The AWS will takecare of millisecond latency at any scale.

  • When it comes to RDS MYSQL lets you to set up, operate and scale database on AWS.so you need to choose Multi A-Z or single A-Z deployment,Db class instance (micro, small, large, xlarge), storage etc.

  • Dynamodb is a distributed nosql solution designed for very large datastore/extremely high throughput nosql application, while RDS shines in smaller scale flexible traditional RDBMS for far more query and design flexibility.

  • For simple application and small data set you can go with Dynamodb, For large & complex application,go for Dynamodb if you look for high throughput or you can choose RDS if you look for cheaper option.

Upvotes: 0

Ashan
Ashan

Reputation: 19728

First of all AWS Lambda can connect with almost any database system.

There are several benefits when using Lambda with Dynamodb.

  • Using IAM policies for fine grained Access Control.
  • Both are Serverless offerings from AWS.
  • Simplicity in provisioning with AWS SAM
  • Dynamodb supports streams with Lambda for data driven workflows.

On the other hand using MySQL or any other database will require to place the database in a private subnet inside a VPC for security best practices. This will require placing Lambda functions also within a VPC that has a negative impact for performance since an Elastic Network Interface (ENI) needs to be attached to each Lambda function upon provisioning. This increases the cold start time of Lambda.

Its also challenging in managing stateful connections with other databases since Lambda is stateless which also impacts performance.

Upvotes: 5

Related Questions