Web RTC Database CS 133 R Robert Cohn
Web. RTC & Database CS 133 R Robert Cohn 4/9/14
If this then that • • • https: //ifttt. com/recipes IOS notifications Text Mail Facebook Lights
Communication • – Client/server – Make a request, receive a response – Browser can make requests, but cannot receive a request – Server can send and receive requests – Heavyweight • Web socket – Bidirectional channel between server or browser – One endpoint must be server – Persistent connection – Lightweight communication • Cloud REST Web server Browser Req Resp Server REST Web. RTC data – Bidirectional – Peer to Peer – • No restrictions on endpoints • No restrictions on network Video, audio, data Browser Server Web socket browser
Web. RTC • Media stack: audio & video • Real time communication – Audio, video, data • Peer-to-peer • Accessible from browser: easy & available
Demo http: //simplewebrtc. com/demo. html? cs 144 r
Web. RTC & Io. T • How could it be used in your project? • Io. T connects to physical world through sensors • Audio/Video • Peer to Peer
Where Did Web. RTC Come From? • 5/2011: Google open sourced Web. RTC, using audio/video streaming technology from $70 M acquisition of Global IP Solutions • ‘Make the browser the home for innovation in real time communications’ • Real-time audio video relied on proprietary technology and plugins – Skype (acquired by Msft for $8. 5 B 5/11)
Reach • Browser – Chrome, Firefox, Opera – Not IE, Safari • App – SDK for i. OS & Android native apps – Windows/linux/mac in JS with Node-webkit
API • Set up peer connection – RTCPeer. Connection • Access local camera/audio – get. User. Media • Add data channel – RTCData. Channel
Media Stack
Demo: Connect Camera to Local Browser Video Display • http: //www. simpl. info/getusermedia/ Camera Media. Stream Video
Demo: Process Camera Data • http: //idevelop. ro/ascii-camera/ Media. Stream Video Canvas Da ta Camera
Demo: Process Camera Data 2 • http: //shinydemos. com/facekat/ Camera Media. Stream Video Canvas Object Recognition
Connecting Clients High Performance Browser Networking, Ilya Grigorik
Signaling • Session control messages: to initialize or close communication and report errors. • Network configuration: to the outside world, what's my computer's IP address and port? • Media capabilities: what codecs and resolutions can be handled by my browser and the browser it wants to communicate with?
Peer to Peer
NAT: STUN/TURN/ICE STUN TURN STUN: 86% TURN: 14% ICE High Performance Browser Networking, Ilya Grigorik
Web. RTC Protocol Stack Real Time Peer to Peer Secure High Performance Browser Networking, Ilya Grigorik
Video Example • http: //www. simpl. info/rtcpeerconnection/ind ex. html
Data • Demo: http: //www. simpl. info/rtcdatachannel/
Summary • Webrtc – Real time, secure, peer to peer communication – Audio, video, data – Open source. Browser. i. OS & Android native. Desktop
References • Web. RTC – Examples: • http: //simpl. info/ • http: //simplewebrtc. com/ – Overview: http: //www. html 5 rocks. com/en/tutorials/webrtc/ basics/ – Free book: High Performance Browser Networking, Ilya Grigorik
Discussion • • • • Serendipity Nabu. BU SEMA Clothes closet Smart. Switch Miho Beagle-Badger Running App Headphone interrupt Horton Baby Monitor Traffic control Weigh. Trackr
Database • • Relational Examples: oracle, mysql, postgresql SQL: Structured Query Language Tables – Rows: customers – Columns: email, address • Define schema in advance • Flexible queries – Select, join • Stored procedures • Transactions • 40 years of research/engineering
No. SQL • • • Key-value: Redis, riak, memcached Columnar: Hbase Document: mongodb, couchdb Graph: Neo 4 j Open source, add-ons for Heroku Different tradeoffs compared to sql – – – – – Scale up/vertical (more CPU’s), Scale out/horizontal (more systems) Flexible queries, flexible schema Durability Availability Transactions Indexing Read performance REST/TCP Integration into programming environment
Riak • Key value – Values: text, json, xml, images, video • REST • Survives nodes up/down • Supports Map/Reduce
Map Reduce • Map: for each document, emit key/value pairs • Reduce: combine all values for same key function map(String name, String document): // name: document name // document: document contents for each word w in document: emit (w, 1) function reduce(String word, Iterator partial. Counts): // word: a word // partial. Counts: a list of aggregated partial counts sum = 0 for each pc in partial. Counts: sum += Parse. Int(pc) emit (word, sum)
Redis Remote dictionary service Key Value Fast reads/writes. Often used as cache Values: hash, list, set, sorted set Durability: in memory, optional save to disk, logging • Replication • Client managed sharding • Transactions • • •
Mongo. DB • hum. MONGOus: scale out • Document: Nested data, JSON: {title: ‘c 144’, members: [‘alice’, ‘bob’]} • Queries: Find: field values, ranges, subfields • Indices based on id or others • Sharding: splitting collections over multiple instances, scale out • Replication • Map-reduce
Couch. DB • • • Document Scale from smartphone to server No transactions or locking REST View: window into document – Map-reduce • Design document: saved view
Summary Type Pro Con Example Relational Queries Fixed Schema Scale out My. SQL Postgre. SQL Column Scale out Add column Sparse column Schema determines query speed HBase Document Nested complex data Match app model Sharding No joins Mongo. DB Couch. DB Key-value Speed Scalability Ad hoc queries Redis Riak Memcached Graph Relationships Limited data No scaleout Neo 4 j
Discussion • • • • Serendipity Nabu. BU SEMA Clothes closet Smart. Switch Miho Beagle-Badger Running App Headphone interrupt Horton Baby Monitor Traffic control Weigh. Trackr
- Slides: 32