Animesh Gaitonde
Animesh Gaitonde

Reputation: 83

As distributed caching requires network call, isn't it beneficial to read directly from the DB in some cases?

I want to understand what is the benefit of running an in-memory cache instance on a separate server to lookup data in distributed caching. The application server will have to make a network call to get the data from Cache. Isn't network call adding to the latency while reading the data ? Wouldn't it make more sense to get the data directly from the database instance ?

Upvotes: 3

Views: 402

Answers (1)

vasha
vasha

Reputation: 136

Network calls are an order of magnitude faster than disk look-ups (less than 100 micros seconds RTT within adata center). Look-up from memory is also fairly fast (10-20 micro seconds per read). On other hand, databases often have to read from the disk and they maintain extra transaction meta-data and locks.

So caches provide higher throughput as well as better latencies. The final design depends on the type of databases and data access scenarios.

Upvotes: 4

Related Questions