Distributed Monoliths

June 7, 2015
programming microservices reading rants

As part of developing RESTful HTTP APIs at work, there’s been a lot of discussion over the “best” way to architect/implement everything. To avoid relying strictly on my own instincts and relearning mistakes that many others have already learned from, I’ve been reading O’Reilly’s Building Microservices. I haven’t finished it yet, but have gotten a lot out of what I’ve read so far (and been pleased to see that my instincts have been largely supported by someone who’s experienced implementing such systems).

The chapter on Integration presents the idea of “the shared database” [p. 41, 1] as possibly the most common and seemingly simple form of integration between different services. You’ve split your environment into multiple applications/services, but decided the way they should operate on shared data is by hooking directly into the same database. I found this section especially interesting because this approach has been championed by some around the office, but I had strong concerns about it and many of those were highlighted in the book.

  1. The database schema becomes a large shared API. Any schema changes you want to make (e.g., improved data representation, new logic in one service requires table changes, etc) now requires careful planning and regression testing to avoid breaking any of the services that interact with the database.
  2. You’ve lost loose coupling between your services because you can no longer change implementation details (e.g., moving from an RDBMS to a NoSQL system) because every consumer that interacts with it is tightly coupled to those low-level implementation details. This can also introduce restrictions on the technology choices for consumers since they’ll be limited to options that have the required driver support.
  3. Major DRY violations / loss of cohesion. Logic associated with interacting with the data in the database is now spread across every consumer. You’re forced to replicate code and have to remember to update it everywhere, which is likely to be an error prone process.

After thinking about it, I decided this approach is effectively building a distributed monolith. As with most clever things I think up, I’m not the first to coin this term and a quick Googling turns up a handful of unique sources. Oddly enough, one was posted the same day I wrote this post. At least it was close to having a novel thought. Oldest reference I could find dates back ~7 months to November 2014. Oh well. At least it wasn’t yet another thing everyone’s excited they “invented” that IBM had already done back in the 1960s (and everyone promptly forgot about).

1: Sam Newman. Building Microservices. O’Reilly Media, 2015.

3dprinting12 alabama7 amalgam4 android2 apple21 auto6 blog24 cat-diary5 cats18 chicago3 college18 comparch5 cooking2 define30 film19 gaming37 georgia2 halloween2 hosting13 hpc11 hugo3 humor35 huntsville5 illinois37 ios2 ireland3 kids5 meme5 monte-sano2 music23 photography35 politics2 programming11 pumpkins2 raid6 rants19 reading25 research11 snow6 sysadmin18 tales-of-the-weird14 tech54 tennessee2 travel11 video8 work29