I have to show success
, failed
and rejected
status count of last 12 month including present month in our UI application. after lot of jvm tuning
, DB tuning
and refactoring
our API still taking 21 seconds
as my collection has 57 million records
. so I have been advised by our architect that I can precompute data and store in a separate collection
and I can calculate data of last one hour
and before sending it to end user just concatenate and sum it.
so he said data will be precomputed every hour. so suppose as of now it is 2:37 PM
. so data will be in precomuted collection till 2pm
. and if query gets fired at 2:37pm
then I can calculate data of 37 minutes
from real time collection. and before sending to end user we can add both the output. will it work?
I need some technical guidance or design here which can help me to design this solution. I am using java spring boot and mongodb.
I tried indexing, JVM tuning, code refactoring but nothing worked