I have a web application to return images to my interface. In this application, the following occurs: when a request is made for a specific image, the application checks if the image exists on the disk, if it exists, returns the image. My problem starts when the image does not exist on the disk. When two requests are executed at the same time for the same image, and it does not exist on the disk, I have a problem because two threads are trying to create the same file on the disk at the same time. To solve this problem, for starters, I tried to create a mutex in creating a disk image. But that was a problem. Since server load is huge due to the large number of concurrent requests, the server crashes.
I would like to ask what your ideas solve this problem. Or if you are otherwise?
Thank.
source
share