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. Subordinates(贪心)

    题目大意: 一共有N个员工,其中最高领导人是编号s的人,每个人都只有一个直接领导,每个人都说出了自己领导的个数,问最少有几个人撒谎了. 思路: 合理的贪心是该把排最后的数变成缺少的数字,然后继续判断. ...

  2. 【Jenkins】忘记admin密码,可以用此方法帮你解决

    突然有一日发现自己忘记了jenkins的管理员密码,因为我一直登录的是另外一个非管理员账户.如果出现必须要使用管理员账户操作的,比如用户管理那里的,必须要管理员账号吧,这就尴尬了. 很方的我打开安装j ...

  3. swoole组件----mysql查询,插入数据

    注意!任何swoole函数都应该包含在go(function(){}) 经典查询方法query() go(function (){ $swoole_mysql = new Swoole\Corouti ...

  4. process 请求数据解析问题

    开发过程中发现ajax提交的数据无法被express正确的解析,主要的情况是这样的: // 浏览器端post一个对象 $.ajax({ url:"/save", type:&quo ...

  5. python自动华 (十六)

    Python自动化 [第十六篇]:JavaScript作用域和Dom收尾 本节内容: javascript作用域 DOM收尾 JavaScript作用域 JavaScript的作用域一直以来是前端开发 ...

  6. [Python自学] day-22 (1) (Session、CSRF、中间件)

    一.响应函数补充 三种返回响应的方式: return HttpResponse() return render() return redirect() HttpResponse: 除了能够返回字符串, ...

  7. python--第四天练习题

    #1.写函数,利用递归获取斐波那契数列中的第 10 个数,并将该值返回给调用者. def rec(a,b,dep=1): c = a + b if dep == 10: return c return ...

  8. 017_STM32程序移植之_AS608指纹模块

    STM32程序移植之AS608指纹模块 BUG说明: 硬件接线图如图所示 STM32引脚 指纹模块引脚 功能 3.3V 3.3V PA3 Tx PA2 Rx GND GND PA1 WAK 3.3V ...

  9. 一些有用的dll

    1.生成excel工具- EPPlus EPPlus.dll 2.生成word工具 - OpenXml DocumentFormat.OpenXml.dll 3.生成条形码工具 -  ZXing zx ...

  10. ueditor粘贴从word中copy的图片和文字 图片无法显示的问题

    我司需要做一个需求,就是使用富文本编辑器时,不要以上传附件的形式上传图片,而是以复制粘贴的形式上传图片. 在网上找了一下,有一个插件支持这个功能. WordPaster 安装方式如下: 直接使用Wor ...