0

Let's assume the following architecture where

  1. EventCreatorApp creates an Event which is logged to DB and sent to WorkerApp for processing
  2. WorkerApp processes the event, handles failures, etc.
EventCreatorApp --> [ DB ]
        |
         ---------> WorkerApp

Once WorkerApp is done, I want to update the event row in the DB with the outcome of running that event.

My question: Which app should write the outcome to the database?

If WorkerApp writes the outcome to the db the logic is nicely decoupled (one app creates events, one app executes events) but I have two apps writing to the db. What's worst, I want to deploy WorkerApp on an AWS Lambda, and that would mean opening a new connection to the db for each event processed.

If EventCreatorApp writes the outcome to the db I don't have any db access problems, but it feels like I'm pushing into EventCreatorApp some logic that doesn't really belong there, and in general I'm coupling the two apps a bit since EventCreatorApp would have to wait for a response.

Which solution is best?

1 Answer 1

1

Why not let a third "DatabaseLoggger" service update the database? So there will be only one app writing to the database, and none of the other apps is coupled directly to the db. All those other apps will have to send logging events to the service.

3
  • This sounds like the cleaner solution, but I'm a bit reluctant to add a third app (and a queue) to the picture - I'm building an MVP and I'd like to keep the architecture as lean as I can
    – laurids
    Commented Jun 20, 2019 at 12:40
  • For a MVP you probably shouldn’t use Microservices in the first place. It’s faster to build a monolith and if it becomes successful and you need to scale (primarily development speed with multiple teams) then you could consider Microservices.
    – Rik D
    Commented Jun 20, 2019 at 15:40
  • +1 for this. You don't want multiple microservices having access to the same database. Otherwise you're coupling. When making a schema change, you have to deploy both microservices.
    – bobek
    Commented Jun 20, 2019 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.