I feel like our application has aspects that lend ...
# sst
g
I feel like our application has aspects that lend themselves to different databases. In some cases NoSQL (DynamoDB) seems like a perfect fit. In other cases (mainly transactional records), I feel like we would be better served with something like MySQL. In both cases, I would like for our API layer to utilize Redis as a caching mechanism to ease the load on the underlying database models. I am hoping (assuming) that something like this can be accomplished with SST. Thoughts?
t
Makes sense to use different databases depending on the domain. In terms of caching at the API layer there are a lot of approaches. I'd actually recommend first trying to put your API behind a cloudfront distribution and using cache control headers in your responses to control caching. This makes it so you don't need an additional service (redis) to manage and has the benefit of being standardized. Downside is you'll need to learn how cache control works in HTTP - something I have to relearn every time I need to implement it
g
I feel like the Cloudfront caching would be for html content and things like that. I am more talking about db content. Our app will be React.js, so only trips back to the cloud will be to grab json data from the database. In a Server environment, we have had success putting a Redis layer in so that our apps didn't make such a huge number of calls to actual database. If User A grabs a list of Countries from our Countries table, User B should be able to grab that same resultset from Redis rather than going to the actual database. The first call is 200ms (for example), the call to Redis is 6ms (for example).
t
If you want to implement caching at the API layer, Cloudfront caching will work for you whether it's HTML content or api responses or anything else. However if you're talking about implementing caching at the domain level I'd suggest implementing it per domain. You'll likely find you don't really need a caching layer in front of Dynamo given its scalability properties. Eg if you have a domain called
Country
with fields like
list()
and
get(id: string)
you can add the details of caching inside those functions so nothing calling it has to be aware of that
You can also checkout Upstash if you're willing to go outside of AWS. Pretty nice redis compatible service with low latency numbers + serverless pricing