views:

116

answers:

4

I'm wondering if, under the circumstances that

  1. You get lots more reads than writes
  2. Your SQL server of choice is cheap/free and offers a fast mirroring/replication service
  3. Your database isn't insanely large

rather than having separate SQL servers it would be better to have an instance of SQL on each machine getting instant updates from the master. This way there would be no network latency when doing all the read queries, but there would be a per box performance hit as the SQL instance has to execute. Would this be better overall for performance? Are there any other pros/cons that might come up?

+5  A: 

Your SQL Server should always be on a different box to the webserver, of that there is no question.

How many DB servers and webservers you have, and how they mirror (or otherwise) is up to how you scale your application.

You have SQL Server on a different machine because it needs (and deserves) a lot of RAM.

Noon Silk
Suppose I had a machine with loads and loads of RAM so that I can feed my SQL server as much as it wants? Oh, and loads of cores too, plenty CPU. Do I still need two machines? [I think your recemmendation is good, but I think the argument needs firming up a bit.]
djna
So basically, as much of the db as possible needs to fit in RAM otherwise you are going to get disk reads, and to fit the DB in RAM is going to be expensive if you do it on a per webserver basis? Is "only if RAM is free" the answer then?
mcintyre321
The answer is harder because you're talking about a specific case of scaling right; and we really need to know a lot about your application, before saying writing down to multiple DB's will improve perf by any significant amount. I mean in general it will, but it's possibly overkill.
Noon Silk
djna: Well 'no' in general, but in practice I prefer to always have a separate machine; because patching is different, and backup, and it can potentially be swapped out, etc, etc. Isolation is good for stability.
Noon Silk
@silky - yep completely agree. I see that a whole lot better argument than your original :-)
djna
It's also better for security to keep the DB server shut away in its own DMZ.
pjp
I disagree; if you can manage it, putting the database on the same box will dramatically lower latency, which improves the speed of simple in-memory queries massively.
MarkR
No, as long as the DB is on the network the latency won't be that bad at all.
Noon Silk
A: 

An immediate con is that there is no distributed lock co-ordinator in SQL Server so you can get merge conflicts as updates can change the same row on two different servers at the same time.

Depending on the size of the database and the disks in the web servers, you will find your network latency is smaller than the disk latency you will start suffering as the web server disks will not usually be as performant as the disk array you give to the database. If you wanted that kind of performance, you would be buying it per web server.

Replication performance is not without latency either, the distribution of the transactions isn't 'free' and careful maintenance of the transaction log would have to be planned to ensure you did not get log fragmentation (too many vlog's wthin the transaction log) which kills replication performance.

Andrew
I should have made the question a bit clearer - one DB is the master and updates get written to it, just reads are done on the slave instances.
mcintyre321
+1  A: 

It's quite a common architectural pattern to have read-only replicas of a database. We accept some degree of stalesness in them, perhaps they are even only updated once a day.

The general rule will be that multiple copies will introduce complexity in terms of operations and management and tend to introduce the possibilities of inconsistency of data - almost inevitably the copies will not be perfectly is step (or the costs of making them soo will be too high.)

An example: what happens if your replication processing breaks a bit. So that some, but not all copies become stale. Now your users start to see radically different views of the world. How much might that matter to you? If it's a site with low value data (eg. celebrity sightings in London suberbs) then perhaps that's fine. If it's on hand inventory, and being out of date means that your customers can't place orders, then maybe you care rather more.

My advice: things that sound simple at a boxed on paper sort of level don't always work out that way when you're sitting in an operations room at 3AM. Be very sure that you can easily operate your solution.

djna
Take heed of the last paragraph here...
Leather
+1  A: 

How would your SQL Server be cheap/free? I should have said the licensing costs for this setup would be crippling. At retail prices you're looking at $6000 per server. See also Jeff's comments about costs. Scale out the web servers by all means, but not your SQL Server until it's pretty much on its' knees.

You might instead want to think about a distributed cache like Velocity or NCache.

Either way, run your site first with one SQL server and see how it copes with the load, then think about mirroring/replication across servers, otherwise you're just optimising prematurely. Measure first!

PhilPursglove
I think the OP meant if they were using an open source database server, or had a volume licence which allowed it to be installed anywhere.
MarkR
I saw SQL server and read SQL Server!
PhilPursglove
SQL Express is free
mcintyre321