Infrastructure
Strategies
You will find hereafter a few options you have in hand to
deploy the Datastore alongside of your service.
Straightforward
Basic deployment of the Datastore as a proxy over
MongoDb database. The service is used to add the Event-Source
layer between your application and your database.
Sidecar
If your philosophy is to give the responsibility of the data
to the own service managing it, a Kubernetes1 sidecar2
is a good option. The Datastore will be collocated with
the container of your service, accessible within the same
Pod and entities contracts can then be fully controlled
by your service business logic.
Read / Write MongoDB
If you are working with a MongoDb Replicaset, you can connect
the read operations to the secondary nodes available in
the cluster while still having write operations on
primary. This advanced configuration is available through
environment variables3: MONGO_WRITE_URL and MONGO_READ_URL instead of simpler MONGO_URL.
If you want to play with such a deployment, please have a look to the simple script to deploy a MongoDb Replicaset with Docker easily4.
Read / Write Datastore
If your application is requiring a different scaling between
read and write you can choose the make different
deployments for these 2 use cases. One kind of deployment
would then be allocated for read operations, another one for
write. In your application, you will have to decide which
instance you want to use based on your own use-case.
With this strategy, you can easily start streaming your data
without worrying about scaling of your Datastore's.