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的更多相关文章

  1. Careercup - Google面试题 - 5732809947742208

    2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find ...

  2. Careercup - Google面试题 - 5085331422445568

    2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...

  3. Careercup - Google面试题 - 4847954317803520

    2014-05-08 21:33 题目链接 原题: largest number that an int variable can fit given a memory of certain size ...

  4. Careercup - Google面试题 - 6332750214725632

    2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval T ...

  5. Careercup - Google面试题 - 5634470967246848

    2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization ...

  6. Careercup - Google面试题 - 5680330589601792

    2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...

  7. Careercup - Google面试题 - 5424071030341632

    2014-05-08 22:55 题目链接 原题: Given a list of strings. Produce a list of the longest common suffixes. If ...

  8. Careercup - Google面试题 - 5377673471721472

    2014-05-08 22:42 题目链接 原题: How would you split a search query across multiple machines? 题目:如何把一个搜索que ...

  9. Careercup - Google面试题 - 6331648220069888

    2014-05-08 22:27 题目链接 原题: What's the tracking algorithm of nearest location to some friends that are ...

随机推荐

  1. SQLServer排序时与读取的记录会影响到结果?

    这是在做程序的时候发现的,我用到了一个分页存储过程,在翻看第二页的时候发现结果竟然与第一页有很多重复的内容, 下面开始测试一下吧: 创建表 create table abc ( id int prim ...

  2. Centos与win8.1的双系统

      背景:win8.1系统已经安装完成,并在此基础之上使用光盘或者U盘来安装centos系统,最终实现双系统   1.         在win8.1系统下查看磁盘及分区情况   2.         ...

  3. ASP.NET 跨域获取JSON天气数据

    前几天做一个门户网站,在首页需要加载气象数据,采用了中央气象局的接口. 刚开始采用JSONP在前台跨域请求数据,没成功~ 后换成在c#后台请求数据返回... 前端代码: $(function () { ...

  4. UIAlertView[警告框] [代理协议型]UIActionSheet [表单视图][代理协议型]

    ////  ViewController.h//  UIAlertViewAndUIActionSheet////  Created by hehe on 15/9/21.//  Copyright ...

  5. think in java 第四版读书笔记 第一章对象导论

    很久没有碰过java了,为了项目需要以及以后找工作,还是有必要将think in java通读一遍.欢迎大家一起讨论学习 1.1抽象过程 面向对象语言的5个特性: 1.万物皆对象 任何事物都可以抽象为 ...

  6. javascript笔记——label包含的自定义按钮选中

    自定义按钮ui样式就是需要有label包含input以及带另外的标签作为新ui的载体,此时触发label的click的时候也会选中按钮,也就是说存在事件捕获,解决这个问题有如下方式 用到了 mouse ...

  7. Spring IOC整理

    示例展示 Spring的一大特点是利用配置的xml文件实现依赖注入. 所谓依赖注入是指把一个业务对象注入另一个业务对象,从而达到对象间的松耦合.(注意是业务对象哦!)依赖注入讲的通俗一点,就是让一个对 ...

  8. iOS开发零基础教程之生成git所需的SSH keys

    在我们github看到了一个不错的第三方库时,可能我们想把他git clone到本地,我们需要复制他的SSH URL,如下图: 复制完地址之后,我们需要打开终端,然后输入命令: git clone + ...

  9. WP开发笔记——WP7 SDK使用技巧

    俗话说的好,工欲善其事,必先利其器. 入门WP开发之前,免不了要先接触开发环境和开发工具.使用WP7 SDK进行开发,我们需要掌握SDK的一些实用技巧,以便我们的开发. 一.开启/关闭电脑键盘输入 W ...

  10. Materialized Views 物化视图 -基础篇

    Materialized Views 物化视图 -基础篇 http://blog.csdn.net/elimago/article/details/5404019