News for hackers. Stuff that matters.
Re:Give Me Back My Monolith by stouset on Thursday March 14, 2019 @02:52AM (#19387008)
Not to mention, JSON APIs start out simple because you just call `to_json` on whatever object you need to share and then move on. Except nobody’s ever documented the format, and handling ends up taking place in a million different places because you can just pass the relevant bits around. The API is “whatever it did before we split it up”.

Now when someone goes to replace one side, it’s often impossible to even figure out a full definition of the structure of the data, much less the semantics. You watch a handful of data come across the pipe, build a replacement that handles everything you’ve seen, and then spend the next few months playing whack-a-mole fixing bugs when data doesn’t conform to your structural or semantic expectations.

JSON lets you get away with never really specifying your APIs, and your APIs often devolve to garbage by default. Then it becomes wildly difficult to ever replace any of the parts. JSON for internal service APIs is unmitigated evil.

Re:Give Me Back My Monolith by humbleMouse on Thursday March 14, 2019 @10:15AM (#19389369)
You could just make a shared object module that is versioned and have all the microservices use those objects to communicate. Or you could implement avro schemas. Many ways around this issue.
Re:Give Me Back My Monolith by jypepin on Thursday March 14, 2019 @06:25AM (#19387918)
I don't know if I would recommend NOT using json when starting out (I'm on the side of pushing for a monolith for as long as possible), but yes omg I've been there.

I've migrated multiple services out of our monolith into our micro service architecture and oh boy, it is just impossible to know (or find someone who knows) what structure is passed around, or what key is actually being used or not. Good luck logging everything and pulling your hair documenting everything from the bottom up.

Re:Give Me Back My Monolith by geezerjay on Thursday March 14, 2019 @04:50AM (#19387491)
> Except nobody’s ever documented the format,

That's hardly a JSON problem. You still experience that problem if you adopt any undocumented document format or schema.

Re:Give Me Back My Monolith by danmaz74 on Thursday March 14, 2019 @05:52AM (#19387751)
I think the point the OP was making was more about the tooling than the format. Having a library that forces you to define the format you're using, instead of dumping to_json whatever internal representation you had, also doubles as documentation.

But then, of course, that can be considered boilerplate code (and, in the beginning and most of the time, it actually is just a duplication of your internal object structure).

Re:Give Me Back My Monolith by bunderbunder on Thursday March 14, 2019 @09:47AM (#19389150)
That, and having the format definition file support comments means that you have a convenient all-in-one place where, at lest in the more straightforward cases, you can handily describe both the message format and the service's behavior in a single file that's easy to share among all your teams.
Re:Give Me Back My Monolith by stouset on Thursday March 14, 2019 @12:09PM (#19390561)
Precisely.

The easiest path with JSON is to do none of this, and so the majority of teams (particularly inexperienced ones) do none of it. With protos, someone must at least sit down and authoritatively outline the structure of any data being passed around, so at a minimum you’ll have that.

But even just forcing developers to do this generally means they start thinking about the API, and have a much higher chance of documenting the semantics and cleaning up parts that might otherwise have been unclear, confusing, or overly complex.

Re:Give Me Back My Monolith by mruts on Thursday March 14, 2019 @05:53AM (#19387756)
I’m surprised that bencoded dictionaries haven’t ever become popular outside of bittorrent. They are expressive, fast, and easy to implement.