Weightlifting at SimplySocial

40
Weightlifting @

description

How SimplySocial uses Python

Transcript of Weightlifting at SimplySocial

Page 1: Weightlifting at SimplySocial

Weightlifting@

Page 2: Weightlifting at SimplySocial

@bogdan

Page 3: Weightlifting at SimplySocial

@SIMPLYSOCIAL

Page 4: Weightlifting at SimplySocial

+ =

Page 5: Weightlifting at SimplySocial

+ =

Page 6: Weightlifting at SimplySocial

+ =?

Page 7: Weightlifting at SimplySocial
Page 8: Weightlifting at SimplySocial

+ =

Page 9: Weightlifting at SimplySocial

ARCHITECTURE

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

Page 10: Weightlifting at SimplySocial

LIFE OF A REQUEST

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 01 API N...

APP 01 APP 01 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

API 02

APP 02

Page 11: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

LIFE OF A REQUEST

Page 12: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

LIFE OF A REQUEST

Page 13: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

LIFE OF A REQUEST

2M x

Page 14: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

LIFE OF A REQUEST

Page 15: Weightlifting at SimplySocial

USE OF PYTHON

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

Page 16: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 17: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 18: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 19: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 20: Weightlifting at SimplySocial

CAN I HEAR A BOOO FOR ?

Page 21: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 22: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 23: Weightlifting at SimplySocial

PYTHON ON APPSERVERS

AWS EC2

Ubuntu 12.04

Chef

NGINX + PHP FPM

FABRIC

DEPLOYMENT

Metrics

Logging

Page 24: Weightlifting at SimplySocial

USE OF PYTHON

METRICS

AWS EC2

Ubuntu 12.04

Chef

NGINX + PHP FPM

FABRIC

Metrics

Logging

Page 25: Weightlifting at SimplySocial

INTRODUCING OSSIE

METRICS GATHERING

REPORTING STATS THROUGH A SIMPLE WEB INTERFACE

INTERACTION WITH RUNNING PROcesses

BACKEND BY STATSD and GRAPHITE

Page 26: Weightlifting at SimplySocial

INTRODUCING OSSIE

import ossie

stat = ossie.Client("arcade.random_worker")

stat.gauge("a_metric", 256)

stat.timer("random.metric", 1.28)

with stat.timer("random.metric.with"): # do something that requires an amount of time # ossie client will report the right time

Page 27: Weightlifting at SimplySocial
Page 28: Weightlifting at SimplySocial

USE OF PYTHON

logging

AWS EC2

Ubuntu 12.04

Chef

NGINX + PHP FPM

FABRIC

Metrics

Logging

Page 29: Weightlifting at SimplySocial

logginG

FULL JSON logging

EVEN nginx logs json

powered by fluentd + S3

FUTURE: Logs can be searched by elasticsearch + kibana

Page 30: Weightlifting at SimplySocial

api.gosimplysocial.com

app.gosimplysocial.com

API 01 API 02 API N...

APP 01 APP 02 APP N...

BACKEND01

BACKEND02

BACKENDN...

DBs

USE OF PYTHON

Page 31: Weightlifting at SimplySocial

AWS EC2

Ubuntu 12.04

Chef

FABRIC

SUPERVISORD

Metrics

SUPERVISORD

Workers

Logging

Page 32: Weightlifting at SimplySocial

AWS EC2

Ubuntu 12.04

Chef

FABRIC

WORKERS

Metrics

SUPERVISORD

Workers

Logging

Page 33: Weightlifting at SimplySocial

INTRODUCING ARCADE

queue based workers framework

Convention over configuration

simple deployment

detailed logging and monitoring

Page 34: Weightlifting at SimplySocial

INTRODUCING ARCADE

CRAWL INSIGHTS

CRAWL PAGES

CRAWL EVENTS

ARCADEFACEBOOKCRAWL

Page 35: Weightlifting at SimplySocial

INTRODUCING ARCADE

CRAWL INSIGHTS

CRAWL PAGES

CRAWL EVENTS

ARCADEFACEBOOKCRAWL

queue pythonworkers

job types

Page 36: Weightlifting at SimplySocial

INTRODUCING ARCADEfacebook/!"" __init__.py!"" common#   !"" __init__.py#   !"" crawler/#   !"" exception.py#   !"" facebook_model.py#   !"" helper.py#   !"" indexer/#   !"" ...!"" config#   !"" __init__.py#   !"" config.yml#   $"" env#   !"" __init__.py#   !"" crawler.py#   !"" ......

!"" tests#   !"" __init__.py#   !"" fixtures#   #   !"" crawler_feed.yml#   #   !"" ...#   #   $"" stream_routing.yml#   !"" test_crawler_feed.py#   !"" ...#   $"" test_stream_worker.py$"" workers !"" __init__.py !"" crawler.py !"" ...

Page 37: Weightlifting at SimplySocial

from arcade.worker import TaskWorkerfrom arcade.helper import retry, task

# [...]

class FacebookCrawler(TaskWorker):

def __init__(self, dependencies): super(FacebookCrawler, self).__init__(dependencies)

@task("default", "crawl") def crawl_feed(self, data): """ Job type: * uid * last_crawl """ feed = CrawlerFeedModel(self) feed.crawl(data)

def before_each(self, data): # [...]

def run(dependencies): try: FacebookCrawler(dependencies).run() except: dependencies.get("exception").capture_exception()

Page 38: Weightlifting at SimplySocial

AND MANY MORE:

continuous integration

RELIABLE ALERTING

CLOUDWATCH to STATSD

REAL USER MONITORING

Page 39: Weightlifting at SimplySocial

Q/A

Page 40: Weightlifting at SimplySocial

Thanks!