开发者

Advice for website speed improvement?

开发者 https://www.devze.com 2023-01-24 01:39 出处:网络
I\'m almost done with this online library: http://gramma.ro I have grade C in YSlow but I\'m still dissatisfied with the average time consumed for this

I'm almost done with this online library: http://gramma.ro

I have grade C in YSlow but I'm still dissatisfied with the average time consumed for this website to be loaded (~7 seconds on my internet connection).

Maybe some of you will say that it works well but please compare with the speed of this one: http://www.libris.ro/ which is absolutely fast.

Do you have any advice for my application? Do you see critical places where I can improve which can seriously reduce the loading time of my site?

Database used: sql server 2008.

Language used: c# + asp.net

Hardware used: dedicated server, AMD 64 2.2 Ghz, 2 GB Ram

Thanks in advance...

UPDATE: I've used OutputCache (1h or 1 day) option for 4 user controls on my page 开发者_如何转开发which improved the site's loading with 3 seconds!!!


The easy answer would be to upgrade your hardware. However, I think there's probably a few simple points for improvement.

How's the memory usage? Do you cache the right things (something like an NHibernate SessionFactory shouldn't be new'ed up every request).

Maybe you can profile your webapp using a code profiler. I've successfully used DotTrace by JetBrains, which has a trial afaik. You simply select the application to profile, run a few requests and check the output for which methods take too much time. Then you can drill-down into the methods, to see which piece of your code takes too long exactly.

It's important to measure performance of your code, because you (usually) can't go by gut feeling alone.

[edit] Oh, one thing you probably already know: it's not a file size problem, which means it's also not a big viewstate problem.


Off the top of my head (and without seeing your code): I'm assuming you're building your lists from the database - what does that SQL look like? Have you optimized the query/queries? Are the table indexes set up properly? Also, something as simple as a with (nolock) where appropriate could make a huge difference.

The site takes a while to initially load for me, so I'm assuming that slow down is in your data retrieval.


It depends on so many things:

  1. round trip to database server
  2. compiled code or not
  3. large viewstate which results in huge download file
  4. a lot of images need to be downloaded

etc.

so it is difficult to tell without knowing some exact details about your application

suggestions:

  1. create a static host header for static resources such as images, js and css files
  2. compile the application (publish)
  3. optimize images for web
  4. use caching
  5. etc.


Browser-based tools like Yslow and Google Page Speed can only provide suggestions on the client-side problems.

From the timeline in Firebug, it appears that your problem is primarily on the server side. Without knowing the specs of your server (it may simply too heavily loaded), I'll have to assume your code is too slow.

Use profiling tools to find out which parts of your code are taking so long, and find ways to optimize it. Often you will find that the 80/20 rule applies, i.e. much of the runtime is taken up by only a small part of the code. This means the big issues are often easy to find and fix, but the more you fix the harder it is to further improve things. Profiling is usually the easiest way to find big bottlenecks, so start by fixing those.


This is an older question, but the answers were horrible if the websites haven't changed.

Libris is loading:

  • ~500KB of images
  • 140KB for JS
  • only 85 HTTP Requests
  • Total Download: 737KB

Gramma is loading:

  • ~1050KB of images
  • 275KB for JS
  • has 113 HTTP Requests
  • Total Download: 1537KB

Basically, your site is double the size in almost every aspect, plus you're using Flash, which is putting another hit on the client machine.

Using CSS Sprites and minifying your JS will certainly help. Mind you those figures were off the first load your site goes on to download more and more after a minute it was over 10MB, whereas the Libris site is more static.


  1. Instead of having your css in the style tag in the header, pull it out to an external css file.

  2. Pull any inline styling out to the css file as well, i.e. the div tags at the top with the mile long style attributes.

The reason it is taking so long to load is that you are trying to push too much text on one page. If you pull it out to external files, it caches it for next time as well as making your initial page load a lot quicker.


Cache expensive db requests, reduce size of images, load javascript librarys from cdn if possible


On top of the usual caching optimizations, you can use the new Image Optimizer (beta) - VS2010 extension which will reduce your image (png and jpg) file sizes without quality loss:

http://madskristensen.net/post/Image-Optimizer-%28beta%29-VS2010-extension.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消