'Asynchronous call to secondary database after returning data from primary database

I have an app which queries and returns data from DynamoDB. I want to use ElasticSearch to return the data with low latency. For some reason, ElasticSearch has been unreliable for me and I need to build a confidence level on ElasticSearch before fully transitioning to it.

I want to design an asynchronous system that first queries DynamoDB and returns the results and then makes a call to ElasticSearch in the background. I will log the requests that failed to be retrieved ElasticSearch and emit metrics to get the percentage of requests that failed. This will help me build confidence on ElasticSearch and possibly understand why it is failing for some queries, by understanding the relationship between failed queries.

My current proposed design: Create a lambda that queries ElasticSearch. Just before returning the response from DynamoDB, invoke the lambda and let it do the rest without waiting for the response from the lambda.

I don't have a lot of experience as a developer and I feel this approach is a bit amateurish. Is there a better design for this system? And if this is the right approach, please provide any feedback on this approach.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source