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

Distributed Systems talk at PDX Python

Distributed Systems talk at PDX Python

This is an expanded version of my bar camp one, a shorter more python version of what will be my OS Bridge talk.

Avatar for wraithan

wraithan

April 11, 2012
Tweet

More Decks by wraithan

Other Decks in Programming

Transcript

  1. Redis • Pub/Sub • Key value store • Fast •

    Interesting data types Wednesday, April 11, 12
  2. Pub/Sub • Channel based • Broadcast • Like UDP •

    Doesn’t require a broker Wednesday, April 11, 12
  3. from redis import StrictRedis # Instantiate a redis client client

    = StrictRedis() # Turn on Pub/Sub mode pubsub = client.pubsub() # Subscribe to 'in' and start listening. pubsub.subscribe('in') for message in pubsub.listen(): print(message['data']) Wednesday, April 11, 12
  4. from redis import StrictRedis # Instantiate a redis client client

    = StrictRedis() # Publish to the 'in' channel client.publish('in', 'Hello World') Wednesday, April 11, 12
  5. Gotchas • Subscribe takes your redis client from you •

    listen() is blocking Wednesday, April 11, 12
  6. Case Study: ZenIRCBot • IRC is a simple idea •

    Lots of us hang out on IRC • I built it Wednesday, April 11, 12
  7. Architecture • Uses Redis for both storage and pub/sub •

    Micro-service Architecture Wednesday, April 11, 12
  8. Services • Only require a Redis client and JSON lib

    • Can run anywhere they can get access to Redis • Can be written in any language Wednesday, April 11, 12
  9. { "version": 1, "type": "privmsg", "data": { "sender": "Wraithan", "channel":

    "#pdxbots", "message": "Hello IRC World!" } } Wednesday, April 11, 12
  10. Stuff that is cool • Pub/Sub is cool • Distributed

    processes are cool • Ergo, ZenIRCBot is cool Wednesday, April 11, 12