# random

Daniel Gato

01/28/2022, 10:50 PM
Random question: Our analytics collect endpoint is using an API to retrieve IP information (country, state, city). We pay for each request on that service. Generally a normal session will trigger about 5ish events. I’m thinking about some in memory database to store that IP payload for the next hour. What AWS serverless product would you use for that?

Simon Reilly

01/28/2022, 11:21 PM
If it has to be in memory, then elasticache or redis. If it's fine to be persisted, then DynamoDB with a TTL column. DynamoDB only guarantee a TTL delete will happen in 48 hrs so additionally making the timestamp part of the sort key and using it in your query will be what is required. We did this for UK addresses lookup in a national government service which would make a request per person. We had a 24 hour cache so we didn't need to call the directory, due to the fact there are about 34 million people registered.


01/29/2022, 8:17 AM
+1 for DynamoDB. Also you’d need to deploy ur Lambda into VPC to use elasticache/redi

Daniel Gato

01/29/2022, 10:46 AM
Elastic cache was my first idea. But the whole VPC plus allocating a machine type and have to scale it up isn't appealing. I'm not from serverless habits so at first a database for this sort of process seems too much. But I'll go with dynamodb!

Richard Simpson

01/29/2022, 11:34 PM
Redis Labs does have an a truly serverless Redis option and it's sorta available for AWS via the marketplace: That's still a lot of friction compared to DynamoDB though.

Daniel Gato

01/30/2022, 8:55 AM
I tried with DynamoDB and using TTL. That makes it incredibly simple to operate.