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 ...
随机推荐
- 跟我一起玩转FineUI之嵌套表格
最近一直在研究FineUI(http://www.fineui.com/),那么什么是FineUI呢,FineUI是基于 ExtJS 的专业 ASP.NET 控件库.创建 No JavaScript, ...
- 删除utorrent广告栏
自从utorrent附带广告栏后整个页面很难看,特别是右面下载详细列表变得支离破碎,今天实在是忍不了,网络搜索关键字“remove utorrent ads”,有效解决了问题. 具体如下:打开设置,选 ...
- ueditor 单独图片上传 转载
<body> <script type="text/javascript"> //这个是图片上传的,网上还有附件上传的 (function($) { var ...
- Cocos2d-JS事件处理机制
在很多图形用户技术中,事件处理机制一般都有三个重要的角色:事件.事件源和事件处理者.事件源是事件发生的场所,通常就是各个视图或控件,事件处理者是接收事件并对其进行处理的一段程序.事件处理机制中三个角色 ...
- 20141212--C#对象比较
static void Main(string[] args) { Class2 oo = new Class2(); oo.shu = ; oo.zi = "你"; Class2 ...
- AMQ学习笔记 - 19. 问题解决 - 控制Atomikos的日志输出
概述 在使用Atomikos为ActiveMQ提供JTA支持时,Atomikos在控制台打印了繁琐的日志.这里介绍如何控制Atomikos日志输出的粒度. 解决方案 基于以下三个事实: Atomiko ...
- 《asp.net mvc实战》笔记
对于大部分复杂的项目来说,可能不会在Models文件夹中放置你的模型.一般来说,最好的方法是将你的领域模型放在独立的项目中.这样其他应用程序可以在使用该项目而不必依赖于你的MVC应用程序.我们建议你只 ...
- conditon监视器接口
conditon监视器接口的实例对象必须通过Lock.newCondition()建立 立
- ZigBee HA示例程序分析
ZigBee协议栈中自带的HomeAutomation例程,虽然也是操作灯泡,但是,是通过ZCL来统一处理的,符合HA profile规范,互连互操作性较好.下面就简要分析以下ZCL的使用. 在任务数 ...
- Firefox 与 IE 对Javascript和CSS的区别
1. document.formName.item("itemName") 问题 说明:IE下,可以使用document.formName.item("itemName& ...