SlideShare a Scribd company logo
  
MongoDB + Pylons FTW: 
Scalabale Web apps with Python & NoSQL
 Niall O'Higgins
  
MongoDB ??
 Non­relational (NoSQL) document­oriented 
database
 Rich query language
 Flexible data model (JSON)
 Sharding and replication with automatic­failover
 CAP write quorum support
  
MongoDB vs MySQL vs BDB
 Feature Comparison
MongoDB MySQL BDB
Master-Slave
Replication
Yes Yes No
Automatic
master
failover
Yes No No
Ad-hoc
Schemas
Yes No No
Manual index
specification
Yes Yes Yes
Rich query
language
Yes Yes No
Joins No Yes No
  
MongoDB: NoSQL?
 Closer to MySQL than to BDB/Tyrant/Redis
 Less emphasis on Google­scale scalability at this 
point compared to e.g. Cassandra/HBase
 Today, MongoDB scales slightly better than 
MySQL IMHO.
 Main advantage over RDBMS is ease of 
development!
  
NoORM
 MongoDB document is a JSON object.
 PyMongo driver exposes these as dictionaries
E.g. db.mycollection.insert(dict(myprop='foo!'))
 You can even embed objects within a document:
E.g. db.mycollection.insert(
dict(emails=
      [dict(email_lower='niallo@pywebsf.org')]
))
  
NoORM II
 You can query across properties, embedded or 
otherwise, easily.
E.g. 
r = db.mycollection.find_one(
{emails.email_lower:'niallo@pywebsf.org'}
)
print r['emails'][0]['email_lower']
  
NoORM III
 SQL queries can get very complicated (huge joins, 
aggregate queries, etc)
 Marshalling SQL to/from  objects is painful, 
tedious.
 Cross­RDBMS portability issues
  → ORMs can make sense with RDBMS
 At least in Python, I see absolutely no need for 
ORM with MongoDB.
  
More on querying MongoDB
 I alluded to a rich query language:
 $lt, $lte, $gt, $gte == <, <=, >, =>
 $ne == <>, !=
 $in == IN
 $or == OR
 Sort() == ORDER BY
 Limit() == LIMIT
 Skip() == OFFSET
 Group() == GROUP BY
  
Geo Features
Geospatial querying out of the box:
 $near (x, y): Return documents sorted by distance 
from point.
 $within, $box/$center: Return documents within 
bounds of a rectangle/circle. Earth is flat in 1.6.x 
and lower. Spherical model in 1.7.0 and up.
 Other limits: Only one geo index per collection. No 
sharding support.
  
More on querying MongoDB
 Sample rich query:
db.foo.find({'$or': [{'owner_account_id': Id}, 
{'shared_to': Id}], 'location': {'$near': [37.783, 
­122.393]}}.skip(offset).limit(PAGE_SIZE)
  
MongoDB Gotchas
 Obviously not as mature as any RDBMS on the 
market. You can find bugs, but developers are 
extremely responsive.
 4MB limit per document.
 Cap on number of indexes per collection.
 No transactions, although some imperfect support 
for atomic operations. Race with e.g. Deleting 
single embedded object from list property.
  → Not the right fit for every system! 
  → Think through your schema!
  
Pylons
 Elegant, lightweight but fully­featured framework.
 Perfect fit for mixed API and Web rendering 
environment we have at Catch.com
 Threaded design, easy to program. No callbacks 
needed. Works fine with synchronous libraries.
 Threads in Python suck due to the GIL.
 Multi­core systems necessitate multi­process 
operation.
 Options: Apache+mod_wsgi or multiple Pasters.
  
mod_wsgi vs multiple Pasters
 Apache+mod_wsgi is kind of a pain to setup, 
configure.
 Past production experiences with mod_wsgi include 
memory leaks, CPU spinning.
 Paster is simple, built into Pylons. One Paster 
server maps cleanly to one Python interpreter 
process.
  LOLapps serve high­volume production traffic 
with Paster just fine.
  
Catch.com Paster
 Multiple Pasters per machine, each listening on a 
separate port.
 Nginx load balances between them all.
 Nginx also terminates SSL.
 No issues whatsoever handling the load today.
  
Paster Debugging Tip
 Configure smtp_server
 Point it at a Google Mail list
 Set up a Gmail label to filter messages into
 Now you have nicely searchable, real­time stack 
traces aggregated from each Paster. Very useful 
for debugging distributed systems!

More Related Content

What's hot

MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql Database
Sudhir Patil
 

What's hot (20)

NoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionNoSQL and MongoDB Introdction
NoSQL and MongoDB Introdction
 
MongoDB World 2016: Poster Sessions eBook
MongoDB World 2016: Poster Sessions eBookMongoDB World 2016: Poster Sessions eBook
MongoDB World 2016: Poster Sessions eBook
 
guacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDBguacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDB
 
Mongo DB: Operational Big Data Database
Mongo DB: Operational Big Data DatabaseMongo DB: Operational Big Data Database
Mongo DB: Operational Big Data Database
 
Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)
 
