22
Scaling Telephony with Python:The Plivo Learnings Nishad Musthafa Plivo Inc Saturday, July 6, 13

Scaling telephony

Embed Size (px)

DESCRIPTION

My Talk at Pycon

Citation preview

Page 1: Scaling telephony

Scaling Telephony with Python:The Plivo Learnings

Nishad MusthafaPlivo Inc

Saturday, July 6, 13

Page 2: Scaling telephony

About me

• First engineer at Plivo

• Dig open source

• Zen of python

• twitter.com/_nishad

Saturday, July 6, 13

Page 3: Scaling telephony

Plivo Open Sourcegithub.com/plivo/plivoframework/

ESL

Saturday, July 6, 13

Page 4: Scaling telephony

How does plivo work?

• Plivo gets a call.

• Plivo needs to know what to do ?

• Plivo uses a callback like http://customercallback.com/

Saturday, July 6, 13

Page 5: Scaling telephony

Initial setup

Media Server

DBCustomer API calls

Callbacks

Saturday, July 6, 13

Page 6: Scaling telephony

Issues with this setup

• Business logic vs Telephony

• Code updates

• Scaling Issues

Saturday, July 6, 13

Page 7: Scaling telephony

Solution

Media Server

DBCustomer API calls

CallbacksDjango

Saturday, July 6, 13

Page 8: Scaling telephony

Did that solve it?Yes

Did we go ahead and use it?Not quiet.

Saturday, July 6, 13

Page 9: Scaling telephony

There are still issues

• Performance issues with Django

• Security issues

Saturday, July 6, 13

Page 10: Scaling telephony

Enter proxy

• A lightweight proxy server written in flask

• This acts as both an in and out proxy

• Has the goodness of gevent

Saturday, July 6, 13

Page 11: Scaling telephony

Solution

Media Server

DB

Customer API calls

Proxy

DjangoCallbacks

Saturday, July 6, 13

Page 12: Scaling telephony

So far so good

• Added a django based UI for our existing customers to add and manipulate their user related data.

• There was no current need for an api for manipulation of these data or so we thought.

Saturday, July 6, 13

Page 13: Scaling telephony

New Customer Alert!!• We had a new customer who urgently

needed a bunch of api’s ready in a week to migrate a large number of minutes to our platform.

• We didn’t have any API’s

• We had one week. It wasn’t a friendly mail. It was an ultimatum

Saturday, July 6, 13

Page 14: Scaling telephony

Tasty Pie to the rescue

• Tasty pie from toast driven is an excellent framework to create an API from your django models. We also did evaluate piston. But there were basic issues there.

Saturday, July 6, 13

Page 15: Scaling telephony

Piston is lacking

• /Account/id/Subaccount/

• /Account/subaccountid/

• The above two are apis on the same model

• Piston doesn’t let you do this.

Saturday, July 6, 13

Page 16: Scaling telephony

Tasty Pie BasicsResource

Retrieve List

Retrieve Detail

Saturday, July 6, 13

Page 17: Scaling telephony

Tasty Pie BasicsCreate

Update

Delete

Saturday, July 6, 13

Page 18: Scaling telephony

Tasty Pie Best Practices• Derive ModelResource to create a

Resource type that’s specific to your use case. Eg: Error returning.

• Dehydrate: Use the Resource’s dehydrate function to add data that isn’t available in the models. Eg: cost as a sum of 2 fields

• Filters: The build_filters function allows you specify filters based on fields of models. Be careful using them.

Saturday, July 6, 13

Page 19: Scaling telephony

Speedups

• Johnny Cache

• Django celery

Saturday, July 6, 13

Page 20: Scaling telephony

One week later

Saturday, July 6, 13

Page 21: Scaling telephony

Questions anyone?

Saturday, July 6, 13

Page 22: Scaling telephony

Thank you!!

Saturday, July 6, 13