quarkusio / quarkus-super-heroes

Quarkus sample application - Super Heroes
Apache License 2.0
283 stars 164 forks source link

Introduce a different database for each microservice ? #6

Closed agoncal closed 2 years ago

agoncal commented 2 years ago

All three Villain, Hero and Fight microservices use a Postgres database. What about having a different database type for each microservice?

We could use Postgres, MySQL and MariaDB, for example.

edeandrea commented 2 years ago

We certainly could. It would have an effect on running the system via docker compose though. Right now only 1 DB instance is started and 3 schemas are created. That would have to change.

agoncal commented 2 years ago

Or maybe have a simpler setup when using docker compose (only one instance of Postgres, as it is now) and a more complex one when doing K8s ?

edeandrea commented 2 years ago

But then the apps would have to have each of the extensions. Isn't that a Quarkus anti-pattern?

By anti-pattern I mean it would be ok to have more than one datasource extension present if the app communicated with more than 1 datasource, but to switch datasource types between environments? Some of the datasource config is fixed at build time.

edeandrea commented 2 years ago

BTW I'm not against the idea, just playing devil's advocate and thinking out loud about the repercussions.

agoncal commented 2 years ago

You're right. We could use Quarkus profiles but that could be cumbersome. I'll give it a try and submit a PR is I come up with something that ends up easy to run on docker compose and no too difficult on K8s

edeandrea commented 2 years ago

Let me know if you have any questions about the setup and how the k8s/docker compose files are generated. I tried to be detailed in the documentation, but if something doesn't make sense or the documentation needs to be updated I'm happy to modify the docs (or take PRs :) ).

Jenriksen commented 2 years ago

Looking at eShopOnContainers project from Microsoft might give some ideas, they have implemented a full set of microservices with different databases as well (I believe their older versions of the repo used an even wider range of different db)

edeandrea commented 2 years ago

I was thinking about Mongo and/or Cassandra? Although Cassandra doesn't yet have a Dev Service (see datastax/cassandra-quarkus#199) so I'd be hesitant to use it.

Jenriksen commented 2 years ago

So MongoDB it is then. I will see if I can find the time to create a PR this week.

edeandrea commented 2 years ago

Awesome! Thanks for taking an interest @Jenriksen!

@agoncal / @cescoffier thoughts?

edeandrea commented 2 years ago

Maybe the fight service makes the most sense/is the least invasive?

agoncal commented 2 years ago

I like the idea of having several types of databases, APIs and so on. As @edeandrea mentioned, MongoDB has DevServices (which makes lives easier in dev). So, if Cassandra does not have DevServices (yet?), Mongo is a good choice

cescoffier commented 2 years ago

I would go for a noSQL DB. Mongo is fine, Redis might be interesting too.

Mongo is closer to what we did in the other microservices (we have a Panache layer). So, I would go mongo.