Search code examples
imageftphostinguploading

Only one ftp user is enough for an uploading proccess at image hosting site?


I have a image hosting website and I'm thinking of using a new server to host the images, the main server "misitio.com" plus a new server that will contain the images "img1.misitio.com".

The images will be upload to the my main server and then it will be transferred to the new server by ftp (all in php code), my question is whether i will have problems using only one user to upload pictures, ie, if many visitors are uploading pictures in simultaneous there will be problems with the connection to the ftp server? (as it always will be using only one user).


Solution

  • We came up with a solution for this in the past. We used a CDN for hosting and serving the images via Rackspace. We accepted the images to be uploaded as normal and then ran a script that synced (push only files that don't exist on the remote site) files to the CDN. That process runs automatically every hour. After 3 hours, we would delete the image from the source webserver. So the CDN was the primary store of all the images and it didn't impact the work the web server had to do to server those images to visitors (let the CDN do the work). Then on a weekly basis, we can a script that would crawl the 400K+ image files in the CDN and cross reference our DB to verify the images weren't orphaned. If they were, they were deleted. Of course, you always had a little bloat in the CDN of images that were orphaned, but they would get removed eventually and the cost to store and server on the CDN was cheap. Be sure to update your website code to reference all images with your CDN address. We set up a CNAME in DNS to mask that public CDN url from users.