Introduction to Web Designing
Introduction to Web DesigningIntroduction to Web Designing
Introduction to Web Designing
 
MongoDB SF Ruby
MongoDB SF RubyMongoDB SF Ruby
MongoDB SF Ruby
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
From RDBMS to MongoDB
From RDBMS to MongoDBFrom RDBMS to MongoDB
From RDBMS to MongoDB
 
Arango DB
Arango DBArango DB
Arango DB
 
JS App Architecture
JS App ArchitectureJS App Architecture
JS App Architecture
 
5 Things You Didn't Know You Could do with CouchDB
5 Things You Didn't Know You Could do with CouchDB5 Things You Didn't Know You Could do with CouchDB
5 Things You Didn't Know You Could do with CouchDB
 
MongoDB Hadoop DC
MongoDB Hadoop DCMongoDB Hadoop DC
MongoDB Hadoop DC
 
NYT Web Archive
NYT Web ArchiveNYT Web Archive
NYT Web Archive
 
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql DatabaseMongoDB Introduction - Document Oriented Nosql Database
MongoDB Introduction - Document Oriented Nosql Database
 
The Hive Think Tank: Rocking the Database World with RocksDB
The Hive Think Tank: Rocking the Database World with RocksDBThe Hive Think Tank: Rocking the Database World with RocksDB
The Hive Think Tank: Rocking the Database World with RocksDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Introduction to NoSQL Database
Introduction to NoSQL DatabaseIntroduction to NoSQL Database
Introduction to NoSQL Database
 
Lean and mean MongoDB
Lean and mean MongoDBLean and mean MongoDB
Lean and mean MongoDB
 
Benefits of Using MongoDB Over RDBMSs
Benefits of Using MongoDB Over RDBMSsBenefits of Using MongoDB Over RDBMSs
Benefits of Using MongoDB Over RDBMSs
 

Similar to MongoDB + Pylons FTW: Scalable Web apps with Python & NoSQL

Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
75waytechnologies
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
Appirio
 
MongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_BabuMongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_Babu
Sharan
 

Similar to MongoDB + Pylons FTW: Scalable Web apps with Python & NoSQL (20)

The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDBSilicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDB
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
Mongodb
MongodbMongodb
Mongodb
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Webinar: Live Data Visualisation with Tableau and MongoDB
Webinar: Live Data Visualisation with Tableau and MongoDBWebinar: Live Data Visualisation with Tableau and MongoDB
Webinar: Live Data Visualisation with Tableau and MongoDB
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_BabuMongoDB_Sharan_Prakash_Babu
MongoDB_Sharan_Prakash_Babu
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Mongo db
Mongo dbMongo db
Mongo db
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
 
MongoDB DOC v1.5
MongoDB DOC v1.5MongoDB DOC v1.5
MongoDB DOC v1.5
 
Mongodb
MongodbMongodb
Mongodb
 

Recently uploaded

Recently uploaded (20)

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Server-Driven User Interface (SDUI) at Priceline
Server-Driven User Interface (SDUI) at PricelineServer-Driven User Interface (SDUI) at Priceline
Server-Driven User Interface (SDUI) at Priceline
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 

MongoDB + Pylons FTW: Scalable Web apps with Python & NoSQL