The problem of uploading files in Nginx load balancer synchronously

Source: Internet
Author: User
Keywords Php nginx nginx_proxy
Great gods, I have a question for you to look at now:
Because of the use of nginx balanced load, due to the distribution of requests to different servers, so if you just want to save the uploaded images only to one server will be a problem.
Baidu to the method:
The first method is to use FTP to synchronize files to the save server in the code.
The second option is to use Curl to submit the file to the save server and then save it again if it is not the server that saved the file.
The third method is to directly use the storage server's IP to tune the interface. The third approach is that we do not consider this side first.
Do not know the gods, how to meet this situation is how to achieve this demand

Reply content:

Great gods, I have a question for you to look at now:
Because of the use of nginx balanced load, due to the distribution of requests to different servers, so if you just want to save the uploaded images only to one server will be a problem.
Baidu to the method:
The first method is to use FTP to synchronize files to the save server in the code.
The second option is to use Curl to submit the file to the save server and then save it again if it is not the server that saved the file.
The third method is to directly use the storage server's IP to tune the interface. The third approach is that we do not consider this side first.
Do not know the gods, how to meet this situation is how to achieve this demand

    1. The host Nginx for the upload location to do special processing, only one machine to take charge of file upload, imperfect but effective, can be a period of time over the plan

    2. Build a Distributed File system, mount to all the server, processing file upload write only to this particular directory, Nginx planning a location point to this directory (for example,/data/upload), the disadvantage is to maintain a more distributed File system ( It's a bit like your first idea, but the distributed file system doesn't need to be "synchronized."

    3. Using an external CDN file came to solve this problem, seven cows, and the cloud can be

1. Dedicated to the entire number of servers used to store these static resources;
2. Complete a few disks, make a network Disk (NFS), dedicated to storing these files, each server to mount the several disks, and Windows shared folder similar;
3. After successful upload, return the URL of a file, which is the address of the file;

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.