views:

1003

answers:

7

I've read that it's unwise to install SQL Server and IIS on the same machine, but I haven't seen any evidence for that. Has anybody tried this, and if so, what were the results? At what point is it necessary to separate them? Is any tuning necessary? I'm concerned specifically with IIS7 and SQL Server 2008.

If somebody can provide numbers showing when it makes more sense to go to two machines, that would be most helpful.

+3  A: 

It's possible, yes.

A good idea for a production environment, no.

The problem that you're going to run in to is that a SQL Server database under substantial load is, more than likely, going to be doing heavy disk I/O and have a large memory footprint. That combination is going to tie up the machine, and you're going to see a performance hit in IIS as it tries to serve up the pages.

Justin Niessner
+6  A: 

Yes, it is possible and many do it.

It tends to be a question of security and/or performance.
Security is questioned as your attack surface is increased on a box that has both. Perhaps not an issue for you.

Performance is questioned as now your server is serving web and DB requests. Again, perhaps not an issue in your case.

Test vs. Production....

Many may feel fine in test environments but not production....

Again, your team's call. I like my test and production environments being as similar as possible if possible but that's my preference.

klabranche
I believe hanselminutes episode 134 and/or 135 revealed that SO was running on one server. Definitely doable, although Scott was a little horrified with the idea. :)
klabranche
+3  A: 

It's unwise in certain contexts... totally wise in others.

If your machine is underutilized and won't experience heavy loads, then there is an advantage to installing the database on the same machine, because you simply won't have to transfer anything across the network.

On the other hand, if one or both of IIS or the database will be under heavy load, they will likely start to interfere, and the performance gain of dedicated hardware for each will probably outstrip the loss of having to go over the network.

womp
+1  A: 

You certainly can. You will run into performance issues if, for example, you have large user base or if there are a lot of heavy query's being run against the DB. I have worked on several sites, usually hosted at 1and1, that run IIS and SQL Server (Express!) on the same box with thousands of users (hundreds concurrent) and millions of records in poorly designed tables, accessed via poorly written stored procedures and the user experience was certainly tolerable. It all comes down to how hard you plan on hitting the server.

Jason Kostempski
A: 

From my experience running SQL & IIS on my dev machine-- SQL tends to take all the memory it can get and starve everything else on the machien for memory, unless you give it a strict upper limit. For ASP.NET-- ASP.NET will only use so much memory per application and will hit that limit before physical memory limits are hit.

The optimization strategies are the same as for any app, try to put static files on a different drive from the db, and the ASP.NET temporary files somewhere other than the db drive. With some raid configurations that might not matter though.

MatthewMartin
+19  A: 

It is unwise to run SQL Server with any other product, including another instance of SQL Server. The reason for this recommendation is the nature of of how SQL Server uses the OS resources. SQL Server runs on an user mode memory management and processor scheduling infrastructure called SQLOS. SQL Server is designed to run at peak performance and assumes that is the only server on the OS. As such the SQL OS reserves all RAM on the machine for SQL process and creates a scheduler for each CPU core and allocates tasks for all schedulers to run, utilizing all CPU it can get, when it needs it. Because SQL reserves all memory, other processes that need memory will cause SQL to see memory pressure, and the response to memory pressure will evict pages from buffer pool and compiled plans from the plan cache. And since SQL is the only server that actually leverages the memory notification API (there are rumors that the next Exchange will too), SQL is the only process that actually shrinks to give room to other processes (like leaky buggy ASP pools). This behavior is also explained in BOL: Dynamic Memory Management.

A similar pattern happens with CPU scheduling where other processes steal CPU time from the SQL schedulers. On high end systems and on Opteron machines things get worse because SQL uses NUMA locality to full advantage, but no other processes are usually not aware of NUMA and, as much as the OS can try to preserve locality of allocations, they end up allocating all over the physical RAM and reduce the overall throughput of the system as the CPUs are idling on waiting for cross-numa boundary page access. There are other things to consider too like TLB and L2 miss increase due to other processes taking up CPU cycles.

So to sum up, you can run other servers with SQL Server, but is not recommended. If you must, then make sure you isolate the two server to your best ability. Use CPU affinity masks for both SQL and IIS/ASP to isolate the two on separate cores, configure SQL to reserve less RAM so that it leaves free memory for IIS/ASP, configure your app pools to recycle aggressively to prevent application pool growth.

Remus Rusanu
@Remus Rusanu - Many like your answer including myself. Good technical info! :) I think the answer often relies on the situation. We used the single server technique because of simplicity, cost and the resources in our situation did not require the separation. When those requirement changed we changed but it took almost 8 years for that to happen. I think many small to medium shops may find themselves in the same situation. Thoughts?
klabranche
@klabranche: The technical info I provided should help configuring a mixed server so that the memory, I/O and CPU are partitioned as best as possible between the SQL and IIS/ASP. On long term: IIS/ASP can easily scale out, while SQL can easily scale up. So the natural tendency is to move IIS/ASP on farms or 'gardens' of cheap comodity hardware, while SQL stays alone on the biggest machine the org has at its disposal.
Remus Rusanu
@Remus Rusanu - I agree. Would you agree that for small / medium size shops / apps that single server situations are not necessarily a bad way to go?
klabranche
Sometimes you must play with the cards you're dealt. But imho any shoppe that makes its living from its web presence should separate the two.
Remus Rusanu
@Remus Rusanu - Good point on the "makes its living from web presence". I would agree on that one. Our situation is not like that. It's our company intranet.
klabranche
Intranets are totaly different story. They live by the budget crumbs and is often hard to justify an extra server.
Remus Rusanu
I believe hanselminutes episode 134 and/or 135 revealed that SO was running on one server. Definitely doable, although Scott was a little horrified with the idea. :)
klabranche
If the load on the system is low and the web (or middle tear) code makes lots of small requests to sqlserver, you may even be faster running everything on the same server due to the lower latency you get by not having the overhead of a network.
Ian Ringrose
+3  A: 

Don't forget the maintenance issue...you can't reboot/patch one without nuking the other. If they are on two boxes, you could give your users a better experience, than no response from the webserver if you are maintaining the SQL box.

Not highest on the list, but should be noted.

Webjedi