Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a rails app that dynamically generates thumbnails on request and saves the result locally to make it faster to serve up the same one again. We use the following url structure:

/thumbnails/99999/large.jpg

Where 99999 is the database record the thumb is linked to. The problem is the number of records with thumbnails is maxing out the directory limit.

Any ideas on how to get around this while maintaining the built in automatic cache retrieval that rails gives you with the public folder?

The end goal is to be able to dynamically generate arbitrary thumbnails on demand and cache the result locally.

share|improve this question

1 Answer 1

Use subdirectories, like:

/thumbnails/001/001/large.jpg
/thumbnails/999/999/large.jpg

and so on. Create as many subdirectories as you think are necessary for the unique identifier of your image, e.g.,:

/thumbnails/999/999/999/999large.jpg

You may need to be aware of the inode limits on your filesystem.

share|improve this answer
    
and how do I then tell nginx to map /thumbnails/99999/large.jpg to /thumbnails/099/999/large.jpg ? Or would you suggest we change it on the web request side too? More tedious than I was hoping, but I guess doable. –  chrishomer Aug 13 '12 at 18:11
    
Well, certainly changing the request so that it hits the physical file would be best, as it removes a complication. It's possible to do a redirect through some regex, but that will be a lot more trouble than it's worth. –  cjc Aug 13 '12 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.