views:

69

answers:

3

Using aspx and c# 3.5, vs2008.

Is there a rule of thumb for how many placeholders can be put on a web page before performance starts to deteriorate?

Any other concerns for using a lot of placeholders?

I am dynamically inserting controls (textboxes, checkboxes, expression validators, and buttons on to my page.

+1  A: 

There's no better answer than to try it for yourself. Use as many placeholders as you feel you need, go benchmark/profile the page code, then finally optimise accordingly using whatever technique is most suitable.

I quote Mr. Knuth:

Premature optimisation is the root of all evil!

Noldorin
I'd rather not reinvent the wheel.
Lill Lansey
@Lill Lansey: You're not reinventing anything. You're simply testing whether your hypothesis about this performance hit actually verifies with what you see.
Noldorin
+1  A: 

As long as you are typing them by hand, I would say that you are safe. If you start copying and pasting to get hundreds of place holders, you might get a measurable performance hit. When you reach several thousands you might get a noticable difference.

Guffa
+1  A: 

You're talking about a couple things here: placeholders, and all the other web controls that I assume you're putting inside these placeholders.

First of all, placeholders themselves are an extremely lightweight control that generate no additional markup and require very little processing by ASP.NET. So you should be able to put hundreds of these on a page while it still being quite fast.

However, the other controls you're putting inside each placeholder have the potential to produce a substantial amount of markup, viewstate, and of course more processing at the server side.

So in fact there is no standard answer for this as it really depends on your particular application and your audience. But there are a couple of things I can share:

1.) Take a look at the final rendered HTML size. Generally speaking I prefer to keep my public-facing HTML pages under 100 KB each and the home page under 20 KB when possible. Obviously it's not the end of the world to make an HTML page larger than this (many popular sites do). But much over this I'd at least consider splitting it up into multiple pages. High speed connections may be common today, but users are as impatient as ever -- so make your site fast. ;)

2.) There's always the question of scalability. To test this you might check out Microsoft's Web Application Stress Tool to try and simulate a peak-load situation. Then take a look at things like CPU, memory, and bandwidth usage to see if it's taking a big toll on the server. Again, if it's too big of a load you may want to consider splitting up the page.

Steve Wortham