Telephony with OpenShift Twilio and MongoDB

7,268 views

Published on

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,268
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
19
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Telephony with OpenShift Twilio and MongoDB

    1. 1. Telephony Applications with MongoDB, OpenShift, & TwilioMark AtwoodDeveloper Evangelist for Red HatOpenShiftme@mark.atwood.nameTwitter @fallenpegasus
    2. 2. What is OpenShift? Red Hat cloud Platform as a Service Free as in beer, Free as in speech Languages: Python, Java, Ruby, Node, PHP, & DIY Storage: Filesystem, MySQL, Postgres, MongoDB No lock-in, no proprietary APIs Sign up at http://openshift.redhat.com Promo code SEATTLE 2
    3. 3. What is Twilio? A cloudy API for telephony REST interface to the PSTN: Voice & SMS Pay by the drink 3
    4. 4. How Twilio voice works Someone calls the number Twilio answers the phone Twilio does HTTP REST to our app Our app replies with some "TwiML" Twilio does what the app told it to Twilio or the caller hangs up the phone 4
    5. 5. How Twilio SMS works Someone texts to the number Twilio receives the text & all metadata Twilio does HTTP REST to our app Our app replies with some "TwiML" Twilio does what the app told it to 5
    6. 6. What is MongoDB? If you have to ask that, you shouldnt be here! Easy to use JSONic Document Store 6
    7. 7. What is Python & What is Bottle? My favorite programming language My favorite web framework Supported by OpenShift Drivers for MongoDB & for Twilio 7
    8. 8. A simple app: SMS Group SMS group chat http://github.com/fallenpegasus/openshift-smsgroup +1-XXX-XXX-XXXX SMS .join to join SMS .leave to leave 8
    9. 9. Glue it all together Get an OpenShift account Get a Twilio account Spin up "smsgroup" app in OpenShift Attach it to your Twilio account Play! 9
    10. 10. Agenda for Demonstration Look at the app at twilio.com Look at the app at openshift.com SSH into the app Port forward from local to remote MongoDB Run local MongoDB clients 10
    11. 11. 11
    12. 12. Some useful software design guidelines Let the language, the libraries, & remote services do the boring work Dont keep state in the app, use a data layer Use queuing to smooth load 12
    13. 13. Dont keep state in the app Keep it in the data layer instead OpenShift might restart or scale the instance at any time Dont waste time keeping complex data in the instance Dont try to write your own database server 13
    14. 14. Dont keep state in the app Keep it in the data layer instead OpenShift might restart or scale the instance at any time Dont waste time keeping complex data in the instance Dont try to write your own database server MongoDB is an excellent solution 14
    15. 15. Use queuing to smooth the load Dont depend on "their" capacity Getting local storage quickly is easier than provisioning more CPU, IO ops, or network bandwidth 15
    16. 16. Use queuing to smooth the load Dont depend on "their" capacity Getting local storage quickly is easier than provisioning more CPU, IO ops, or network bandwidth And its cheaper 16
    17. 17. Some Queue options roll your own SQS AQMP RabbitMQ etc 17
    18. 18. Queue options roll your own SQS AQMP RabbitMQ etc MongoDB "find_and_modify" 18
    19. 19. def worker: while True: time.sleep(1) while True: msg = mongo_db.sendq.find_and_modify(remove = True) if (msg == None): break message = twilio_client.sms.message.create( to = msg[To], from_ = twilio_fromnum, body = msg[Body]) 19
    20. 20. Conclusion Telephony apps are easy and fun You can build your own Using OpenShift, Twilio, and MongoDB 20
    21. 21. Questions? 21

    ×