[ic] howto do if file exists

Mike Heins interchange-users@icdevgroup.org
Fri Apr 18 17:21:01 2003


Quoting John Young (john_young@sonic.net):
> Mike replied:
> 
> > Quoting Stefan Hornburg (Racke) (racke@linuxia.de):
> > 
> >> On Thu, 17 Apr 2003 12:20:38 -0400
> >> Mike Heins <mike@perusion.com> wrote:
> >> 
> >> > Quoting Nicholas Cook (ncook@gryphon.net):
> >>
> >> > > I hadn't thought about using apache. I'll try that approach because
> >> > > I am talking about 20,000+ images.
> > 
> >> > Warning -- Apache can't repeal the laws of physics either. It still
> >> > has to do directory lookups just like IC does.
> >> > 
> >> > You will be much happier if you hash your directories (like IC does
> >> > with the session directory) and keep maximum entries down to a
> >> > thousand or less.
> >>
> >> Using a filesystem suited for this should be an option as well, right ?
> > 
> > 
> > Which one would you suggest? I am not aware of any mainstream Linux
> > B-tree (or such) filesystems....
> 
> 
> I'm assuming Racke was speaking of ReiserFS.  From their website:
> http://www.reiserfs.org/
> 
>      ReiserFS is based on fast balanced trees. Balanced trees are more
>      robust in their performance, and are a more sophisticated algorithmic
>      foundation for a filesystem. When we started our project, there was a
>      consensus in the industry that balanced trees were too slow for
>      filesystem usage patterns. We proved that if you just do them right
>      they are better.  We have fewer worst case performance scenarios than
>      other filesystems and generally better overall performance. If you
>      put 100,000 files in one directory, we think its fine; many other
>      filesystems try to tell you that you are wrong to want to do it.
> 
> Hans Reiser and others have quite a bit of techinical information available
> at that site.
> 
> Of course, benchmarking would be required to *really* know how it compares
> (if anyone wants to build the same system twice, just with different 
> filesystems).

Aha, there is one. I think ReiserFS is a default option for Linux
"mkfs", so that would be viable.

Still in all, it might be nice to have some management for images in IC.
I was thinking of:

    1. Images table in database.

    2. The image tag checks for file, if not gives URL to IC-based page
       that pulls image from table and writes to file system.

    3. Optional entry to map image to hashed directory.

    4. External check script (just DBI) which removes directory and
       rewrites all images in hashed directories based on some algorithm
       -- and saves results appropriately in products table.

    5. The reverse script which pulls in an image directory to the
       table; must have "items" and "thumb" directory to read which are
       product images and which are regular images.

    6. Auto thumbnail generation.

    7. Change image upload to go to image table instead of to file
       system.

It would probably take me about a day to get it mostly done; but it
would take 4 or 5 more days to document and refine and test. It would be
too much of a support hassle for the list with the amount of time I can
afford to spend on it, so I probably shouldn't do it. 8-}

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

Nature, to be commanded, must be obeyed. -- Francis Bacon