API Gateway Async (Callback) Response to the Caller after processing using Lambda or Workers in EC2

We are making a rule engine in AWS. This engine is composed by a noSql Data Base Dynamos DB to storage the information, an api gateway to make the call and a lambda function to processing the call from the Api. Nothing new up to here.

The algorithm that we use is very efficient to evaluate the rules for every event and send back the response. This response gives the process id and the achieved events to the caller. Obviously the response time starts to increase if we add more rules or make an complex rules model. This is not good when we need to gives a fast response to an API.

To solve this problem we were thinking a solution returning a 200 OK response, and a process id to the caller and ant the same time invoking another lambda to processing all the rules (This is easy to do). The problem rise up when we want to inform to the caller the process results to trigger some actions on the caller side depending this response.

Is there any solution for this requirement? Such as a callback async url? Simulating a late response complementing the first response (200 OK)?

AWS Implementation Example:

AWS Implementation Example

I'm attaching an image with the architecture model, I would like to know some solutions to make the point 10 and 11.

Thank you All!!

Upvotes: 1

Views: 1454

Answers (1)

Kannaiyan
Kannaiyan

Reputation: 13035

I had a similar problem and this is how I solved it.

Steps:

  1. Collect the request and drop in kinesis, return with a process id
  2. Kinesis deliver request one by one to RulesEngine
  3. Rules Engine Evaluates the rules and writes the results back
  4. Results reader will read the results with processid from dynamodb and deliver it to the user

Architecture Diagram

Hope it helps.

Upvotes: 2

Related Questions