2

I am exploring using AWS Lambda through Laravel Vapor. Avoiding the use of Redis can save us ~$56/mo (t2.small at ~$24, NAT Gateway at ~$32).

Instead of Redis, I plan to use DynamoDB which is much cheaper. Pretty much same thoughts to this thread https://twitter.com/JackEllis/status/1246500143425146880

My question is, does it make sense to use DynamoDB as a cache layer on top of RDS or is the latency pretty much the same, which means I would be better off just relying on MySQL's internal caching?

For context, in Laravel there's a package called laravel-model-caching that caches query results. With Redis as the cache driver it makes sense, because you get super low latency compared to mysql even with mysql caching.

But now if I get rid of Redis, caching queries using the package might not make sense if the cache layer is another DB (Dynamo) anyway.

Is my thinking correct that DynamoDB and RDS latency is not much different?

jcsoriano
  • 121
  • 2
  • t2.anything is not intended to be used for a production system. Please review this URL content https://aws.amazon.com/ec2/instance-types/t2/ – Wilson Hauck Apr 21 '20 at 20:51

1 Answers1

0

Couple of notes...

  1. DynamoDB boasts a consistent millisecond latency, I doubt MySQL can achieve that. Both depend on the instance network performance of course, e.g. t2.something network is slower than c5n.something.

  2. Do you have only one Laravel node or more? If you have just one install Redis locally, no need for an extra EC2 instance.

  3. Redis ElastiCache doesn’t need NAT

  4. DynamoDB isn’t as cheap as it looks. The per query price may be small but using it as a cache may turn out to be quite expensive if you hammer it with lots of queries.

Hope that helps :)

MLu
  • 23,798
  • 5
  • 54
  • 81
  • Hi @MLu thanks for the post. For 1 can you share a link that says that about DynamoDB latency? I have been reading sub 10ms or sub 20ms but not 1ms. For 2: I'm using Lambda (through Vapor) so it's serverless (number of nodes depends on usage) For 3: Unfortunately Vapor says AWS requires a NAT Gateway when using Redis with Lambda (https://docs.vapor.build/1.0/resources/caches.html) For 4: thanks for the warning! Because of that I will double-check costs for the first month if it turns out to be more expensive than just paying for Redis + NAT – jcsoriano Apr 22 '20 at 02:27