Practical steps to achieve independent deployments between Java web services

Recently, I’ve been reading a new book called Building Microservices: Designing Fine-Grained Systems, by Sam Newman. It’s a good book so far and this is my second article pertaining to the book. One of the things that the author discusses on page 30 is the importance of loose coupling between microservices.

When services are loosely coupled, a change to one service should not require a change to another. The whole point of a microservice is being able to make a change to one service and deploy it, without needing to change any other part of the system. This is really quite important.

IMO, the author’s statement is perfectly valid. But, in this high level book, the author doesn’t get into practical code level recommendations. As such, I thought that I would discuss some practical tactics for achieving truly independent deployments for the Java RESTful JSON microservice world.

  1. Client-Side Independence: Client side independence happens when you’re working on a client that calls the Java service and you can add new data to the service’s JSON request payload without actually changing anything on the server side beforehand. This is useful, especially when the two codebases involved are owned by two different teams. Perhaps the server side coders aren’t ready with their implementation yet. In order to achieve this type of independence, you really want to ensure that the JSON POJOs being deserialized on the server side make use of Jackson’s @JsonIgnoreProperties annotation (or the equivalent of whatever non-Jackson JSON library you are using).
  2. Server-Side Independence: Server-Side independence is the complement of client-side independence. It happens when you’re working on a service that gets called by a client and you can add new functionality without worrying about the client causing exceptions by not sending the most up-to-date data. Like client-side independence, this is especially useful when the two codebases involved are owned by two different teams. In order to achieve this degree of freedom and loose coupling, you need to be able to gracefully handle null values in your requests. The client doesn’t send the new field? No problem, just ignore and move on.
  3. Don’t Change Existing Inputs, Just Add New Ones: This recommendation is a corollary to #1 and #2. One of the cornerstones of achieving loose coupling is to ensure that you never change the meaning or type of existing inputs. Rather, you only add new inputs. Want to change the meaning of an existing variable in the JSON request? Just deprecate it and create a new variable. Alternatively, create a new version of your API, eventually ignoring the old variable completely and supporting both in the interim. Doing so doesn’t force your clients to change all at once. In fact, Unicode uses this principle to great effect. The Unicode consortium has guaranteed that none of the characters for any given number will change – ever. This policy is necessary because it means that you can always have confidence that when you code an a, that it will always mean an a, and not change meaning to a b when Trump decides to establish Minitrue. Similarly, your clients can have confidence that you will never change the meaning of their data they send to you unless they call a new versioned endpoint.
  4. Flags to Turn On and Off Functionality: Lastly, as a fallback, you should consider adding a configuration flag that can enable and disable the new functionality. Ideally, with proper testing you shouldn’t need this. But, you should consider making use of such flags because they are fallbacks that can be readily used should you find an issue with your new functionality. Rollbacks are useful, but suppose you want to disable your functionality after another change has already been rolled out, or pushed to prod at the same time your own change went out. Unforeseeable issues make functionality flags a sensible tactic for achieving independent deployments between services, augmenting your systems’ overall robustness.

I hope that you, like me, can make use of these tactics for achieving independent deployments between services. Happy coding.

If the likes of Anthony Bourdain and Kate Spade are susceptible to suicide, what hope do the rest of us have in finding personal satisfaction via our careers?





Last week I woke up to the news that Anthony Bourdain had committed suicide in his hotel room in France. I really enjoyed Bourdain’s work, and consider myself a fan. The sheer volume of media attention surrounding his death attests to the tremendous impact he had on peoples’ lives. When I talked to my friend, Dany Houde, about Bourdain’s death, Dany discussed how Bourdain lived “the life” and how he was questioning his own choices since he thought so highly of Bourdain’s lifestyle. I agree with much of what Dany had to say. Like Dany’s choices, my own choices in travel destinations and desire to experience amazing cuisines on my journeys are heavily influenced by Bourdain’s shows.

Similarly, a few days before Bourdain’s suicide was news, the news of the day was that Kate Spade had also committed suicide. Admittedly, I wasn’t as big a fan of Kate Spade as I was of Anthony Bourdain. Being a high-end women’s fashion designer, her impact on me was less than that of the bad-boy-globe-trotting-gourmand image projected by Bourdain. Nonetheless, I do respect her work. Like Bourdain, the maelstrom of media coverage surrounding Spade’s death is clear evidence of her tremendous impact on society, and of the fact that she, like Bourdain, had reached the apex of professional achievement.

One often associates professional success with personal satisfaction. I recall Brian Gill, one of the leaders that I have most respected in my career, stating that in his opinion, you should only work at a job that you love. It’s wise advice, and it’s advice that I strive to achieve. For me, the implication of Brian’s advice is that by having a career that you love, your personal sense of satisfaction with life overall is enhanced. After all, since work forms such a substantial portion of our lives, satisfaction at work means a greater percentage of the time overall that we feel satisfied.

