• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

腾讯大讲堂09 如何建设高性能网站

on

  • 1,527 views

 

Statistics

Views

Total Views
1,527
Views on SlideShare
1,527
Embed Views
0

Actions

Likes
1
Downloads
36
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Mysql conf 2005
  • Perlbal + memcached, both developed and shared by LJ team
  • 用了 packet sniffer 以后,下图显示如果用户没有 cache ( empty cache )的情况下读取 www.yahoo.com 的情况,可以看到其实只有 5 % 的时间花在了读取最开始的 html 上( 0.24 ),其他的 90% 时间花在了读取其他组件,例如 image , css 和 scripts 。
  • 我们又对其他大型网站做了测试,发现情况也很类似,大部分的时间都是花在了读取非 html 的其他组件。
  • 目前很多常用的性能优化技巧都集中在 html 生成( generating html )的部分( apache , C++, database , etc )但是实际上用户反应时间( response time )中只有 20% 是和这一部分相关的,所以我们还是将时间花在另外那 80% 的问题吧。
  • 2/8 定律
  • 结论:要让用户感觉网页反应最快, full cache 的优势很大
  • 有多少比例的用户在看主页的时候是 empty cache 有多少比例的 PV 是在 empty cache 的情况下产生的
  • 在 yahoo 的首页增加一个透明的小图 (1x1) , header 设置成 ” Expires: Thu, 15 Apr 2004 20:00:00 GMT , Last-Modified: Wed, 28 Sep 2006 23:49:57 GMT“ 。每天跟踪有多少比例的用户请求的这个小图,以及多少比例的 page view 中请求了这个小图 When the browser saves a component in its cache, it also saves the Expires and Last Modified values. Specifying an Expires date in the past forces the browser to request the image every time the page is viewed (with a few exceptions, such as when users click the browser’s “back” button to return to a page).
  • 从浏览器返回的 response 应该是 200 ( The browser does not have the image in its cache )或者 304 ( The browser has the image in its cache, but needs to verify the last modified date )。
  • On the first day of the experiment, no one had these images cached so the empty cache percentage was 100%. As the days passed more users had the images cached, so the percentages dropped until at some point it reached a constant steady state.
  • However, we found in our study that regardless of usage patterns, the percentage of page views with an empty cache is always ~20%. empty cache 的用户很可能比你想像中要多得多
  • The browser saves the “C” cookie on the user’s computer and sends it back in future requests. The “domain=.yahoo.com” specifies that the browser should include the cookie in future requests within the .yahoo.com domain and all its sub-domains. For example, if the user then visits finance.yahoo.com, the browser includes the “C” cookie in the request. Since an Expires attribute is not included in this example, the cookie expires at the end of the session.
  • Cookies 的大小也会对用户的反应时间造成很大影响,
  • While the data shows that the majority of page views aren’t impacted by a significant delay, it also shows that about 2% of page views have over 1500 bytes of cookies set at the .yahoo.com domain. Although 2% sounds insignificant, at Yahoo! this translates to millions of page views per day,
  • The data in Table 2 reflects only cookies set at the top domain levels to eliminate any cookies that may have been set by ads
  • A cookie set at the .yahoo.com domain impacts the response time for every Yahoo! page in the .yahoo.com domain that a user visits. 尽量减少不必要的 cookies 将 cookie 的 size 缩小 将 cookie 放到 domain level 的时候要谨慎小心,尽量不要影响其他的 sub domain 将 expiration date 合理设置
  • 既然对最终用户反应时间的最大影响来自与有多少个组件要被请求,为什么不能一次同时将他们下载完呢?主要是因为 http/1.1 的规范,浏览器每次只能同时从单个 hostname 下载两个组件
  • 但是如果一个网站将自己的组件平均地分配到两个 hostname 上,就会像下图
  • 那么到底是不是将组件分配到越多 hostname 越好呢,我们也做了测试。 The experiment measured an empty HTML document with 20 images on the page. The images were fetched from the same servers as those used by real Yahoo! pages. We ran the experiment in a controlled environment using a test harness that fetches a set of URLs repeatedly while measuring how long it takes to load the page on DSL.
  • We fetch 20 smaller-sized images (36 x 36 px) and 20 medium-sized images (116 x 61 px). To our surprise, increasing the number of aliases for loading the medium-size images (116 x 61px) worsens the response times using four or more aliases. Increasing the number of aliases by more than two for smaller-sized images (36 x 36px) doesn’t make much of an impact on the overall response time. On average, using two aliases is best. One possible contributor for slower response times is the amount of CPU thrashing on the client caused by increasing the number of parallel downloads. Another issue to consider is that DNS lookup times vary significantly across ISPs and geographic locations.
  • check out this image, used on Yahoo!'s homepage , or this one from Google's .
  • serving compressed HTML, CSS, client-side scripts, and any other type of text content. If you make XMLHttpRequests to services that return XML (or JSON, or plain text), make sure your server gzips as well
  • There's one gotcha when it comes to serving gzipped content: you must make sure that proxies do not get in your way. If an ISP's proxy caches your gzipped content and serves it to all of its customers, chances are that someone with a browser that doesn't support compression will receive your compressed content. To avoid this you can use the Vary: Accept-Encoding response header to tell the proxy to cache this response only for clients that send the same Accept-Encoding request header.
  • due to the nature of the scripts (they could potentially change anything on a page), browsers block all downloads when they encounters a
  • Look out for the Number One

腾讯大讲堂09 如何建设高性能网站 腾讯大讲堂09 如何建设高性能网站 Presentation Transcript