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 ...
随机推荐
- jQuery无缝循环开源多元素动画轮播jquery.slides插件
详细内容请点击 初始化插件: 一款基于jQuery无缝轮播图插件,支持图内元素动画,可以自定义动画类型$(".slideInner").slide({slideContainer: ...
- 【转载】MQTT学习笔记——MQTT协议体验 Mosquitto安装和使用
http://blog.csdn.net/xukai871105/article/details/39252653 0 前言 MQTT是IBM开发的一个即时通讯协议.MQTT是面向M2M和物联 ...
- 解决 Oracle em 无法打开的问题
重建em emca -deconfig dbcontrol db -repos drop 删除 emca -config dbcontrol db -repos create 创建 set ora ...
- Part 45 to 47 Talking about Enums in C#
Part 45 C# Tutorial Why Enums Enums are strongly typed constants. If a program uses set of integ ...
- Ubuntu14.04 Chromium 编译
1.下载depot_tools: 首先安装 git-core: sudo apt-get install git-core 执行命令: git clone https://chromium.googl ...
- 友盟分享--集成QQ和微信
随着社交工具的应用范围越来越广,分享一些内容的功能也开始要求实现了. 用得比较多的第三方,比如说友盟,比如说Share等等... 前几天刚用友盟写了集成QQ和微信客户端的功能,觉得有必要分享一下. 在 ...
- Application 统计在线人数
MVC 统计在线人数: protected void Application_Start() { Application[; AreaRegistration.RegisterAllAreas(); ...
- VxWorks 6.9 内核编程指导之读书笔记 -- ISRs和Watchdog Timer
中断服务程序 ISR 硬件中断处理是实时系统的关键,因为它是外部时间通知系统的方式. ISR亦称为中断处理函数,是对中断的正确响应.可以使用任何ISR连接到任何没有被VxWorks使用的中断上.当关联 ...
- 【转】C#异步编程及其同步机制
C#异步编程及其同步机制 本篇文章涵盖一下几部分内容: 1. 什么是异步编程,为什么会需要异步编程 2. .NET下的异步编程及其发展 3. .NET线程同步机制及线程间数据封送 4. 异步模式 5. ...
- C++ 11 之推导关键词
C++ 11新增了两个推导关键词,auto & decltype 1.区别 auto:用于推导变量类型: decltype: 用于推导表达式或者函数返回值 2.直接上代码 intmain() ...