Talk at Stanford's CS442 (High Productivity and Performance with Domain Specific Languages in Scala http://www.stanford.edu/class/cs442/), on Rogue. 5/24/2011
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
CS442 - Rogue: A Scala DSL for MongoDB
1. rogue:
a scala dsl for mongodb
CS442 - 5/24/2011
Jorge Ortiz (@jorgeortiz85)
2. what is foursquare?
location-based social network - “check-in” to bars,
restaurants, museums, parks, etc
friend-finder (where are my friends right now?)
virtual game (badges, points, mayorships)
city guide (local, personalized recommendations)
location diary + stats engine (where was I a year ago?)
specials (get rewards at your favorite restaurant)
4. foursquare: the tech
Nginx, HAProxy
Scala, Lift
MongoDB, PostgreSQL (legacy)
(Kestrel, Munin, Ganglia, Python, Memcache, ...)
All on EC2
5. what is mongodb?
fast, schema-less document store
indexes & rich queries on any attribute
sharding, auto-balancing
replication
geo-indexes
6. mongodb: our numbers
8 clusters
some sharded, some not
some master/slave, some replica set
~40 machines (68.4GB, m2.4xl on EC2)
2.3 billion records
~15k QPS
10. mongodb: query example
val query =
(BasicDBOBjectBuilder
.start
.push(“mayorid”)
.add(“$lte”, 100)
.pop
.push(“veneuname”)
.add(“$eq”, “Starbucks”)
.pop
.get)
11. rogue: a scala dsl for mongo
type-safe
all mongo query features
logging & validation hooks
pagination
index-aware
cursors
http://github.com/foursquare/rogue
13. rogue: code example
val vs: List[Venue] =
(Venue where (_.mayorid <= 100)
and (_.venuename eqs “Starbucks”)
and (_.tags contains “wifi”)
and (_.latlng near
(39.0, -74.0, Degrees(0.2))
orderDesc (_._id)
fetch (5))