20131008 - wajug - tweetwall pro

41

Upload: pascal-alberty

Post on 28-Jun-2015

100 views

Category:

Technology


5 download

DESCRIPTION

Présentation sur l'architecture de TweetWall Pro, des API Twitter, des challenges de l'évolution du produit

TRANSCRIPT

Page 1: 20131008 - Wajug - TweetWall Pro
Page 2: 20131008 - Wajug - TweetWall Pro

Pascal Alberty@zorrobiwan

CTO Managing Partner

Page 3: 20131008 - Wajug - TweetWall Pro

History

Page 4: 20131008 - Wajug - TweetWall Pro

More than 50 web specialistsAbout 20 companies or independent people

RueDuWeb

Page 5: 20131008 - Wajug - TweetWall Pro

Where ?

Page 7: 20131008 - Wajug - TweetWall Pro

Main Architecture

● Front (Akimedia)

○ Public Website○ Private Website○ Flash Animations○ Sessions configuration management

● Back (Tesial)

○ Sessions content management

Page 8: 20131008 - Wajug - TweetWall Pro

Front - Key components (Akimedia)

● CMS Akiwi (PHP) & MySQL database (MyISAM)○ Pubic Website○ Private Website (users, eCommerce

● Flash animations○ Displaying messages and other features

● “Manager” in PHP○ Communication between Animations/Front/Back

Page 9: 20131008 - Wajug - TweetWall Pro

Back - Key Components (Tesial)

● Engine○ Java web application○ API used by Front for data management

■ sessions, tweets, moderation, tweetos,...

● Batch○ Java web application○ Formerly grabbing Tweets○ Grabbing pictures (avatars & medias)

Page 10: 20131008 - Wajug - TweetWall Pro

Technical Infrastructure

● Front/Back Server

● DB Servers○ Front / Back○ Replication (fail over)

● Dev Server○ dev (front / back)○ pré-prod (front / back)

Page 11: 20131008 - Wajug - TweetWall Pro

SVN

● KISS

● dev = trunk● pre-prod = branch● prod = tag on branch or trunk

● front = release by switch● back = release by packaging

Page 12: 20131008 - Wajug - TweetWall Pro

Back Software Architecture

Maven 2Spring 3.1Hibernate 3.2ehcache 1.5Twitter4J 3Maya 0.2...

Page 13: 20131008 - Wajug - TweetWall Pro

Back Software Architecture

● DTO & DAO○ Data Structure & persistence

■ session, tweet, tweetos, hashtags, ...● Services

○ Business functionalities○ Transaction management

● Clients○ Engine○ Batches

Page 14: 20131008 - Wajug - TweetWall Pro

Engine

● Java Web Application

● API REST○ CRUD operations

● Used by Front for data management

● Call Services layer

Page 15: 20131008 - Wajug - TweetWall Pro

Batches

● Java Web Application

● Quartz Jobs○ Formerly Tweets Grabbing ○ Avatars Grabbing○ Pictures Grabbing

● Call Services Layer

Page 16: 20131008 - Wajug - TweetWall Pro

Challenges

● Scalability○ SaaS and Agency are growing

● Twitter○ New technical and business constraints

● Product○ Must evolve by integrating other social networks

Page 17: 20131008 - Wajug - TweetWall Pro

Twitter API

● Let’s talk about Twitter API

Page 18: 20131008 - Wajug - TweetWall Pro

Twitter APIs

● APIs○ Search API○ REST API○ Streaming API○ https://dev.twitter.com/docs/history-rest-search-api

● Versions○ API version 1 (deprecated)○ API version 1.1

Page 19: 20131008 - Wajug - TweetWall Pro

Rate limiting

● Rate limit window duration○ 15 minutes

● Requests allotted○ per user○ via application-only auth

● Example○ GET statuses/user_timeline○ per user: 150 requests per 15 minutes○ via app: 300 requests per 15 minutes

https://dev.twitter.com/docs/rate-limiting/1.1/limits

Page 20: 20131008 - Wajug - TweetWall Pro

Other technical limits

● Direct messages○ 250 per day

● Tweets○ 1,000 per day○ Retweets are counted as Tweets.

● Changes to account email○ Four per hour

● Following○ 1,000 per day

● Following (account-based)○ up to following 2,000 other users

Page 21: 20131008 - Wajug - TweetWall Pro

Platform objects

● Tweets can be found alone, within user objects, but most often within timelines

● Users can be found tweeting, following, and favoriting on Twitter

● Entities are most often found within Tweets● Places can be found throughout the natural universe,

but typically only appear attached to Tweets on Twitter

Page 22: 20131008 - Wajug - TweetWall Pro

Objects type

● JSON !

● XML output will be dropped soon○ Only JSON output with API 1.1

● Be careful with ids (64 bits)○ use String version (especially if using Javascript)○ Twitpocalypse

■ https://dev.twitter.com/docs/twitter-ids-json-and-snowflake○ Idpocalypse

■ https://dev.twitter.com/blog/64-bit-twitter-user-idpocalypse

Page 25: 20131008 - Wajug - TweetWall Pro

Entities / Entity Example

● Hashtags, Medias, URLs, User mentions, Symbols

● No need to parse● Data used for display also (ex: display_url)

Page 26: 20131008 - Wajug - TweetWall Pro

Place example

https://api.twitter.com/1/geo/id/247f43d441defc03.json

Page 27: 20131008 - Wajug - TweetWall Pro

Libraries

● PHP○ Twitter-async (https://github.com/jmathai/twitter-

async)○ tmhOAuth (https://github.

com/themattharris/tmhOAuth)○ Zend Framework (http://framework.zend.

com/manual/1.12/en/zend.service.twitter.html)● Java

○ Twitter4J (http://twitter4j.org/)

https://dev.twitter.com/docs/twitter-libraries

Page 28: 20131008 - Wajug - TweetWall Pro

Twitter4J

● Unofficial Java library for the Twitter API● 100% Pure Java (5+)● Android platform and Google App Engine

ready● Zero dependency : No additional jars

required● Built-in OAuth support● Out-of-the-box gzip support● 100% Twitter API 1.1 compatible

Page 29: 20131008 - Wajug - TweetWall Pro

Tools

● Twurl○ https://github.com/marcel/twurl○ "curl" for Twitter API○ Manage access tokens (authentication)

● Apigee Console○ https://apigee.com/console○ Free console to execute APIs

Page 30: 20131008 - Wajug - TweetWall Pro

Search API

● Similar to http://search.twitter.com

● Criteria○ terms○ geocode○ language ("Language detection is best-effort")○ count, until, since-id, max-id○ result type: mixed, recent, popular○ include entities

● Paginated !○ you have to manage this by yourself

Page 31: 20131008 - Wajug - TweetWall Pro

REST API

● Timelines● Tweets● Direct Messages● Friends & Followers● Users● Suggested Users● Favorites● Lists● Saved Searches● Places & Geo● Trends● Spam Reporting● OAuth● Help

Page 32: 20131008 - Wajug - TweetWall Pro

Streaming API

● Persistent HTTP connection○ until you decide to close it

● Could be reeeeaaaaaaally huge !○ Think about you architecture (hard and soft) !○ Separate storage and consumption

● Only one stream opened at a time

● Could be tricky to managed○ Use a library

Page 33: 20131008 - Wajug - TweetWall Pro

Streaming API endpoints groups

● Public Streams○ GET statuses/sample○ POST statuses/filter○ GET statuses/firehose (limited access)

● User Streams○ Data and events for a specific user

● Site Streams (beta and limited access)○ Real time update for large number of users

Page 34: 20131008 - Wajug - TweetWall Pro

About the challenges

● Scalability● Twitter constraints● Product evolution

=> Use of Twitter Stream API=> Other Social Networks integration

=> Maya

Page 35: 20131008 - Wajug - TweetWall Pro

Maya

Abstraction layer for feed andpost

Used in TWP as the input sourcefor media

Page 36: 20131008 - Wajug - TweetWall Pro

Maya - General architecture

Listener

Listener

SessionSession

Page 37: 20131008 - Wajug - TweetWall Pro

Maya - concepts

● Post: content emitted on a (social) network by a user

● Feed: a collection of posts matching a set of filters (PostFilter)

● FeedOperator: the service to register, manage stop and restart feeds

Page 38: 20131008 - Wajug - TweetWall Pro

Maya twitter plugin

● Backed by Twitter4J● Rely on the live stream twitter API● Challenges

○ Adding new feeds on the fly without losing any history

○ Single channel for all feeds, need to identify to which feed(s) a tweet belongs to

● Demo!

Page 39: 20131008 - Wajug - TweetWall Pro

Front Evolutions

● From Pull to Push○ NodeJS

● Manager from PHP to JS○ NodeJS

● HTML5 Animations

Page 40: 20131008 - Wajug - TweetWall Pro

Next Improvements

● Queuing traitement with SI○ Message traitement○ Medias grabbing and/or treatment

● Adding other social networks

● Better scalability - reliability - performance○ load balancing○ replication○ nginx○ ...

Page 41: 20131008 - Wajug - TweetWall Pro

Q/A