2. About Monica Wilkinson Loves the web and data portability.
Developer Advocate @ Cloud Foundry
12 years development experience.
Last 5 years in Social Web
Open Web Standards Advocate
Contact Me: @ciberch
mwilkinson@vmware.com
CONFIDENTIAL
2
Friday, January 27, 12
3. Agenda
1.Overview of Cloud Foundry
2.What is Activity Streams ?
3.Building an Activity Stream Engine
CONFIDENTIAL
3
Friday, January 27, 12
4. About Cloud Foundry The first Open PaaS
Multi(n) Languages, Frameworks,
Services & Clouds
Open Source
CONFIDENTIAL
4
Friday, January 27, 12
8. STEP 3 - Push your code to Cloud Foundry
vmc push
• Detects runtime automatically.
• In addition if you have manifest.yml vmc will read:
• App Name
• App Instances
• Services to bind to App
•Demo
CONFIDENTIAL
8
Friday, January 27, 12
10. http://activityStrea.ms
Activity Streams is a simple open specification used to describe social
actions around the web.
The goal of Activity Streams is data portability
Some publishers of Activity Streams: Socialcast, MySpace, Facebook
and G+
The default format is JSON but Atom is also supported. The JSON
format was added after we saw some initial limitations with JSON
Core concepts are: Actor, Verb, Object and Target
CONFIDENTIAL
10
Friday, January 27, 12
12. What is an Activity Stream Engine ?
An activity stream engine allows you to publish events and subscribe to
events.
Many activity stream engine support aggregation of events via Streams.
Many activity stream engines support fanning out activities to subscribers.
Many activity stream engines tailor the stream to the reader providing Key
Stats and Contextual Info. Example: Monica with 1000 followers or Bank
of America established in 1989
CONFIDENTIAL
12
Friday, January 27, 12
14. What should we use to store Activities ?
Key-Value Column Document Graph
Redis, Cassandra, MongoDB Neo4J
Riak HBase
CONFIDENTIAL
14
Friday, January 27, 12
15. Mongo DB schema-less documents are perfect
for Activities
Key-Value Column Document Graph
MongoDB
(so easy)
CONFIDENTIAL
15
Friday, January 27, 12
16. About MongoDB
1. No-SQL database development : {
2. Stores JSON-style tools: many,
documents with language_support: superb,
embedded documents
=
agility: high
3. Horizontally scalable },
production: {
4. Full Indexing Support
speed: fast
5. Open Source so great fault_tolerance: true
ORMs and drivers.
scalability: high
CONFIDENTIAL
16
Friday, January 27, 12
19. Step 2 - Expose helpers for the queries
The most important is to be able to list the activities in
descending order by published time.
It is also important to hydrate any objects for which we
have references
With Mongoose you can do:
this.getActivityStream = function(n, fx)
{ Activity.find().sort('published',
'descending').limit(n).populate('target').run
(fx);
}
More at: https://github.com/cloudfoundry-samples/
activity-streams-mongoose
CONFIDENTIAL
19
Friday, January 27, 12
20. How do we make our engine faster and more
scalable ?
Add support for PubSub
In a PubSub model as soon as an event is published it
gets sent to all the subscribers.
The Publisher doesn’t know who the subscribers are, it
simply knows where to publish.
Redis has nice support for Pub Sub http://redis.io/topics/
pubsub
CONFIDENTIAL
20
Friday, January 27, 12
22. Using Socket.io
Server Side:
• Subscribe to a Stream
• When there is a new event send it to the client as JSON
Client Side
• Add support to publish activities to the Stream
• Change the client rendering to use ActivityStrea.ms
Benefits
• Richer messaging
• Activity Syndication
CONFIDENTIAL
22
Friday, January 27, 12