animoto/jammit — comment on commit ce2bdf1afd2b9c4c409787aafac4f6b2eb188ce0
File: lib/jammit/cdn_config.rb line 92
By dmag:

> we'll never need to hit Redis again after boot?

No, we hit Redis every deploy. (unless you meant Rails boot)

1) before copying assets to S3, we check the "has this commit been sent to S3?" flag for this commit in Redis.
- if the flag is there, but pending, we spin for a minute and try again (pretend it's not there if it's too old)
- If it's there and marked done, we exit
- if it's not there, we go on to step 2.
2) The first server to start running a particular commit will deploy (sync) all assets to S3. It then tells Redis "assets in this commit have been send to S3" (This should key expire after month or two, so no cleanup needed.) For the next month, nobody will need to talk to S3 when running this commit.

> So if you are constantly bouncing servers on two boxes with different commits then they will be running Jammit each time, but nobody should end up with the wrong assets.

Actually, what should happen is that the full S3 upload gets run on the *first* deploy of each commit only. Thereafter the script should see the commit is "already uploaded" and exit without talking to S3 at all. Bouncing servers should read Redis once and not talk to S3 at all. (Each server may reference slightly different assets in S3, but that's because they are running different commits. S3 will already have both sets of files referenced.)