Should Node.js and MongoDB be in different pods?

6/30/2017

I am trying to host a simple Node.js app connected to MongoDB, I look on the web, I've found 2 different methods and some guides to do so:

  1. Different pods:

    • Example from the official Kubernetes documentation.
    • Example from the official Google Cloud Platform documentation.
  2. Same pod:

    • Example from the official IBM documentation.

This confused me a bit, which is the best practise to achieve that?

-- atkayla
docker
google-cloud-platform
ibm-cloud
kubernetes
node.js

1 Answer

6/30/2017

You should put them in different pods.

Being in different pods you can then scale up the number of replicas of the web application part to as many instances as you need and you will still have the one instance of MongoDB.

If you had them in the same pod, you wouldn't be able to scale up to multiple instances as each replica would have its own MongoDB instance and thus separate data. If doing data updates to MongoDB from the web application, that would cause all sorts of problems as subsequent requests could hit a difference instance and so see different data.

-- Graham Dumpleton
Source: StackOverflow