LAMP 站点上较长的目录路径/名称和 URL 有哪些缺点?
LAMP 站点上较长的目录路径/名称和 URL 有哪些缺点?
我试图尽可能高效地组织网站上的图像,并且热衷于使用许多嵌套目录,这样子目录中的子目录就不会超过 1,000 个。
在最坏的情况下,图像将被存储为如下所示:
./images/76/543/7654321/640/1.jpg
与这样简单的子目录相比,拥有如此多的子目录是否有任何严重的缺点:
./i/a7/c3/5e.jpg
我想服务器必须挖掘更多的子目录,花费的时间越长,目录结构越长,URL 就越长,因此 HREF 在 HTML 文档中占用的空间就越大。但这会产生多大的影响呢?假设我们扩展到数百万用户,这是我需要考虑的事情(短目录结构与长目录结构)?
有关上下文,请查看 这个。
谢谢!
What are the downsides of longer directory paths/names and URL's on a LAMP site?
I am trying to organize images on my sites as efficiently as possible, and I'm keen on using many nested directories so that no sub-directory has more than 1,000 sub-directories.
In a worst-case scenario, images would be stored looking something like this:
./images/76/543/7654321/640/1.jpg
Are there any serious downsides to having so many sub-directories vs. something simpler like this:
./i/a7/c3/5e.jpg
I suppose the more sub-directories the Server has to dig in to, the longer it's going to take, and the longer the directory structure is, the longer the URL will be, so the more space the HREF will take up in the HTML doc. But how much of a difference will that make? Let's say we scale up to millions of users, is this something I need to take into consideration (short dir structure vs long dir structrue)?
For context, please view this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个目录中包含大量文件可能会导致速度变慢。你把它分开是对的。但是,您可以尝试通过在路径名中使用所有字母数字字符来减少长度。
如果您有:
通过上述操作,您可以存储 101559956668416 张图像。这看起来很荒谬,所以也许是这样的:
通过上面的内容,您可以存储 1679616 张图像。这是一个合理的数字,但可能不足以满足您的需求。那么这样怎么样:
这允许 2176782336(20 亿)张图像,每个目录最多只有 1296 个子文件/目录。
混合一些大写字母,甚至一些符号,你可以使用更少的字母。
就我个人而言,我会选择最后一个选项。这似乎是一个很好的平衡。
Having a large number of files in one directory can make it slow. You are right to split it up. You can however try to reduce the length by using all alphanumeric characters in the path names.
If you were to have:
With the above you can store 101559956668416 images. This seems ridiculous so perhaps something like:
With the above you can store 1679616 images. This is a reasonable number but might not be enough for your needs. So how about this:
This allows for 2176782336 (2 billion) images and each directory will only ever have a maximum of 1296 child files/directories.
Mix in some capital letters and perhaps even some symbols and you can get away with even fewer.
Personally I would go with the last option though. It seems to be a nice balance.