-1

I've built a blogging system which allows multiple short posts to be added daily, each with a photo to represent the article content.

So each photo is in JPG format and a max width of 280px, but a variable height - Possible over 2000px if it's a set of photos grouped together into one image.

So my concern is how many images to store in the blogs administative directory:

blog.com/images/2019 ( /sub-directory )

If using a simple <img src="images/<?php echo $year."/".$id; ?>.jpg" /> tag, to get and display the image, is there a point where it starts to slow down your pages photo load time if too many images are stored in /sub-directory?

Would it be recommended to split down sub-directory by month, week or even day? Having 365 folders per year seems a little extreme compared to 52, but what are yor recommendations?

Wayne Six
  • 1
  • 1
  • You already have yearly directories. With 10 posts per year that's only 3650 files per directory. even with 100 posts per day that's next to nothing. What are you worrying about? – Gerald Schneider Feb 26 '19 at 10:33
  • So 36500 image files per directory is considered a small number? Remember I'm not talking about how many images a Directory can store, I'm talking about how many it takes to affect performance. I've heard some say only 1 or 2 thousand is recommended - Even your duplicate answer states `idea of more than few thousands entries in single dir is scary to me` – Wayne Six Feb 26 '19 at 10:41
  • This depends on various factors, most important the hardware and the used filesystem. There are no general guidelines. You will have to measure it. – Gerald Schneider Feb 26 '19 at 10:44
  • WordPress uses year and month directories, and I've never heard anyone complain about it. – Michael Hampton Feb 26 '19 at 13:42

1 Answers1

0

This is dependent on what storage media you have.

Having an ancient HDD will certainly give you trouble if you store dozens of thousands of files in the same sub-dir and then attempt to read that.

If you have RAIDs of newer HDDs or SSDs there should be no trouble from a performance perspective, but then you can eventually end up needing to manage all that data in a different manner, so it's best to split it on yearly basis anyway.

Overmind
  • 3,076
  • 2
  • 16
  • 25