Thursday, May 10, 2007

Business Tier or Database

In our current production environment, indeed, most production environments around the world, there are multiple machines front ending access to the database. In our particular set of circumstances we have a number of web/application servers sitting in front of a database server. It seems rather obvious, but I will say it anyway, this means that the database server is the "tier" which is the hardest to scale. We can add web and application servers with relative ease, but it is downright difficult to spread a single database over multiple servers without some really funky maneuvering.

So, if this is the case, and I know that most of you understand this, why are people still putting excessive amounts of processing on the database tier?

Yes, you should minimize the amount of data that you are transmitting across the tiers, but this doesn't mean that you need to move your business tier to the database!!! There is a balancing act that developers need to do in order to properly distribute the workload in their application and part of that balancing act is the understanding of where to put different pieces of logic. If you are performing a number of different calculations on the server so that you can stop sending back a single column to the client, don't bother, as it may be more efficient to do it in your code than in T-SQL. This is something that you will need to test and figure out.

Or, talk to your DBA. They've been through this before and your question is probably something that they've answered dozens of times. If they haven't then I'm sure that they are going to enjoy figuring out the answer.

No comments: