我创建了一个PHP代码,将我的文件夹中的所有文件上传到我在Amazon S3上的存储桶.我的代码能够在子文件中上传文件,而不会失去其结构.
基本上,用户必须登录到我的网站,然后根据用户的帐户名称,他们可以将照片上传到我的存储在Amazon S3上.用户最多可以上传10张照片,然后将其修改为子文件类型.修改和缩略图.
我应该如何将架构上传到亚马逊S3上?
username/originalfiles/picture01.jpg username/original/picture02.jpg username/original/picture03.jpg .... username/original/picture10.jpg username/modifiedpicture01.jpg username/modified/picture02.jpg username/modified/picture03.jpg .... username/modified/picture10.jpg username/thumbailspicture01.jpg username/thumbails/picture02.jpg username/thumbails/picture03.jpg .... username/thumbails/picture10.jpg
要么
选项2(所有文件在同一个桶中)
username-original-picture01.jpg username-original-picture02.jpg username-original-picture03.jpg .... username-original-picture10.jpg username-modifiedpicture01.jpg username-modified-picture02.jpg username-modified-picture03.jpg .... username-modified-picture10.jpg username-thumbailspicture01.jpg username-thumbails-picture02.jpg username-thumbails-picture03.jpg .... username-thumbails-picture10.jpg
或者它在Amazon S3中没有什么不同?
然而,您使用的命名约定会对性能产生巨大的影响,一旦达到某一点(对于少量的文件,它可能不会很明显).
一般来说,您希望文件/文件夹名称的起始部分为“random-ish”,随机越多越好,所以s3可以更好地分散工作负载.如果名称前缀相同,则会有潜在的瓶颈.每个文件名开头的一个短的随机哈希可能会给你最好的性能.
从马(AWS)口:
The sequence pattern in the key names introduces a performance problem. To understand the issue,let’s look at how Amazon S3 stores
key names.Amazon S3 maintains an index of object key names in each AWS region.
Object keys are stored lexicographically across multiple partitions in
the index. That is,Amazon S3 stores key names in alphabetical order.
The key name dictates which partition the key is stored in. Using a
sequential prefix,such as timestamp or an alphabetical sequence,
increases the likelihood that Amazon S3 will target a specific
partition for a large number of your keys,overwhelming the I/O
capacity of the partition. If you introduce some randomness in your
key name prefixes,the key names,and therefore the I/O load,will be
distributed across more than one partition.If you anticipate that your workload will consistently exceed 100
requests per second,you should avoid sequential key names. If you
must use sequential numbers or date and time patterns in key names,
add a random prefix to the key name. The randomness of the prefix more
evenly distributes key names across multiple index partitions.
Examples of introducing randomness are provided later in this topic.
http://docs.aws.amazon.com/AmazonS3/latest/dev/request-rate-perf-considerations.html