title: Shared library vs Microservice?
body: <p>I have two micro services(ms) ms1 and ms2. In both of the ms there is duplicate reusable code(like hashing/security related/orm/etc). Just FYI this usable
  code can sometimes maintain some state as well in DB (if it matters by any chance)</p>
  
  <p>There are two ways, I can proceed </p>
  
  <ol>
  <li>Either extract the reuable code as separate library and include in both ms</li>
  <li>Create separate ms for this reusable code and expose it as rest end points</li>
  </ol>
  
  <p>If I take approach 2, advantage is I just have to redeploy the ms3 in case of any change. If take approach 1, I need to redploy both ms. At the same
  time approach 2 will require separate maintenance/resources/monitoring. </p>
  
  <p>Which one is more ideal approach in terms of system design considering hardware resource is not a challenge. I just mentioned two microservicebut in some cases
  there are more than two ms having duplicate code.</p>
  
  <p>I am not sure what is the criteria which can help me to decide whether to go towards shared library or micro service ?</p>
  
  <p><strong>Update :-</strong></p>
  
  <p>I have got some clarity from below blogs but still have question. Will think and post anew question if required.</p>
  
  <p><a href="https://blog.staticvoid.co.nz/2017/library_vs_microservice/" rel="noreferrer">https://blog.staticvoid.co.nz/2017/library_vs_microservice/</a> </p>
  
  <p><a href="https://dzone.com/articles/dilemma-on-utility-module-making-a-jar-or-separate-2" rel="noreferrer">https://dzone.com/articles/dilemma-on-utility-module-making-a-jar-or-separate-2</a></p>