Web 应用程序的理想目录结构

发布于 2024-08-29 10:53:19 字数 558 浏览 3 评论 0原文

我即将创建一个基于用户的网站,并且必须为每个用户存储照片、文档和其他数据。

如果我取一个愚蠢的数字,比如 1 000 000 000 个用户,我相信一个包含 1 000 000 000 个用户的文件夹不会是世界上最快的事情!所以我正在考虑创建类似

第一级的东西:[az] 第二级:[az] 第三级:[az]

因此 bobby 将位于 /b/o/b/by

但这也意味着它不会均匀分布,因为以 az 开头的用户很少,而以 am,s 开头的用户较多, l ...

所以我正在考虑使用用户ID 例如“000000000001”、“000000000001”等...

第一级:[000-999] 第二级:[000-999] 第三级:[000-999]

因此用户000000000001的数据将存储在/data/000/000/000/001中 那么我将确保每个级别最多有 1000 个文件夹。

大家对此有何看法,我该做什么或不该做什么?

如果 I/O 太糟糕,服务器将在 raid 1 上运行带有 EXT3 的 Centos 5.4 我可能会参加raid 10。

I'm about to create a user based website and will have to store photo, docs and other data for each user.

If I take a silly number like 1 000 000 000 users, I believe than one folder with 1 000 000 000 won't be the fastest thing in the world! So I was thinking of creating something like

1st level : [a-z]
2nd level : [a-z]
3rd level : [a-z]

Therefor bobby will be in /b/o/b/by

But this also mean that it won't be spread equaly, because there will be very few user starting with a z and many more with a m,s,l ...

so I was thinking of using a user id
such as "000000000001", "000000000001" etc...

1st level : [000-999]
2nd level : [000-999]
3rd level : [000-999]

therefore data of the user 000000000001 will be store in /data/000/000/000/001
then I will be sure to have a maximum of 1000 folder in each level.

What do you guys think about it, what I should do or not do ?

The server will be running Centos 5.4 with EXT3 on raid 1, if the I/O get's too bad
i will probably go for a raid 10.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞄了个咪的 2024-09-05 10:53:19

哈希函数提供了一种在易于搜索的结构中分布大量数据的方法。

请参阅此相关问题: 为什么使用哈希来创建大型文件集合的路径名?

还可以尝试在 Google 结果中查找目录散列

A hash function provides a way to distribute large amounts of data across an easily searchable structure.

See this related question: Why use hashing to create pathnames for large collections of files?

And also try looking through Google results for Directory Hashing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文