I am building a solution where IoT-devices send in measurement-data to an API that's hosted on AWS. For each measurement-type the user can set a threshold value; that when reached will trigger an alert to be sent out.
My design is based on events, so each new measurement that's received in the API generates a work item on an AWS SQS-queue. A lambda-function then processes the work-item and reads all the threshold-alerts for that particular device from a database, and checks if any of the received data has passed the threshold. If the threshold is passed, it sends out an alert email.
The API processes about 1000 requests each hour and the reading of all threshold-alerts from the database is getting expensive/time consuming.
So my question is if there is a better way to design this alert system? I was thinking of adding a cache-layer that will cache all threshold-limits since they don't change that often, but this means I have to use a distributed cache and still make a roundtrip via HTTP.
All suggestions welcome!