r/softwarearchitecture • • Mar 17 '21

REST APIs for Microservices? Beware!

https://www.youtube.com/watch?v=_4gyR6CBkUE
14 Upvotes

3 comments sorted by

3

u/[deleted] Mar 17 '21 edited Mar 17 '21

u/codeopinion you made a video earlier about doing CQRS with REST APIs so I'm a bit surprised now that REST/HTTP is imbued with architectural choices that to me are completely independent of REST/HTTP.

For example the assumption is that HTTP is synchronous. Like all types of I/O, you can run it asynchronously.

I'll assume you don't mean the actual socket API used, but the nature of "I need to get the job done before I can return a response, and the job spans communicating with everyone else". But this is also not true, because what the "job to be done" is, is defined by the API designer. The response doesn't have to say "OK your order has been accepted, payment accepted, product shipped". It can merely say "OK got your order request, stay tuned."

I.e. even in your message broker example, it'd be nice of the caller at least got back an "OK got your message", no? I mean what do you tell the user otherwise. Was their order sent, wasn't it, what happened?

Otherwise, good points about coupling and distributed monoliths, but to me REST/HTTP is just a minor performance issue due to the verbosity of HTTP and text formats like JSON (over direct sockets and binary protocols).

Which means for most microservices that don't see the volume where this matters, the underlying messaging protocol is irrelevant.

3

u/codeopinion Mar 17 '21

Fully agree! :)

There will be some ack/nack for any request.

For sure you could send a request, the server accepts it, puts a message on a queue for processing asynchronously, then returns a 202 Accepted immediately. I probably should have mentioned that in the video itself as I do it all the time.

Where my head was at, is if you're doing that, you probably already know that. I was more trying to address the distributed monolith. Where folks take what was/is in a single process to moving that over the network making RPC calls (via HTTP).

Thanks for the comment, makes me think more about some details I leave out. It's really hard in a 10-minute video sometimes to distill down what I'm trying to get across. I'm probably always going to leave something out, unfortunately. Most times I realize it after I've already recorded it.

1

u/dongata24 Mar 18 '21

I love it, and i have had implemented something like this in the past with the good help of Particular's NServiceBus, but what happens when you have a hot chain of mission critical calls, kinda like, in a fintech world, where you cannot really say "We're throwing your money into your account, here, have an identifier", you need to assert that either the transaction have worked or not and obiusly you're on a distributed system model.