DEV Community

Jaanchal1
Jaanchal1

Posted on

Redis-OM Lambda CDK

Overview of My Submission

This sample shows how to define a Lambda function which uses Redis-om via AWS Cloud Development Kit. This is a fork of prisma-lambda-cdk sample repo which replaces mysql/postgres with redis stack & prisma with Redis-om.

By this sample, you can see how a Lambda function which uses Redis OM can be deployed with CDK, how indexes can be created from Lambda, and how Redis OM works in Lambda.

Submission Category:

Minimalism Magicians

Language Used

Typescript

Link to Code

GitHub logo jaanchal1 / redis-om-lambda-cdk

Build and deploy a Lambda function with Redis OM by AWS Cloud Development Kit.

Redis-OM Lambda CDK Sample Application

This sample shows how to define a Lambda function which uses Redis-om via AWS Cloud Development Kit. This is a fork of prisma-lambda-cdk sample repo which replaces mysql/postgres with redis stack & prisma with Redis-om.

Redis OM is an open source object mapping, search etc library for Redis written in Typescript & very useful with its developer friendly API.

By this sample, you can see how a Lambda function which uses Redis OM can be deployed with CDK, how indexes can be created from Lambda, and how Redis OM works in Lambda.

Lambda Dashboard

AWS Lambda console output

How it works

Architecture

This sample consists of the following AWS services:

  • Amazon VPC
  • Redis Cloud (Amazon doesn't offer redis stack yet)
  • AWS Lambda

There're two Lambda functions:

  1. a function that reads and writes records from/to Redis handler.ts
  2. a function that sets up the index for Request entity migration-runner.ts

How the

Additional Resources / Info

Performance Benchmarks

I did the testing for both lambda functions by creating a url for them and then using k6 to test them.
Terminology:

  • VU Count: Number of concurrent requests being made
  • Duration: The duration for which test was run
  • Function type: Type of Lambda function executed
  • Prisma p95: p95 response time of prisma lambda function
  • Redis OM p95: p95 response time of redis om lambda function
  • Prisma p90: p90 response time of prisma lambda function
  • Redis OM 90: p90 response time of redis om lambda function
  • Prisma AVG: Avg response time of prisma lambda function
  • Redis OM AVG: Avg response time of redis om lambda function
VU Count Duration Function Type Prisma p95 Redis OM P95 Prisma p90 Redis OM p90 Prisma AVG Redis OM AVG Prisma Failed Reqs Redis OM Failed Reqs
10 30s Handler - Create Data 91.99 ms 67.56 ms 74.57 ms 60.4 ms 71.56 ms 57.16 ms 0 0
20 30s Handler - Create Data 89.35ms 65.7ms 74ms 59.19ms 70.56ms 54.73ms 26.60% 24.66%
20 30s Handler - Retrieve Data 698.56ms 516.26ms 600.07ms 394.06ms 547.38ms 344.9ms 0 0
20 30s Migration Runner 10.87s 3.16s 8.95s 2.93s 7.8s 2.67s 0 0

From these stats we can infer that there's a signifact performance boost when migrating schemas using Redis OM instead of Prisma.
Reads from Redis are also faster than Mysql & while not much but writes are faster as well.


Top comments (0)