One of my friends said that he always favor DB on a separate machine instead
of having it on the same machine as the web server. I also had a discussion on
the same in the ASP.NET forums, where I realized that most developers think on
the same lines as my friend. This was a bit surprising as logically speaking,
having a DB on a different machine will lead to extra network trip, which will
definitely affect performance. Even if we have a high link line between both web
server and the DB server, theoretically speaking there will still be an extra
overhead, no matter how small it is.
I agree that having 2 machines with a firewall between them would make your
app more secure in the event that if a hacker gains access to your web server,
the DB server would still be safe. But increase in performance is a bit
difficult to digest!
Then I realized that people confuse scalability with
performance. Ofcourse having two machines would increase the
scalability, which is a good thing. But if you have a single web app and
foresee no major scalability issues, then having the DB alongwith the web server
is perfectly fine!
We need to consider all cases before taking any decision on creating an extra
DB tier instead of following some rule blindly.