Upgrade to Pro — share decks privately, control downloads, hide ads and more …

background job patterns

background job patterns

Matt Yoho

May 23, 2012
Tweet

More Decks by Matt Yoho

Other Decks in Programming

Transcript

  1. Event occurs, job enqueued Worker instantiate job model Load AR

    object(s) model Create AR object(s) Hit API job {id, token} job goes away Wednesday, May 23, 12
  2. Event occurs, job enqueued Worker instantiate job model Load AR

    object(s) model Create AR object(s) Hit API job {id, token} Wait 90s re-enqueue self Wednesday, May 23, 12
  3. Event occurs, job scheduled Worker instantiate job model Load AR

    object(s) model Create AR object(s) Hit API job {id, token} job goes away 90s enqueue job Wednesday, May 23, 12
  4. CancelAbandonedOrders: cron: "*/5 * * * *" clear_leaderboards_contributors: cron: "30

    6 * * 1" class: ClearLeaderboards queue: low args: contributors description: "Reset the weekly leaders" Wednesday, May 23, 12
  5. May want to respond to traffic, load, rate-limiting, by adding

    or subtracting workers, changing interval Wednesday, May 23, 12
  6. models, views, controllers jobs, client libraries message queue m “User

    123 linked twitter account with token ‘abc’” Wednesday, May 23, 12
  7. models, views, controllers jobs, client libraries message queue m “User

    123 linked twitter account with token ‘abc’” Wednesday, May 23, 12
  8. models, views, controllers jobs, client libraries message queue m “Every

    30 seconds, I’ll hit the twitter api with token ‘abc’ and then the feed engine api for user 123” Wednesday, May 23, 12
  9. pros: increased flexibility & control horizontal scaling smaller apps fewer

    specs per app cons: burden of complexity on you Wednesday, May 23, 12