20
Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. MongoDB at Coupons Inc. http://www.coupons.com/coupon-codes/ http://www.coupons.com/passbook (for iPhone)

Mongo DB at Coupons Inc

  • Upload
    mongodb

  • View
    1.003

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute.

MongoDB at Coupons Inc.http://www.coupons.com/coupon-codes/

http://www.coupons.com/passbook (for iPhone)

Page 2: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 2

How do coupon codes work?

4. Clicks to get code and is redirected to Kmart. Affiliate “cookie” is dropped.

1. User searches “Kmart coupons” in Google/Coupons Inc.

5. Applies coupon code at checkout. Saves money, gets items = happy customer! 3. Finds coupon

code for $5 for $50.

2. Sees a Coupons.com link on search results page.

Page 3: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 3

Why we looked for new DB?

Needed to build a data driven website for Coupon Codes in a short amount of time.

Want one DB to reasonably handle multiple use cases.

Want to quickly iterate. Only thing we knew about our schema is

that it’s going to change pretty quickly.

Page 4: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 4

Main requirements

Easy to change our model. Low operational overhead. Developer can do the changes herself.

Wanted a DB to avoid multiple caching layers as this got us into trouble earlier.

Initially data size is not going to be large, but if we do things right its expected to grow quickly.

Page 5: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 5

Requirements Contd.

Main use cases did not require join, and did not need multi row transactions.

Need to support Java, Python, Perl and PHP – because we want to develop things quickly.

Should be easy to set up across multiple data centers soon after launch.

Should work in EC2.

Page 6: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 6

Requirements Contd.

Ok to have only Linux support ( We have some windows servers in the company, but we didn't need to support multiple OS(for DB clients).

Page 7: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 7

DBs considered

SQLServer behind cache [Gemfire/Varnish/memcache/apc] Used heavily in company. Existing

expertise with SQL Server. Operational overhead(schema

changes) MySQL

Familiarity with the DB in the Coupon Codes team.

Could not easily change our model.

Page 8: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 8

DB Considered Contd.

MongoDB Easy to model, make changes to

“schema”. Sharding would let us scale in future.

Easy to go from non sharded to sharded mode.

Page 9: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 9

Main datastore for all Coupon/Merchant related data.

Writes by internal processes, periodic reads for indexing into Solr.

Down time does not impact availability of live site.

Important consideration when deploying a new technology. (If MongoDB fails, it does not affect the live site.)

1st Use Case

Page 10: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 10

Sample Coupon

{"category_id" : NumberLong(117),"category_name" : "Books, News & Magazines","code" : "","coupon_id" : "53_2","created_by" : 5,"exclusive_offer" : 1,"passbook_offer" : 1,

"tags" : ['passbook', 'black friday' ]

"merchant" : {"name" : "Abebooks","id" : NumberLong(678),"image_url_small" : "http://cdn.cpnscdn.com/.../aff/in/small/abebooks_88x31_1.gif", "image_url_large":"http://cdn.cpnscdn.com/.../in/large/abebooks_234x60_0.gif"

},"url" : "/coupon-codes/go/rs?k=53_2"

}

Page 11: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 11

Real time analytics for website

Writes from frontend servers, reads internally.

Page 12: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 12

Serve user preferences data for live site.

• 1st use case where live site depends on MongoDB.

• Writes happen from internal processes

• Reads from frontend servers.

Page 13: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 13

Archiving data

Archiving old data feeds: Useful for periodic analysis.

Internal writes and reads

Page 14: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 14

Internal CMS

First version Django and MongoDB. Didn't have good integration.

Current version is based on MongoDB, but not Django. Used extensively internally.

Page 15: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 15

Passbooks/Printable Images

Examples of Blobs. Passbooks are zip files. Need tight control on Printable Coupons Images (These are different than the Grocery Coupons).

Page 16: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 16

Coming up soon

User Generated Content from Mongo

Both real time writes and reads. Schema : Still evolving!

Page 17: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 17

What pleasantly surprised us

Stability Database easy to set up (install packages

and some configuration) Good documentation (easy to find stuff you

want to do). Multi Data Center replication. MMS (Mongo Monitoring Service) - Really

excellent service.

Page 18: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 18

Things we learnt the hard way

Didn't have the latest Debian, Ubuntu, PHP, Python client packages on Ubuntu repository.

No great support for Django(packages were not marked stable then). We moved away from Django.

In JavaScript number 42 becomes number 42.0. (Hit us in production). This is a common pitfall/learning item for users but it's an aspect of importing data into Mongo.

Page 19: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 19

Things we learnt the hard way contd…

Our application would benefit from joins which MongoDB does not support.

Need a package to install replica sets on same machine.

Page 20: Mongo DB at Coupons Inc

Coupons.com Incorporated Confidential and Proprietary Information - Please Do Not Copy or Distribute. 20

This slide is intentionally left blank to mark the last slide.