News for hackers. Stuff that matters.
Re:If All You Have Is a Database, Everything Looks Like a Nail by konschubert on Tuesday December 08, 2020 @04:54AM (#25343556)
If you find yourself doing in-code joins across microservices, you need to stop and think:

Are my services correctly scoped? Am I doing these joins because there is maybe a higher level domain that goes across these two services?

Should I re-scope my services? Or should I build an Aggregator-View service that holds a JOINED copy of the data.

These aggregator-view services often make sense as Backend-For-Frontends. They must be restricted to a read-only API since they mirror data from other microservices.

GraphQL is a dead end when you are doing joins in code.

Re:If All You Have Is a Database, Everything Looks Like a Nail by tpetry on Tuesday December 08, 2020 @07:48AM (#25344434)
What you are describing is in my optinion the exact problem happening with almost all microservices. Building an aggregator microservice to join together two services is another microservice in a complex microservice landscape...

People on hn seem to hate monoliths, but a monolith with just a few services outsourced to microservices is much easier to handle. No more joining microservice, no more race conditions when trying to do transactional processing over some microservices and all the problems of microservices.

Re:If All You Have Is a Database, Everything Looks Like a Nail by konschubert on Tuesday December 08, 2020 @08:24AM (#25344695)
I agree that a well-maintained monolith is simpler and more stable than micro services.

The emphasis is on well-maintained. If you’ve ever had team A write a crazy query and kill the database for team B, you’ll start to appreciate the damage containment and encapsulation that microservices provide.

EDIT: Of course there might be other, better solutions to this problem.

Re:If All You Have Is a Database, Everything Looks Like a Nail by konschubert on Tuesday December 08, 2020 @01:45PM (#25349626)
With “kill the database” I mean things such as transaction deadlocks.
Re:If All You Have Is a Database, Everything Looks Like a Nail by fatnoah on Tuesday December 08, 2020 @11:50AM (#25347793)
>If you find yourself doing in-code joins across microservices, you need to stop and think:

This is a place where far too few people stop to think about what you're doing. I've seen too many cases where an operation requires coordinating requests across multiple service methods THAT ARE ONLY USED IN THAT PARTICULAR OPERATION! The devs spend all of their time a) coordinating things and b) trying to make it performant and c) realizing none of the gains of having microservices to begin with.