title: Run two processes in a single docker container or two containers connecting to the same DB?
body: <p>I need to develop an application that listens to a kafka topic and saves the data to a DB (cassandra). It will be a high density stream of data so saving the data will be resource expensive. Once the data is saved it will be queried and exposed through a REST API.</p>
  
  <p>I see two options, but both of them have downsides:</p>
  
  <p><strong>Option 1</strong><br>
  Create two services, each one in a separate docker container. One would run only the kafka listener process in python and the other one a flask web server.<br>
  <em>Advantages</em>: Every container runs only one process<br>
  <em>Downsides</em>: Both services connect to the same DB, which is not ideal according to the microservices pattern architecture, for the services are not completely decoupled.</p>
  
  <p><strong>Option 2</strong><br>
  Run both, kafka listener and web service in one container.<br>
  <em>Advantages</em>: Just one service to connect to the DB.<br>
  <em>Downsides</em>: More than one process running in a single docker container, and one of them (saving and updating) would be a lot more resource expensive than the other, so it would not scale uniformly.   </p>
  
  <p>Is there another way to go that doesn't involve moving to a monolithic architecture? Or which one of them is the best practice?</p>