Careercup - Google面试题 - 4807591515389952
2014-05-06 00:45
原题:
What would happen if you have only one server for a web cache (a web browser cache whose key is url and value is the loaded content of the webpage) but huge numbers of clients? And how would you solve it? Assume the cache is implemented with a hashmap and a linkedlist.
题目:你建了个网站,只有一台缓存服务器,服务器cache用的是拉链式的哈希表。如果客户端的并发量很大,怎么办呢?
解法:既然并发量很大,那就LRU cache吧。不过这个也治标不治本,因为大并发量的时候,cache会被不断刷新,等于没有。如果静态内容很多的话,浏览器端缓存能够减轻一部分服务器端缓存的压力。最简单直接的解决办法,就是掏钱给集群扩容了,多台机器好办事。
代码:
// http://www.careercup.com/question?id=4807591515389952
// What would happen if you have only one server for a web cache (a web browser cache whose key is url and value is the loaded content of the webpage) but huge numbers of clients? And how would you solve it? Assume the cache is implemented with a hashmap and a linkedlist.
// Answer: Well, I guess the cache can be considered a hash table, using chaining to handle collisions. LRU cache will be better. Despite the cache, with huge number of requests, the cache will be constantly flushed. It would still cause the server to crash. If the system is not so "dynamic", perhaps browser cache will help to reduce a little stress for the server-side cache.
int main()
{
return ;
}
Careercup - Google面试题 - 4807591515389952的更多相关文章
- Careercup - Google面试题 - 5732809947742208
2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find ...
- Careercup - Google面试题 - 5085331422445568
2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...
- Careercup - Google面试题 - 4847954317803520
2014-05-08 21:33 题目链接 原题: largest number that an int variable can fit given a memory of certain size ...
- Careercup - Google面试题 - 6332750214725632
2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval T ...
- Careercup - Google面试题 - 5634470967246848
2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization ...
- Careercup - Google面试题 - 5680330589601792
2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...
- Careercup - Google面试题 - 5424071030341632
2014-05-08 22:55 题目链接 原题: Given a list of strings. Produce a list of the longest common suffixes. If ...
- Careercup - Google面试题 - 5377673471721472
2014-05-08 22:42 题目链接 原题: How would you split a search query across multiple machines? 题目:如何把一个搜索que ...
- Careercup - Google面试题 - 6331648220069888
2014-05-08 22:27 题目链接 原题: What's the tracking algorithm of nearest location to some friends that are ...
随机推荐
- AngularJS学习小结
在刚学习AngularJS的时候觉得好像挺简单的,看见老师每次用很少的代码就做出用源生代码或者JQuery要用多行代码才做出的效果的时候觉得好像思路很简单,也很好写就写出来了,但是等到我们自己做的时候 ...
- 深入浅出ExtJS 第四章 表单与输入控件
4.1 制作表单 var form = new Ext.form.FormPanel({ title:'form', defaultType:'textfield', buttonAlign:'cen ...
- Ubuntu 15.04 无损扩展分区(目录)容量的方法 (无需格式化, 文件不丢失)
源 起 用了一段时间Ubuntu,碰到了UBuntu磁盘空间不足的问题, 最初我只给Ubuntu分配了30个G的空间, 昨天试用了一下VirtualBox安装了一个xp虚拟系统,用以解决Ubuntu下 ...
- github 学习笔记【一】
这几天在学习github ,其实学了主要用来管理自己的项目!因为要在家里和公司两头做! 所以就开始学习使用!目前熟练几个命令,其他的一边用一遍学吧!想一举成功应该是不太可能的! 反复记忆才能更好,据说 ...
- php 图片调整大小 封装类【转载】
<?php class ImageResize { private $image; private $img_des; private $image_type; private $permiss ...
- XenCenter删除SR失败解决方法
到CLI下 查SR的UUID xe sr-list SR的uuid=e0571e72-f6c5-1c9e-4ad8-9817b2331f47 FORGET SR xe sr-forget uuid=e ...
- oracle删除字段时候判断字段是否存在
declare v_count number; begin ) into v_count from all_tab_columns a where a.TABLE_NAME = 'XXX1' and ...
- 【python】python文件和目录操作方法大全(含实例)
转自:http://www.jb51.net/article/48001.htm 一.python中对文件.文件夹操作时经常用到的os模块和shutil模块常用方法.1.得到当前工作目录,即当前Pyt ...
- 6款基于SVG的HTML5CSS3应用和动画
1.CSS3/SVG质感背景小图标 镂空效果图标按钮 今天我们来分享一款用CSS3和SVG实现的质感背景小图标,鼠标滑过图标时出现镂空的效果,并且有质感背景的描边,效果非常不错. 在线演示 源码下载 ...
- 超赞值得一试的六款jQuery插件和CSS3应用
1.jQuery图片横向滚动插件 这是一款利用jQuery实现的图片横向滚动插件,我们可以设置任意数量的图片,然后点击左右箭头按钮即可分组浏览这些图片.这款jQuery图片插件的优势有两点,其一是可以 ...