educative.io

Educative

Why writing to Memcache is cheaper than writing to database?

I can understand, with DB we are writing to disk and Memcache remains in the memory.

How it’s related to cost?

1 Like

Hi @Pranit_Kothari!
The core idea behind the argument “cache writing has reduced cost compared to database” is split into two scenarios.
In Cloud Computing, the cost of updating the database (write operation) has an associated cost. This cost is saved/reduced if the change to the database is committed in batches. The Cloud Computing concept associated to this scenario is called Staging Area. Here any change is stored for some time before committing to the actual database.
The second scenario is directly committing the change to database instead of memory cache. This is feasible for systems which do not obey Cloud Computing architecture.
Hope this clears the question. Feel free to contact if there is any other issue.

1 Like