Celery and the social networks

1,333 views

Published on

EuroPython 2013

Published in: Technology
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total views
1,333
On SlideShare
0
From Embeds
0
Number of Embeds
126
Actions
Shares
0
Downloads
0
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Celery and the social networks

  1. 1. agile.open.connected Celery And The Social Networks 5 Things I Have Learned During Earthquake Hackathon Andrew Mleczko
  2. 2. Andrew Mleczko Python Dev RedTurtle - Italy - Poland amleczko@redturtle.it @amleczko www.redturtle.it Andrew Mleczko
  3. 3. May, 20th - the earthquake
  4. 4. the earthquake
  5. 5. the earthquake
  6. 6. the earthquake this is not “parmesan” this is real italian PARMIGIANO ;-D
  7. 7. re-start, do it fast!
  8. 8. and the real needs the virtual idea
  9. 9. focus on storytelling
  10. 10. keep attention alive online resources newspapers radio television
  11. 11. EARTHQUAKE 20/5 first idea 24/5engage stakeholders collect specs 28/5 get the server placeholder page 27/5 design layout 4/6 hackaton 11-14/6 find companies GOLIVE 26/6 36 days from event
  12. 12. facciamoadesso.it was born ;-)
  13. 13. simply use social networks but...
  14. 14. Speed Rate Limits Stability
  15. 15. Celery can fix all off it!
  16. 16. view from the top
  17. 17. The website architecture Notification App (REST) website stories ecommerce companies products news SMS Social Networks email github.com/RedTurtle/ restarter.buildout +
  18. 18. companies sell products
  19. 19. company profile
  20. 20. the product
  21. 21. book it!
  22. 22. The website architecture Notification App (REST) website stories ecommerce companies products news SMS Social Networks email github.com/RedTurtle/ restarter.buildout +
  23. 23. how to organize tasks?
  24. 24. how to organize tasks? small atomic minimal state
  25. 25. how to organize tasks? @task def post_on_wall(facebook_id, message):     params = {}     params['id'] = facebook_id     params['message'] = message     response = requests.post(url, params=params)
  26. 26. how to organize tasks? @task def send_sms(login, password, message, phone):     payload = {'login': login,                'password': password,                'phone': phone,                'body' : message }     try:         r = requests.get('%s/send' % GATEWAY, params=payload, timeout=TIMEOUT)     except requests.exceptions.Timeout as e: send_sms.retry(e, countdown=3)
  27. 27. rate limits
  28. 28. rate limits # make sure to not hit 3rd party limits @task(rate_limit=’1/m’) def send_sms(login, password, message, phone): ...
  29. 29. rate limits # make sure we will never spam our wall @task(rate_limit=’5/h’) def post_on_wall(facebook_id, message):     params = {}     params['id'] = facebook_id     params['message'] = message     response = requests.post(url, params=params)
  30. 30. rate limits gotchas ➡ Fails on worker daemon restart ➡ Doesn’t work with multiple worker daemons ➡ External rate limits are based on many factors: ➡ who’s asking ➡ public/private info ➡ what feature
  31. 31. rate limits gotchas https://api.twitter.com/1/account/settings.json 'x-ratelimit-class': 'api_identified', 'x-ratelimit-limit': '350', 'x-ratelimit-remaining': '257' https://api.twitter.com/1/users/search.json?q=europython 'x-featureratelimit-class': 'usersearch', 'x-featureratelimit-limit': '180', 'x-featureratelimit-remaining': '179'
  32. 32. social network facebook.com/facciamoadesso @facciamoadesso
  33. 33. the results on facebook
  34. 34. lessons learned
  35. 35. Grazie. Thank you.
  36. 36. Questions ? Andrew Mleczko Python Dev Plone Framework Team member amleczko@redturtle.it tw: @amleczko
  37. 37. Credits http://www.flickr.com/photos/mgstyer/5083898608 http://www.flickr.com/photos/55483178@N02/5260890765 See also: http://blog.redturtle.it/redturtle/earthquake-plone-to-the-rescue

×