Code Monkey home page Code Monkey logo

Comments (6)

dsyer avatar dsyer commented on July 26, 2024

If it's mounted on the host, then the host can clean it up I guess? What is the maximum capacity? It should only be limited by the size of the physical disk it is on, right? Do you have any concrete data / samples that actually display this problem? I can't think why a Spring Boot app, in general, would be writing a lot of data to /tmp. I think it might be used by Tomcat in a small way, but nothing that would grow continuously AFAIK.

from gs-spring-boot-docker.

rreitmann avatar rreitmann commented on July 26, 2024

I was just wondering because we use multipart file uploads and AFAIK tomcat or the servlet engine used by spring boot stores these files in the temp directory. Since we are running the spring boot containers on a managed platform (previously Pivotal Web Service, currently AWS Fargate) I have neither influence on the physical size of that directory nor can I IMHO rely on the host cleaning this directory up.

from gs-spring-boot-docker.

dsyer avatar dsyer commented on July 26, 2024

I doubt if it's a very common issue - we've been running Spring Boot in containers in CloudFoundry for literally years and no-one brought this up before. Maybe long-running apps with file uploads is an uncommon use case. The best I can say is - you probably need to restart the container to be sure (not the app, the container). I know some OSes have services that clean up tmp dirs (Fedora for sure), so maybe those would be something you could add to your container.

from gs-spring-boot-docker.

gregturn avatar gregturn commented on July 26, 2024

@rreitmann To be clear, multipart uploads are piped to the application's running directory, not /tmp. (Unless you explicitly store them in /tmp).

Being inside a container implies you're in a cloud native world, which means if you're managing local files, you really need to own that task.

Given that Tomcat explicitly needs a /tmp folder to run, and since you don't appear to leveraging a cloud friendly mechanism like S3, I'd pick some subfolder to host all your files. And implement some form of "reaping" mechanism up front, e.g. any file more than 48 hours old is deleted or archived elsewhere. Something.

You cannot depend upon Tomcat starting/stopping to handle it, nor the container itself. You could run into unpredicted optimizations. So periodically clean things out.

BTW, if you run 2+ instances of your application, you now have ANOTHER problem.

If this is starting to sound complex, welcome to the problem of storing your own files in the cloud. And the reason S3 (or GridFS) has become very popular.

from gs-spring-boot-docker.

rreitmann avatar rreitmann commented on July 26, 2024

@gregturn Thanks for the clarification regarding multipart uploads. We do use MongoDB's GridFS for almost all files we create and we clean up GridFS ourselves. However there is one case in which we store an uploaded file by transferring it to a temp file created with Files.createTempFile for further processing. I will refactor this part.

However I still think that spring boot or tomcat should clean up the files they create in tmp when running in a container.

from gs-spring-boot-docker.

dsyer avatar dsyer commented on July 26, 2024

AFAIK Spring Boot does not create files in /tmp. Tomcat only does if you use certain features (JSP maybe?). And we don’t expect those to be especially leaky. If you want to pursue that though, please open an issue in Spring Boot.

from gs-spring-boot-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.