Can I use a file based database on Heroku?

会有一股神秘感。 提交于 2021-01-30 09:09:06

问题


I have a small Node.js / Express app deployed to Heroku.

I'd like to use a lightweight database like NeDB to persist some data. Is it possible to periodically backup / copy a file from Heroku if I used this approach?


回答1:


File-based databases aren't a good fit for Heroku due to its ephemeral filesystem (bold added):

Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

Depending on your use case I recommend using a client-server database (this looks like a good fit here) or something like Amazon S3 for file storage.



来源:https://stackoverflow.com/questions/50421061/can-i-use-a-file-based-database-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!