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.

Im building multi-server support for a file upload site Im running. When images are uploaded.... they are thumbnailed and stored on the main front-end server, until cron executes (every 10 mins) and moves them to storage servers, so for the first 10 mins, they will reside, and be served off the main front-end server.

When a file is uploaded, users are given embed codes... which is a thumbnail url + link to the full size, which is a html page. So it might be something like http://www.domain.com/temp_content/filename.jpg which links to http://www.domain.com/file-ID

Except in 10 mins, http://www.domain.com/temp_content/filename.jpg wont exist, it will be http://server1.domain.com/thumbs/filename.jpg

if the user grabbed the original code... the thumb file will be broken.

I COULD move the file to its destination, without cron, but that will take time, and will lag the script until the move is complete. I also dont like to have users running commands like that, I'd rather have the server do them at regular intervals.

Anything else I can do?

share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

I would start by always abstracting the filename. It will save you a lot of hassle.

You could then hand out the second link (server1.domain.com) as that's where the majority of requests will go and then handle edge cases where the file hasn't yet been moved with mod_rewrite. Eg:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(.*)$ http://www.domain.com/$1 [R=302]

That will 302 (temporarily) redirect requests to files that don't exist to the other domain.

Alternatively you could make storage from the first server available from the second.

share|improve this answer
    
+1: better than what I was typing! –  tomjedrz Jul 1 '09 at 19:37
add comment

Could you change the message sent to users to include both URLs?

You could also make a custom error page that allowed users to enter the URL they were given and have it automatically translated.

share|improve this answer
    
use embeds the thumb into their site..... after 10 mins, thumb is a red X. –  user11350 Jul 1 '09 at 21:38
add comment

Your Answer

 
discard

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