简体   繁体   中英

File upload best solution for load balanced servers

I got 2 webservers load balanced, connected to 1 Mysql Server. One of the functionality of the php application on the servers allows the users to upload pictures which have to be accessible from either of the Web server . What would be the best solution to do so ?

  • Upload the pictures to the clouds ?
  • Store the pictures in the database
  • Upload the pictures to the MysQL server (not the database, the filesystem)
  • ... ?

Thanks for your advices.

Rsync like above works, but if your running a high traffic site off something like wordpress platform the number of images uploaded can quickly become too many for rsync to traverse in the directory tree, and you'll first see rsync slow down too a crawl during the checksum part, and then it will just stop working like when you do an ls in a directory with too many files. But this is the best solution until you encounter these problems.

Another solution is a remote mounted nfs partition but thats pretty insecure unless you are in a really trusted environment.

Another solution would be to immediately 'put' the file on Amazon S3 and then store the URL link in your database and just render that on page loads.

Don't store the pictures in the database - that really slows down the db table.

我使用GlusterFS(一个复制的文件系统)和Amazon S3(用于云存储)都取得了很好的效果。

I would recommend uploading to a folder on the filesystem. Then run a cron job periodically that rsync's the folder between the two servers. You could also have the rsync run in process with the image upload. Storing images in the database can get complicated and can bloat your database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM