开发者

Storing and retrieving user files on a different server / sub domain

I'm looking for some quick info about best practices on storing user's uploaded files on different servers or sub开发者_JAVA百科 domains...

For example, photos on facebook of course arent on facebook.com/files/users/453485 etc... but rather on photos.ak.fbcdn.net or whatever...

I'm wondering how with php i can upload to a different server whilst maintaining a mysql connection to my original... is it possible?


Facebook uses a content delivery network (cdn, hence fbcdn or facebook content delivery network) and probably uses webservices to pass binary data (photos) from server to server.

Rackspace Cloud offers a similar service. Here is an example application of their PHP library to access their webservice api: http://cloudfiles.rackspacecloud.com/index.php/Sample_PHP_Application


I'm going to make the assumption that you have multiple webservers, and want to be able to access the same set of files on each one. In that case, some sort of shared storage that each machine can access might be a good place to start.

Here are a couple options I've used:

  • Shared NFS Volume [ http://en.wikipedia.org/wiki/Network_File_System_(protocol) ]
  • MogileFS [ http://www.danga.com/mogilefs/ ]
  • Amazon S3 [ http://aws.amazon.com/s3/ ]

If you don't have control over the hardware or aren't able to install extra software, I'd suggest Amazon S3. There is an api that you can use to shuttle files back and forth. The only downside is that you don't get to use storage that you may already use, and it will cost you some money.

If you do have access to the hardware and software, MogileFS is somewhat like S3, in that you have an api to access the files. But is different in that you get to use your existing storage and get to do so for no additional cost.

NFS is a typical place where people will start, because it's the simplest way to get started. The downside is that you'll have to be able to configure servers, and setup a NFS volume for them to mount.

But if I were starting a high-volume photo hosting service, I'd use S3, and I'd put a CDN like Akamai in front of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