Morten Bergfall
Morten Bergfall

Reputation: 2316

Why are ASP.NET pages so much slower on localhost than on the production server

The title pretty much sums it up, and I'm sure there's a perfectly valid explanation,
but it seems extremly odd that loading pages(after they're compiled) on my local computer seems to take forever, when the same code is blistering fast when "live".

I'm developing on Vista, IIS7, pretty ok hardware; while the server is a single machine, running Windows server 2003 and IIS6 on a Xeon <3 ghz and a gigabit line.

Of course, I understand that the web server is especially tailored for this kind of activity,
but it still seems strange that a machine serving up to 2-300 sessions at a time
(spread unevenly on ~5 .Net 2.0 applications) through a remote network(aka. the internet ;-)
is so much faster at presenting the pages, compared to running the code locally...

Just something that's been on my mind for a while...

UPDATE
Thanks a lot for the answers! Just thought I'd add a few points to the above:

Chose a random page from the project I'm currently working on, reloaded it completly a couple of times; locally I got it in about 4 seconds, compared to ~2 sec from the server. This was using FF and Firebug; using Opera I kind of felt there was a smaller difference but that's just my gut...

So I guess that leaves (as you mentioned) harddrives and the database connection... Just seems weird....

Upvotes: 11

Views: 6947

Answers (10)

Morten Bergfall
Morten Bergfall

Reputation: 2316

Well...after upgrading my machine ([email protected], 1TB >100mb/s search drive ) I see next to no difference even while having this computer do the works ( MS SQL server, IIS ) compared to the same page hosted at GoDaddy. When asking my inital question I had a somewhat lesser machine and compared it to my firms dedicated servers. So the anwer to the question is basically : They're not. Thanks for all of your answers though!

Upvotes: 3

Powerlord
Powerlord

Reputation: 88846

Are you actually running this through IIS7 or is it really running through Visual Studio's ASP.NET Development Server? If the latter, well... that right there is a huge reason. The ASP.NET Development Server is optimized to debug applications, not to run them quickly.

The other half the problem is that you didn't actually tell us the specs to your machine, only that it's "ok hardware," not usually a metric when it comes to computer. Vista does suck up some resources, both with its new display manager (for the Aero Glass desktop) and its tendency to pre-load commonly run applications into RAM.

It also sounds like you might be running the database server from your desktop as well, which sucks down more resources that the server machines won't, since they would most likely have (a) separate databases server(s).

Upvotes: 1

Aleksandar
Aleksandar

Reputation: 1339

Small million of things are in the game: faster network; better DB server running for a long time and having all queries already executed before; ... maybe is due to Vista :)

Upvotes: 0

Thomas Hansen
Thomas Hansen

Reputation: 5513

If you are using FireFox or Safari and you are on Windows Vista then you should disable IP version 6 since this messes with Vista in combination with WebDev and FireFox/Safari...

In FF type in about:config in the address bar, filter for "IPv6" and set enabled to FALSE!

This is a bug with IPv6 in Windows Vista and is a highly likely candidate for your troubles...

Upvotes: 8

user39603
user39603

Reputation: 2235

I'm surprised no-one has mentioned hard disks yet. The hard disk is often a typical bottleneck in a system, and desktop hard disks are often a lot slower than server (SCSI) disks. A desktop workstation could also have more processes running that are all using the disk at the same time, whereas server machines are more optimized to run the critical server processes only. But of course, it all depends on what exactly a machine is doing.

Upvotes: 1

Tom
Tom

Reputation: 7243

IF there are things stored on the server that the application needs to access, this will considerably slow things down - yes, I've seen places where there was a production server which hosted the only database system available to the whole company, for both production and development.

Upvotes: 0

Rune Grimstad
Rune Grimstad

Reputation: 36340

There are at least two reasons for this:

  • First, your local server is probably running the pages in debug mode with a debugger attached. This makes everything run slower

  • Second, each time you change your pages code or you restart your server all pages must be recompiled, and that takes some time.

On your production server the pages are compiled once and then the compiled version is served to all users, and you are probably not running in debug mode (I hope!).

Upvotes: 3

Ian G
Ian G

Reputation: 30224

Have you considered that it may be because of caching? i.e. pages on the production server are cached, and those on localhost are not cached.

I also agree with terjetyl it is possible that your localhost cannot find a linked file (eg javascript source file), your firewall could be blocking these....

Upvotes: 0

terjetyl
terjetyl

Reputation: 9565

You can also check if your site is trying to access unavailable content (unavailable urls) from your development machine. I've had this problem a couple of times before.

Upvotes: 2

Peter Gibbons
Peter Gibbons

Reputation: 159

There is no reason that the app shouldn't run fast locally in your described setup-- perhaps you have something else going on.

The first thing to look at would be what you are running on your dev box: Anti-virus or software firewalls can be a killer for these things, and you may want to test with that disabled.

Upvotes: 1

Related Questions