为什么最好不要在 spring 网络应用程序的生产场景中使用内容加载应用程序的文件系统?

Why is it best to NOT load up the file system of your application with content in a production scenario for spring web apps?

spring.io 的上传文件指南中有这样的警告:

In a production scenario, you more likely would store the files in a temporary location, a database, or perhaps a NoSQL store like Mongo’s GridFS. It’s is best to NOT load up the file system of your application with content.

没有任何其他上下文。这是出于安全或性能还是其他原因?

因为文件系统大多数时候不是存储数据的合适位置:

  • 如果你的应用程序是集群的,每台机器都有自己的文件系统,因此对机器 A 的请求将看不到机器 B 上的先前请求存储在文件系统上的内容
  • 如果您的应用程序部署在云端的 PAAS 上,提供水平可扩展性,PAAS 可以启动新的 VM 或容器来维持负载,然后删除这些 VM 和容器,从而丢失您可能拥有的所有东西放入文件系统
  • 有些平台甚至不允许您访问文件系统
  • 您可能已经为您的数据库制定了备份策略,或者正在依赖外部存储服务为您提供备份策略。在文件系统上存储数据将迫使您提供另一种备份策略