I'm setting up a database server as a separate VM in my server so that I can control resources, and make backups of just that instance. I own a server that will reside in a colo soon. Is this the best way to approach my DB regarding scalability? Are there any security concerns? Do I listen at localhost
still, even though it's a separate instance? And, is there any benefit to running your DB (PostgreSQL in my case) in the same machine as your application (web based SAAS application in my case)?
2 Answers
Scalable systems usually partition the application and the database, so you're on the right track. Security should be good as long as you use the built-in IP filtering of pgSQL.
As far as benefits of running everything on one server, its definitely easy to backup, but all it takes is one hardware failure and your entire application goes down.
If you're just getting started, money is probably the biggest factor towards not doing this, but I would suggest two physical servers running two VMs each (one application, one DB) and setup to be able to failover to each other.
I'd say you start with one machine hosting both application and database. It is still quite easy moving the database to a separate machine or cluster or whatever when you find a need for it.
When setting up the system, just keep in mind that your infrastructure might need to change in the future. Maybe assign a hostname for the database already from the beginning, so you don't need updating the application whenever the database is moved. Just point the hostname to the new location.
Having a lot of hardware (be it physical or virtual) when you don't need just lead to overhead and potential failures. You may or may not ever need more resources, but don't overgrow from the beginning.
Keep it simple!