6

I am planning to use cloudfoundry paas service (from VMWare) for hosting my node.js application. I have seen that it has support for mongo and redis in the service layer and node.js framework. So far so good.

Now I need to store my mediafiles(images uploaded by users) to a filesystem. I have the metadata stored in Mongo.

I have been searching internet, but have not yet got good information.

user644745
  • 5,673
  • 9
  • 54
  • 80

2 Answers2

10

You cannot do that for the following reasons:

  • There are multiple host machines running your application. They each have their own filesystems. Each running process in your application would see a different set of files.
  • The host machines on which your particular application is running can change moment-to-moment. Indeed, they will change every time you re-deploy your application. Every time a process is started on a new host machine, it will see an empty set of files. Every time a process is stopped on an old host machine, all the files would be permanently deleted.

You absolutely must solve this problem in another way.

  • Store the media files in MongoDB GridFS.
  • Store the media files in an object store such as Amazon S3 or Rackspace Cloud Files.
yfeldblum
  • 65,165
  • 12
  • 129
  • 169
  • Thanks dear. it's a good explanation. your second point gives me some hope. Is there any documentation about how can I use Amazon S3 with Cloudfoundry. Thanks again for your explanation. – user644745 Mar 02 '12 at 14:52
  • 2
    I'm not terribly familiar with Node.js or CloudFoundry, but here is [an example](http://www.hacksparrow.com/node-js-amazon-s3-how-to-get-started.html) to get started. – yfeldblum Mar 02 '12 at 17:17
0

Filesystem in most cloud solutions are "ephemeral", so you can not use FS. You will have to use solutions like S3/ DB for such purpose

Vishal Biyani
  • 4,297
  • 28
  • 55