suprxd
suprxd

Reputation: 330

What happens to temp files in Heroku (Node application)

I have a free Heroku account and my Node app uses Amazon S3 to store files. I ham using s3fs module along with multiparty-middleware which first temporarily stores the files and then uploads it to S3.

After the file is uploaded and unlinked in fs, the file still remains in my local temp folder during local development. I have deployed the same code on my Heroku app and I am worried if there is any way to check the temp folder or delete it daily because the app has slug size limit of 500mb and the uploaded files can be even more than 100s of Mbs.

Upvotes: 2

Views: 4367

Answers (1)

Andrés Andrade
Andrés Andrade

Reputation: 2223

In Heroku, each dyno has its own ephemeral filesystem, with a fresh copy of the most recently deployed code.

In general, the ephemeral filesystem works just like any filesystem. Directories you have permission to write to, such as /tmp, you can write files to.

During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad and any files written will be discarded at the moment the dyno is stopped, restarted or recycled.

If you are storing your temp files in /tmp folder you can run df to check used and available space:

heroku run bash
df -h /tmp

Also note that the slug is a compressed and pre-packaged copy of your application and files are not stored inside the slug but in the ephemeral filesystem of your dyno. It's highly unlikely that you have a use case that really justifies having to delete files from your dyno's ephemeral filesystem.

In conclusion, you should not worry about deleting the tmp folder daily since any files written will be discarded at the moment the dyno is stopped or restarted or approximately once a day as part of normal dyno management.

Upvotes: 2

Related Questions