But holy shit, man. Surely Bourdain and Spade both loved their jobs. Sure I didn’t know them personally, but I just don’t see how you can get to that level of success without loving (and I mean really loving) what you do. For an aspiring fashion designer, you really can’t reasonably aspire to achieve anything more than Kate Spade did. And yet, she hung herself. For an aspiring chef, restauranteur, or twenty-first-century-upper-middle-class-globe-trotter, you really can’t aspire to achieve anything more than Anthony Bourdain did. And yet, he too hung himself.

But doesn’t doing what you love for a living naturally translate into personal satisfaction and fulfillment? Isn’t that the whole point, to be happy in the end? I get that money doesn’t buy happiness, but surely having a profession that you love translates into some measure of personal satisfaction in the larger sense. At the very least, shouldn’t doing what you love for a living lead to enough satisfaction that you shouldn’t want to kill yourself?

So then, what do I make of Bourdain and Spade? Was the fulfillment of success just not enough for them? Clearly, depression had a major influence. But, they functioned well enough to get where they are; the depression didn’t overwhelm them in their youths. Was their success just because they were fueled by manic energy, constantly trying to outrun their own demons and depression? Who knows…

But that’s just what makes their deaths so scary to me, that their success wasn’t enough in the end. Shouldn’t people who made it so far in life not want to kill themselves? If they, being so awesome, can’t stave off the crushing depression of their own minds, what hope does mundane little ole me have?

For me, bereft of answers, all I can fall back on is that we all require balance in our lives. Our careers, alone, aren’t sufficient to achieve personal fulfillment. There are a number of dimensions in which we all need satisfaction.

One list of categories in which one needs to develop and feel satisfied comes from the different sections in John Sonmez’s book – Soft Skills:

  1. Career: Everybody has to pay the bills, but why not feel satisfied doing it? Everybody needs to grow and develop in their chosen profession.
  2. Self-Marketing (aka Personal Branding): Building your own personal brand can give one a big leg up on the competition. This is one of the things that I’m trying to achieve by writing on this blog. But it’s also an outlet for you to express your thoughts and opinions and gain a reputation in this area. Note that for many, personal branding can be tightly coupled with one’s own career.
  3. Learning: IMO, learning should be a lifelong thing. Whether it’s learning new technologies in my career or reading a new parenting book, learning and assimilating the hard-won lessons of others is key to making fewer mistakes and becoming wiser as one gets older.
  4. Productivity (aka Getting Things Done): Everybody needs to accomplish daily tasks. It could be tasks at one’s job. It could be daily cleaning and cooking – daily administrivia and minutia and paying those bills in a timely fashion. Whatever it is, we all need to get shit done, and getting better and doing it and developing good habits is necessary. Getting such things done and out of the way helps cultivate a sense of satisfaction and confidence in life.
  5. Finances: We need to increase our degree of financial freedom as we get older. Ideally, we want to have a decent retirement and live comfortably during our golden years.
  6. Fitness: Everybody needs to be healthy. When you aren’t healthy just about every other aspect of your life is dragged down. We all need to be as healthy as we can be.
  7. Spirit: This dimension isn’t so much about picking a faith as it is about changing your own brain to get what you want out of life. Atheism doesn’t exclude one from growing in this dimension. Examples of growing in this category include improving one’s self-esteem and self-image. But if you are spiritual, then doing something like cultivating your relationship with God would fall under this category, since by believing that you are becoming closer with God, you are changing your own brain to feel better about yourself and more comfortable with yourself.

In addition to the above categories, I would add two more to the list:

  1. Family: Everybody has a family of some sort. Investing in our relationships with our kids and our family helps one live a more fulfilling life.
  2. Volunteering: Everybody has gotten something from their community. At the very least, we have all been lucky in some capacity. As such, we should help give a little back and improve the lives of others. Doing so gives one a greater sense of personal fulfillment.

So to come full circle, where do these categories leave me on what to think about Bourdain and Spade’s suicides? They clearly had mastered the categories of Career, Self Marketing, Learning, Productivity, and Finances. Both appeared to be moderately healthy, so they had to have had a least some measure of success with the Fitness category. They both seemed to do their share of volunteering – check for that category. But what about Spirit, Family? Of course, I have no idea. I don’t even know if improving in these categories would have helped them. I haven’t suffered through depression to the point where I felt suicidal, and I hope I never do. All I can say is that for me, personally, each of these categories contributes substantially to my sense of satisfaction and happiness. Focussing on my career, alone, doesn’t augment my long-term happiness. Instead, by focussing on my career in concert with these other areas, my overall happiness and satisfaction with life is increased. I hope that continues to remain so and I hope that each of these categories helps you in achieving the same.