<p>I'm currently working on a traditional monolith application, but I am in the process of breaking it up into spring microservices managed by kubernetes. The application allows the uploading/downloading of large files and these files are normally stored on the host filesystem. I'm wondering what would be the most viable method of persisting these files in a microservice architecture?</p>

Matt Greene
<p>There are many places to store your data. It also depends on the budget that you are able to spent (Holding duplicate data means also more storage which costs money) and mostly on your business requirements.</p>

<ul>
<li>Is all data needed at all time?</li>
<li>Are there geo/region-related cases?</li>
<li>How fast needs a read / write operation need to be?</li>
<li>Do things need to be cached?</li>
<li>Statefull or Stateless?</li>
<li>Are there operational requirements? How should this be maintained?</li>
<li>...</li>
</ul>

<p>A part from this your microservices should not know where the data is actually stored. In kubernetes you can use Persistent-Volumes <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a> that can link to a storage of your Cloud-Provider or something else. The microservice should just mount the volume and be able to treat it like a local file.</p>

<p>Note that the Cloud Provider Storages already include solutions for scaling, concurrency etc. So I would probably use a single Blob-Storage under the hood.</p>

<p>However it has to be said, there is trend to understand a microservice as a package of data and logic coupled together and also accept duplicating the data, which leads to better scalability.</p>

<p>See for more information:</p>

<ul>
<li><a href="http://blog.christianposta.com/microservices/the-hardest-part-about-microservices-data/" rel="nofollow noreferrer">http://blog.christianposta.com/microservices/the-hardest-part-about-microservices-data/</a></li>
<li><a href="https://github.com/katopz/best-practices/blob/master/best-practices-for-building-a-microservice-architecture.md#stateless-service-instances" rel="nofollow noreferrer">https://github.com/katopz/best-practices/blob/master/best-practices-for-building-a-microservice-architecture.md#stateless-service-instances</a></li>
<li><a href="https://12factor.net/backing-services" rel="nofollow noreferrer">https://12factor.net/backing-services</a></li>
<li><a href="https://blog.twitter.com/engineering/en_us/topics/infrastructure/2017/the-infrastructure-behind-twitter-scale.html" rel="nofollow noreferrer">https://blog.twitter.com/engineering/en_us/topics/infrastructure/2017/the-infrastructure-behind-twitter-scale.html</a> </li>
</ul>
