I am trying to learn microservices and write a project based on microservices, but I don't know how to choose the right database for each microservice?

Based on my researches MySQL and PostgreSQL are mostly used on big projects like Facebook, Instagram, Robinhood, etc. and also Cassandra and Redis are some of No-SQL databases used by Netflix and Instagram. I couldn't find any big project that uses MongoDB but it's very popular in educational contents and I don't know if is it a good choice for big projects as well?

In general, I want to know how to decide in which services or parts of the project we must( Or it's better to) use SQL and for what services it's better to choose NO-SQL databases? Are there any specific rules/instructions for this?

I see many projects like Instagram or Netflix use both SQL and No-SQL databases but I don't know how do they determine for which part they should use what kind of them?

EDIT: I also like to add up two more questions to make it more clear:

  1. Will we get into trouble if we only use either SQL or NO-SQL databases in a big application? When and why?
  2. Can we consider GraphQL as a solution for NO-SQL databases to meet data integrity or ACID rules? I mean what is the role of GraphQL in No-SQL world and could it make NO-SQL databases a complete replacement for SQL databases?
  • 1
    Do you need data integrity? -> Yes -> Use a RDBMS
    – user212533
    Oct 20, 2022 at 17:28
  • 1
    Does this answer your question? What are the differences between NoSQL and a traditional RDBMS?
    – mustaccio
    Oct 20, 2022 at 17:31
  • 1
    I'll blow your mind with this: some microservices use more than one type of database. Oct 20, 2022 at 18:51
  • 2
    @GoodMan - as I mention in one of my answers, it's the transaction model (ACID or BASE) that you want to look at - if your clients/stakeholds can go with a BASE (Amazon) model whereas ACID is stricter (think banks). Other than that, many NoSQL constructs have made their way into the RDBMS world - JSONB or HStore approximates Key-Value and also Document (MongoDB) - IMHO, you can get the best of both worlds using PostgreSQL and more importantly, you don't have to sacrifice ACID transactions!
    – Vérace
    Oct 20, 2022 at 19:33
  • 2
    "no-sql" == "reinvent the wheel"
    – Rick James
    Oct 20, 2022 at 21:04

1 Answer 1


I want to know at least the most important/major reasons/rules to decide which one is better to use...

In short:

Use a NoSQL solution when:

  • The schema is loosely defined and changes more frequently than you want to manage in the data layer
  • The schema is outside your control and is liable to change, such as when consuming an external API
  • Because you have no personal preference and don't care about data integrity

Use a SQL solution / RDBMS when:

  • Data integrity is important
  • You want to avoid a design that results in data duplication
  • Your schema is well defined or changes at a rate that's tolerable for you to manage in the data layer
  • Your data is relational

Either way, it's never a difference of query speed / performance despite what any article out there may misleadingly claim.

Some additional resources:

  1. NoSQL DB candidate for the project (looking for experienced advice)

  2. Should I use SQL vs NoSQL for files catalog?

...will update with more info and resources later.

  • 1
    @GoodMan No problem! "GraphQL...Can we consider it as a solution for NO-SQL databases to meet data integrity or ACID rules?" - No, those are different things. GraphQL is just a subset of NoSQL databases, heavily optimized for solving very specific problems that are graph theory based. "could it make NO-SQL databases a complete replacement for SQL databases?" - Nope. NoSQL is functionally a subset of RDBMS, IMO, and I doubt will ever replace RDBMS. The only benefit that is unique to them is lack of tight schema enforcement (which can be an issue when not properly managed too).
    – J.D.
    Oct 20, 2022 at 21:53
  • 4
    GraphQL isn't a database. It's sort of a query language for API's. It can be an interface either to an RDBMS or a NoSQL data store. It's orthogonal to the choice between relational and non-relational. Oct 20, 2022 at 23:19
  • 1
    @BillKarwin Good point, I'm not particularly versed on GraphQL itself and moreso mean my reply to OP in regards to graph databases. Thanks for that clarification!
    – J.D.
    Oct 21, 2022 at 2:33
  • 1
    I don't know much about it either. I just remember the developers at my last job being excited about it as the new shiny thing they wanted to play with. They kept talking about it as an alternative to RESTful API's. Oct 21, 2022 at 2:42
  • 1
    @BillKarwin lol yea I feel ya. Developers to new tech, are like puppies to new toys.
    – J.D.
    Oct 21, 2022 at 2:44

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