C
C
c34120842015-01-10 17:45:42
linux
c3412084, 2015-01-10 17:45:42

How to properly organize the file structure for a project?

Good afternoon.
I have a portal that has over 10kkk of images already uploaded.
In organizing their storage, I use the following approach to the formation of paths.
/b/C/c283308/bC_w250h300.jpg , where

  • /b/C/ - image ID, represented as a string (in this case, ID = 100),
  • c283308 - Random number from 100,000 to 999,999,
  • bC_w250h300.jpg - The name of the image itself.

But already for an image with ID = 10 000 000 000 (its text form will be kUKYOA) the path will be
/k/U/K/Y/O/A/c616822/kUKYOA_w250h300.jpg
I don't think this is a good way to store data. Maybe there is something more efficient?
In addition, to generate a link to such an image by Prefix (kUKYOA) and Key (616822), it is required to loop over the number of prefix characters to break each character through "/". In this example, these are 6 calls to substr. But there can be up to 30 images per page, i.e. approximately 180 substrings. I had not thought about it before, and the problems were different. As they say, we solve problems as they come.
There is an idea to split the prefix with nginx, and give the user the following link: /kUKYOA/c616822/kUKYOA_w250h300.jpg, and nginx will split it in the required format. But, IMHO, this is nonsense.
In general, please advise.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily, 2015-01-10
@vsadm

Look at specialized data stores like Elliptics .

A
Alexander Zelenin, 2015-01-10
@zelenin

1 folder and 10,000 pictures or 10,000 folders and one picture each?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question