阅读背景:

添加要在Cloud Foundry上使用的应用程序的文件

来源:互联网 

For an application I'm converting to the Cloud Foundry platform, I have a couple of template files. These are basically templates for documents that will be converted to PDF's. What are my options when it comes to having these available to my application? There are no persistent system drives, so I can't just upload them, it seems. Cloud Foundry suggests for you to save them on something like Amazon S3, Dropbox or Box, or simply having them in a database as blobs, but this seems like a very curious work-around.

对于我正在转换到Cloud Foundry平台的应用程序,我有几个模板文件。这些基本上是将转换为PDF文档的模板。在将这些应用程序提供给我的应用程序时,我有哪些选择?没有持久的系统驱动器,所以我似乎不能上传它们。 Cloud Foundry建议你将它们保存在像Amazon S3,Dropbox或Box这样的东西上,或者只是将它们作为blob存放在数据库中,但这似乎是一个非常奇怪的解决方法。

These templates will change separately from application files, so I'm not intending to have them in the application Jar.

这些模板将与应用程序文件分开更改,因此我不打算将它们放在应用程序Jar中。

1 个解决方案

#1


5  

Cloud Foundry suggests for you to save them on something like Amazon S3, Dropbox or Box, or simply having them in a database as blobs, but this seems like a very curious work-around.

Cloud Foundry建议你将它们保存在像Amazon S3,Dropbox或Box这样的东西上,或者只是将它们作为blob存放在数据库中,但这似乎是一个非常奇怪的解决方法。

Why do you consider this a curious work-around?

为什么你认为这是一个好奇的解决方法?

One of the primary benefits of Cloud Foundry is elastic scalability. Once your app is running on CF, you can easily scale it up and down on demand. As you scale up, new copies of the app are started in fresh containers. As you scale down, app containers are destroyed. Only the files that are part of the original app push are put into a fresh container.

Cloud Foundry的主要优点之一是弹性可伸缩性。一旦您的应用程序在CF上运行,您就可以轻松地按需扩展它。随着您的扩展,应用程序的新副本将在新容器中启动。缩小规模时,应用程序容器将被销毁。只有属于原始应用程序推送的文件才会放入新容器中。

If you have files like these templates that are changing over time and you store them in the container's file system, you would need to make sure that all instances of the app have the same copies of the template file at all times as you scale up and down. When you upload new templates, you would have to make sure they get distributed to all instances, not just the one instance processing the upload. As new app instances are created on scale-up, you would need to make sure they have the latest versions of the templates.

如果您有这些模板的文件随着时间的推移而发生变化并将它们存储在容器的文件系统中,则需要确保应用程序的所有实例在扩展时始终具有相同的模板文件副本下。上传新模板时,您必须确保将它们分发到所有实例,而不仅仅是处理上载的一个实例。由于新的应用实例是在扩展时创建的,因此您需要确保它们具有最新版本的模板。

Another benefit of CF is app health management. If an instance of your app crashes for any reason, CF will detect this and start a new instance in a fresh container. Again, only files that were part of the original app push will be dropped into the fresh container. You would need to make sure that the latest version of the template files got added to the container after startup.

CF的另一个好处是应用程序健康管理。如果您的应用实例因任何原因崩溃,CF将检测到此情况并在新容器中启动新实例。同样,只有属于原始应用程序推送的文件才会被放入新容器中。您需要确保在启动后将最新版本的模板文件添加到容器中。

Storing files like this that have a lifecycle separate from the app in a persistence store outside of the app container solves all these problems, and ensures that all instances of the app get the same versions of the files as you scale instances up and down or as crashed instances are resurrected.

在应用程序容器外部的持久性存储中存储具有与应用程序分离的生命周期的文件可以解决所有这些问题,并确保应用程序的所有实例在上下扩展实例时或者作为实例扩展实例时获得相同版本的文件。崩溃的实例复活了。


分享到: