https://www.interviewbit.com/problems/design-cache/

Features:
This is the first part of any system design interview, coming up with the features which the system should support. As an interviewee, you should try to list down all the features you can think of which our system should support. Try to spend around 2 minutes for this section in the interview. You can use the notes section alongside to remember what you wrote.
Q: What is the amount of data that we need to cache?
A: Let's assume we are looking to cache on the scale of Google or Twitter. The total size of the cache would be a few TBs.
Q: What should be the eviction strategy?
A: It is possible that we might get entries when we would not have space to accommodate new entries. In such cases, we would need to remove one or more entries to make space for the new entry.
Q: What should be the access pattern for the given cache?
A: There are majorly three kinds of caching systems :
Write through cache : This is a caching system where writes go through the cache and write is confirmed as success only if writes to DB and the cache BOTH succeed. This is really useful for applications which write and re-read the information quickly. However, write latency will be higher in this case as there are writes to 2 separate systems.
Write around cache : This is a caching system where write directly goes to the DB. The cache system reads the information from DB incase of a miss. While this ensures lower write load to the cache and faster writes, this can lead to higher read latency incase of applications which write and re-read the information quickly.
Write back cache : This is a caching system where the write is directly done to the caching layer and the write is confirmed as soon as the write to the cache completes. The cache then asynchronously syncs this write to the DB. This would lead to a really quick write latency and high write throughput. But, as is the case with any non-persistent / in-memory write, we stand the risk of losing the data incase the caching layer dies. We can improve our odds by introducing having more than one replica acknowledging the write ( so that we don’t lose data if just one of the replica dies ).

Estimation:
This is usually the second part of a design interview, coming up with the estimated numbers of how scalable our system should be. Important parameters to remember for this section is the number of queries per second and the data which the system will be required to handle.
Try to spend around 5 minutes for this section in the interview.
Total cache size : Let's say 30TB as discussed earlier.

Q: What is the kind of QPS we expect for the system?
A: This estimation is important to understand the number of machines we will need to answer the queries. For example, if our estimations state that a single machine is going to handle 1M QPS, we run into a high risk of high latency / the machine dying because of queries not being answered fast enough and hence ending up in the backlog queue.
Again, let's assume the scale of Twitter / Google. We can expect around 10M QPS if not more.
Q: What is the number of machines required to cache?
A: A cache has to be inherently of low latency. Which means all cache data has to reside in main memory.
A production level caching machine would be 72G or 144G of RAM. Assuming beefier cache machines, we have 72G of main memory for 1 machine. Min. number of machine required = 30 TB / 72G which is close to 420 machines.
Do know that this is the absolute minimum. Its possible we might need more machines because the QPS per machine is higher than we want it to be.

[System Design] Design a distributed key value caching system, like Memcached or Redis的更多相关文章

  1. Design and Implementation of Global Path Planning System for Unmanned Surface Vehicle among Multiple Task Points

    Design and Implementation of Global Path Planning System for Unmanned Surface Vehicle among Multiple ...

  2. System.Drawing.Design.UITypeEditor自定义控件属性GetEditStyle(ITypeDescriptorContext context),EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...

  3. [Tomcat]无法使用tomcat6.exe启动服务解决办法, The system cannot find the Registry key for service 'tomcat7'

    重新配置环境变量后,可以使用startup.bat启动服务, 但是无法使用tomcat6.exe启动服务, 错误信息: [2011-03-10 18:51:49] [warn]  The system ...

  4. 通过spring.net中的spring.caching CacheResult实现memcached缓存

    通过spring.net中的spring.caching CacheResult实现memcached缓存1.SpringMemcachedCache.cs2.APP.config3.Program. ...

  5. NHibernate无法将类型“System.Collections.Generic.IList<T>”隐式转换为“System.Collections.Generic.IList<IT>

    API有一个需要实现的抽象方法: public IList<IPermission> GetPermissions(); 需要注意的是IList<IPermission>这个泛 ...

  6. 問題排查:System.BadImageFormatException: 未能加载文件或程序集“System.ServiceModel

    錯誤訊息如下: System.BadImageFormatException: 未能加载文件或程序集“System.ServiceModel, Version=3.0.0.0, Culture=neu ...

  7. HttpClient exception:ExceptionType:System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: Operation ca

    error msg: System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System. ...

  8. redis删除单个key和多个key,ssdb会落地导致重启redis无法清除缓存

    redis删除单个key和多个key,ssdb会落地导致重启redis无法清除缓存,需要针对单个key进行删除 删除单个:del key 删除多个:redis-cli -a pass(密码) keys ...

  9. The design of a distributed variant of Plato framework to support collaborated editing

    A first thought system architecture (pulling mode) is one that the server doesn't keep client inform ...

随机推荐

  1. CDN加速地址URL拿不到,显示“无法访问此网站”

    问题:CDN加速地址URL拿不到,显示“无法访问此网站” 原因:浏览器缓冲原因,导致拿到的content-encoding不是一个标准的值 解决方法: 1. 客户机器 ping一下访问的CDN加速域名 ...

  2. 大数据之路week05--day07(序列化、类加载器、反射、动态代理)

    遇到这个 Java Serializable 序列化这个接口,我们可能会有如下的问题 a,什么叫序列化和反序列化b,作用.为啥要实现这个 Serializable 接口,也就是为啥要序列化c,seri ...

  3. linux实操_shell预定义变量

    当前进程号: 运行后 后台最后一个进程号: 运行后

  4. 对Ajax的一些理解

    前言 在学习js的过程,我个人对于Ajax这项技术有着很深的印象,大概是因为它在我们网页开发过程中常见的交互里所发挥的作用太过于关键了吧,所以我想在这里好好地谈一些自己对它的理解. 概念理解 Ajax ...

  5. jQuery 操作一览表

    js获取方法要比jq的方法麻烦的多,主要是因为FF浏览器,因为FF浏览器也会把换行当作dom元素,下面跟着小编一起来学习js jquery获取当前元素的兄弟级 上一个 下一个元素的,需要的朋友一起来学 ...

  6. js校验密码必须包含字母大小写、数字

    校验密码必须包含字母大小写.数字 function checkPasswordNew(s){ var str=trim(s); //var reg = /^(?![A-Z]+$)(?![a-z]+$) ...

  7. 为什么说Redis是单线程的?

    一.前言 近乎所有与Java相关的面试都会问到缓存的问题,基础一点的会问到什么是“二八定律”.什么是“热数据和冷数据” ,复杂一点的会问到缓存雪崩.缓存穿透.缓存预热.缓存更新.缓存降级等问题,这些看 ...

  8. Oracle 后台进程(一)简介

    一.什么是Oracle数据库后台进程 为了时系统性能最好并能够协调多个用户,多进程系统使用了一些附加进程,成为后台进程. 在许多操作系统中,后台进程是在实例启动时自动建立的.一个Oracle实例可以包 ...

  9. MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory

    Creating file-per-table tablespaces outside the data directory 一. Data Directory 1.应对情况 当数据库所在空间不足的时 ...

  10. 【luogu4145】上帝造题的七分钟2 / 花神游历各国--区间开根-线段树

    题目背景 XLk觉得<上帝造题的七分钟>不太过瘾,于是有了第二部. 题目描述 "第一分钟,X说,要有数列,于是便给定了一个正整数数列. 第二分钟,L说,要能修改,于是便有了对一段 ...