hermes: free the data! distributed computing with mongodb

34
Hermes: Free the Data! Distributed Applications with MongoDB Presented by Warren Chang, VP Engineering @ Borderfree

Upload: mongodb

Post on 15-Apr-2017

2.488 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Hermes: Free the Data! Distributed Computing with MongoDB

Hermes: Free the Data!Distributed Applications with MongoDB

Presented by Warren Chang, VP Engineering @ Borderfree

Page 2: Hermes: Free the Data! Distributed Computing with MongoDB

2

Hermes {hur'-meez}Hermès

Hermes 69230

Page 3: Hermes: Free the Data! Distributed Computing with MongoDB

3

Iconic French Brand since 1837Known for luggage and handbags

Page 4: Hermes: Free the Data! Distributed Computing with MongoDB

4

(hur'-meez)Greek God,Divine Messenger of the GodsLink between the mortals and Olympians

Page 5: Hermes: Free the Data! Distributed Computing with MongoDB

5

HermesIt’s a conceptSimple, Persisted, Message Bus

Page 6: Hermes: Free the Data! Distributed Computing with MongoDB

6

Event driven messaging Distributed Applications Flexible architecture Self-contained business rules

Page 7: Hermes: Free the Data! Distributed Computing with MongoDB

7

Event driven messaging Distributed Applications Flexible architecture Self-contained business rules

Page 8: Hermes: Free the Data! Distributed Computing with MongoDB

8

Event driven messaging Distributed Applications Flexible architecture Self-contained business rules

Page 9: Hermes: Free the Data! Distributed Computing with MongoDB

9

Event driven messaging Distributed Applications Flexible architecture Self-contained business rules

Page 10: Hermes: Free the Data! Distributed Computing with MongoDB

10

Lets take a step back

Page 11: Hermes: Free the Data! Distributed Computing with MongoDB

11

Consulting

Publishing

Ad Tech

Page 12: Hermes: Free the Data! Distributed Computing with MongoDB

12

Page 13: Hermes: Free the Data! Distributed Computing with MongoDB

currencies60+

countries100+

customers170+

2014 GMV$550M

+

Borderfree helps online retailers go global

Page 14: Hermes: Free the Data! Distributed Computing with MongoDB

14

2012Tech Stack Diversity

Java

Page 15: Hermes: Free the Data! Distributed Computing with MongoDB

15

2013Tech Stack Diversity

JavaPHP

Page 16: Hermes: Free the Data! Distributed Computing with MongoDB

16

2014Tech Stack Diversity

JavaPHPnode.jspythonscala

Page 17: Hermes: Free the Data! Distributed Computing with MongoDB

17

THE CHALLENGE

Page 18: Hermes: Free the Data! Distributed Computing with MongoDB

18

The Challenge J2EE Best Practices Enterprise Application Server

Weblogic Single Database (Oracle) Hibernate ORM 3 digit growth YOY Speed to market mentality Data Lock-in

Page 19: Hermes: Free the Data! Distributed Computing with MongoDB

19

WHAT DO WE DO?

Page 20: Hermes: Free the Data! Distributed Computing with MongoDB

20

The ChallengeWhat to do about the data? Decouple Stream Persist Monitor

Page 21: Hermes: Free the Data! Distributed Computing with MongoDB

21

SOLUTIONS

Page 22: Hermes: Free the Data! Distributed Computing with MongoDB

22

What we loved about it: Great messaging platform. Highly scalable Reliable

What didn’t work for us: Lack of Persistence Administrative overhead Additional Infrastructure Complex message handling

Page 23: Hermes: Free the Data! Distributed Computing with MongoDB

23

What we loved about it: Highly Scalable Durable Messages Extendibility

What didn’t work for us: Expertise It is HARD! Additional Infrastructure Support

Page 24: Hermes: Free the Data! Distributed Computing with MongoDB

24

Features Known & supported

infrastructure Highly Scalable Fault Tolerant Simple & Flexible

Caveats Initial sizing & design is

critical

MongoDBComponents: Capped Collection Tail-able Cursor Replica set Flexible Schema Aggregation Framework

Page 25: Hermes: Free the Data! Distributed Computing with MongoDB

25

Hermes

Page 26: Hermes: Free the Data! Distributed Computing with MongoDB

26

Hermes Breakdown{ Capped Collections }http://docs.mongodb.org/v2.6/core/capped-collections/

Highlights:• FIFO Queue• Fixed Size Collection• Guarantee sort by insertion order

($natural)• Tail-able Cursor support!• Very little support overhead

{Code}• use hermes

db.createCollection(“orders”, {‘capped’:true, ‘size’:4000000000})

Page 27: Hermes: Free the Data! Distributed Computing with MongoDB

27

Hermes Breakdown{ JSON }Basic Schema

{_id: ObjectId()typ: (msg type: String),dt: MongoDate() data: {

/* flexible json object data here */ }

}

Page 28: Hermes: Free the Data! Distributed Computing with MongoDB

28

Hermes Breakdown{ Tailable Cursor }http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/

Highlights:• Non-exhausting cursor• Query-’less’ feed of data

{code}Python

cursor = self.coll.find(tailable=True, await_data=True)Or

cursor = self.coll.find({'_id':{'$gt’:<objectId>}}, tailable=True, await_data=True)

Page 29: Hermes: Free the Data! Distributed Computing with MongoDB

29

Hermes Breakdown{ Replica Set }http://docs.mongodb.org/manual/core/replication/

Highlights:• Low overhead replication• Scalable redundancy• Optimize read/write efficiency

Page 30: Hermes: Free the Data! Distributed Computing with MongoDB

30

Simple Example

Page 31: Hermes: Free the Data! Distributed Computing with MongoDB

31

# setup Mongo Connection try: self.conn = pymongo.MongoClient(host=servers) self.db = self.conn[db] self.coll = self.db[coll] self.startPoint = startpoint except Exception as e: self.logger.error(e) self.logger.error(str(self.__class__.__name__) + " :: Connection to Database Failed!") exit(1)

def run(self): self.logger.info(str(self.__class__.__name__) + " starting tailable cursor.") if self.startPoint != None: # start from last queue position cursor = self.coll.find({'_id':{'$gt':self.startPoint}}, tailable=True, await_data=True) else: # start from top of queue cursor = self.coll.find(tailable=True, await_data=True) while cursor.alive: try: data = cursor.next() rec = data self.logger.debug("updt:" + rec['data']['UPDATED_DATE'] + " ordr:" + rec['data']['ORDER_ID'] + " objid: " + str(rec['_id'])) except StopIteration: self.logger.info(str(self.__class__.__name__) + " waiting ...")

Page 32: Hermes: Free the Data! Distributed Computing with MongoDB

32

Core System Migration

Page 33: Hermes: Free the Data! Distributed Computing with MongoDB

33

Page 34: Hermes: Free the Data! Distributed Computing with MongoDB

34

Questions?