Upload
nishad-musthafa
View
1.309
Download
0
Embed Size (px)
DESCRIPTION
My Talk at Pycon
Citation preview
Scaling Telephony with Python:The Plivo Learnings
Nishad MusthafaPlivo Inc
Saturday, July 6, 13
About me
• First engineer at Plivo
• Dig open source
• Zen of python
• twitter.com/_nishad
Saturday, July 6, 13
Plivo Open Sourcegithub.com/plivo/plivoframework/
ESL
Saturday, July 6, 13
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
Initial setup
Media Server
DBCustomer API calls
Callbacks
Saturday, July 6, 13
Issues with this setup
• Business logic vs Telephony
• Code updates
• Scaling Issues
Saturday, July 6, 13
Solution
Media Server
DBCustomer API calls
CallbacksDjango
Saturday, July 6, 13
Did that solve it?Yes
Did we go ahead and use it?Not quiet.
Saturday, July 6, 13
There are still issues
• Performance issues with Django
• Security issues
Saturday, July 6, 13
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
Solution
Media Server
DB
Customer API calls
Proxy
DjangoCallbacks
Saturday, July 6, 13
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
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
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
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
Tasty Pie BasicsResource
Retrieve List
Retrieve Detail
Saturday, July 6, 13
Tasty Pie BasicsCreate
Update
Delete
Saturday, July 6, 13
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
Speedups
• Johnny Cache
• Django celery
Saturday, July 6, 13
One week later
Saturday, July 6, 13
Questions anyone?
Saturday, July 6, 13
Thank you!!
Saturday, July 6, 13