如何提升网站性能 Website Performance Optimization

This article was written by Bob Feldbauer (@bobfeldbauer)

Optimizing website performance can dramatically increase conversions and loyalty, and decrease costs. Although it may be traditionally viewed as a responsibility of developers, the reality is that sysadmins are also often asked to work on website performance optimization.

The following is intended as a busy sysadmin's "crash course" in optimizing website performance.

As with trying to optimize any process, you should establish a baseline to measure any changes against. Install the Firebug Firefox plugin and Yahoo!'s YSlow add-on to measure your initial performance and verify improvements as you make changes. To see performance changes over time from a consistent external source, you can use free tools like Pingdom's Full Page Test or Octagate's SiteTimer. Also, Google's Webmaster Tools shows optimization suggestions based on the Page Speed tool, and crawl stats for the average time spent downloading a page from your site.

Yahoo!'s research shown in the table below shows 62-95% of the time required to load a page is spent making HTTP requests for non-HTML components like images, scripts, and stylesheets. See the following table for the time spent loading HTML vs non-HTML components for popular websites:

SiteTime Retrieving HTMLTime Elsewhere
Yahoo!10%90%
Google25%75%
MySpace9%91%
MSN5%95%
eBay5%95%
Amazon38%62%
YouTube9%91%
CNN15%85%

As the table indicates, reducing the number of HTTP requests can provide one of the biggest increases in performance. Aggregating CSS and JavaScript into as few files as possible and using CSS Sprites are two ways to reduce the number of HTTP requests.

In addition to reducing the number of HTTP requests, being able to load scripts in parallel instead of serially can improve performance. A newly developed tool calledHead JS can be used to load JavaScript scripts in parallel, while retaining execution order. This allows scripts to load without blocking other components from loading.

Most sites include static files that change infrequently (CSS, images, JavaScript, etc) and can benefit from appropriate HTTP caching. See the Google's Page Speed team'sguide to HTTP caching for more information.

Another important step in website performance optimization is configuring your web or application server to deliver gzip compressed content. On typical sites, gzipping content reduces text size by 75% and total size by 37%.

In addition to gzip compression, making images, scripts, and CSS files smaller also helps - especially when loading a site on lower bandwidth connections like mobile devices. Even if you gzip scripts or CSS files, you can "minify" them to further reduce their size by 5% or more. Yahoo!'s YUI Compressor can minify both CSS and JavaScript, while Yahoo's Smush.it can optimize image sizes without losing quality.

Although there are many other things you can do to optimize website performance, this "crash course" in optimization should get you started.

Further reading:

  1. Yahoo!'s Exceptional Performance team's

  1. Web Performance Best Practices by Google's Page Speed team

http://sysadvent.blogspot.com/2010/12/day-7-website-performance-optimization.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
You don't have to accept slow Ruby or Rails performance. In this comprehensive guide to Ruby optimization, you'll learn how to write faster Ruby code--but that's just the beginning. See exactly what makes Ruby and Rails code slow, and how to fix it. Alex Dymo will guide you through perils of memory and CPU optimization, profiling, measuring, performance testing, garbage collection, and tuning. You'll find that all those "hard" things aren't so difficult after all, and your code will run orders of magnitude faster. This is the first book ever that consolidates all the Ruby performance optimization advice in one place. It's your comprehensive guide to memory optimization, CPU optimization, garbage collector tuning, profiling, measurements, performance testing, and more. You'll go from performance rookie to expert. First, you'll learn the best practices for writing Ruby code that's easy not only on the CPU, but also on memory, and that doesn't trigger the dreaded garbage collector. You'll find out that garbage collection accounts for 80% of slowdowns, and often takes more than 50% of your program's execution time. And you'll discover the bottlenecks in Rails code and learn how selective attribute loading and preloading can mitigate the performance costs of ActiveRecord. As you advance to Ruby performance expert, you'll learn how profile your code, how to make sense out of profiler reports, and how to make optimization decisions based on them. You'll make sure slow code doesn't creep back into your Ruby application by writing performance tests, and you'll learn the right way to benchmark Ruby. And finally, you'll dive into the Ruby interpreter internals to really understand why garbage collection makes Ruby so slow, and how you can tune it up. What You Need: Some version of Ruby. The advice from this book applies to all modern Ruby versions from 1.9 to 2.2. 80% of the material will also be useful for legacy Ruby 1.8 users, and there is 1.8-specific advice as well. Table of Contents Chapter 1. What Makes Ruby Code Fast Chapter 2. Fix Common Performance Problems Chapter 3. Make Rails Faster Chapter 4. Profile Chapter 5. Learn to Optimize with the Profiler Chapter 6. Profile Memory Chapter 7. Measure Chapter 8. Test Performance Chapter 9. Think Outside the Box Chapter 10. Tune Up the Garbage Collector
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值