SlideShare a Scribd company logo
Antonio Scalzo
How I meet
MongoDb
My first approach and use
case with a NoSQL database
Why MongoDb?
❖ Due to some days of illness and lot of free time :)
❖ Basically, i was founding a clear / nice way to speed up
my own website localities typehead.
Where MongoDB?
❖ http://www.e656.net, my
personal website, has a section
where you can look for a train
station to see the timetable.
Data sources come from a
traditional mysql table, and the
search was made in “or” +
“like” using 4 db fields.
Where MongoDB (2)?
❖ Localities are ~ 17.000 records, not too much
❖ Search results condition are more complex than the
example (join with other 4 tables)
❖ So, traditional MySQL search system was really slow,
especially with heavy load traffic situations (in some
cases, 1500 - 2000 ms)
My First (bad) Solution
❖ An hash table stored in cache (Memcached), where
localities are partitioned using the first two letter of the
name, and the search was made using php strpos()
function.
❖ Quicker than MySQL alone, (100 ms with data in cache,
1000 ms without), but really dirty and with a nice
memory usage. Just a Patch!
Non Relational Database
❖ According to Wikipedia:
❖ A NoSQL (originally referring to "non SQL" or "non relational") database
provides a mechanism for storage and retrieval of data that is modeled in means
other than the tabular relations used in relational databases […] The data
structures used by NoSQL databases (e.g. key-value, graph, or document) differ
slightly from those used by default in relational databases, making some operations
faster in NoSQL and others faster in relational databases. The particular suitability
of a given NoSQL database depends on the problem it must solve. Sometimes the
data structures used by noSQL databases are also viewed as "more flexible" than
relational database tables.
❖ My idea was: build a documents structure only with mandatory data, and
try MongoDB ‘regex’ search.
Install MongoDB
❖ Server: Ubuntu 14.04 64bit
❖ Step 1: install MongoDB:
❖ Source: https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
❖antonio@srv:~$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv
7F0CEB10
antonio@srv:~$ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/
mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
antonio@srv:~$ apt-get update
antonio@srv:~$ apt-get install -y mongodb-org
Install MongoDB PHP Extension
❖ The simplest and quickest way to install MongoDB
extension is using PECL
❖ Source: http://php.net/manual/en/mongo.installation.php
❖ More info on PECL / Pear: https://pecl.php.net/support.php
antonio@srv:~$ pecl install mongo
Configure MongoDB
❖ MongoDB main configuration uses /etc/mongod/mongod.conf file.
❖ Base install comes without users and authentication / security
❖ Step 1: connect to Mongo Shell and create admin user:
antonio@srv:~$ mongo
MongoDB shell version: 3.0.6
connecting to: test
Welcome to the MongoDB shell.
> use admin;
switched to db admin
> db.createUser({ user: "root", pwd: "yourPwd", roles: [ "root" ] })
Successfully added user: { "user" : "root", "roles" : [ "root" ] }
Configure MongoDB
❖ Enable user authentication:
❖ edit /etc/mongodb/mongodb.conf
❖ restart MongoDB server
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
auth = true
GNU nano 2.2.6 File: /etc/mongodb/mongod.conf Modified
antonio@srv:~$ service mongod restart
mongod stop/waiting
mongod start/running, process 11646
Create Database and User
❖ MongoDB creates database on first time that it is used,
so we connect to admin database using root credentials.
❖ Done! Now we are ready to use that.
❖ For more info about MongoDB Users and role:
http://docs.mongodb.org/master/administration/security-user-role-
management/
antonio@srv:~$ mongo admin -uroot -p
MongoDB shell version: 3.0.6
Enter password:
connecting to: admin
> use E656Net;
switched to db E656Net
> db.createUser({ user: "yourUser", pwd: "password", roles: [ "readWrite", “dbAmin" ] })
Successfully added user: { "user" : "yourUser", "roles" : [ "readWrite", "dbAdmin" ] }
Create a (simple) php data import script
Use MongoDB with Symfony2
❖ E656.net is written using Symfony2 and uses Doctrine
as DB ORM
❖ Symfony2 has a very simple way to integrate MongoDB
ODM (Object Document Mapper) in our project:
DoctrineMongoDBBundle
❖ Follow installation instruction here, using Symfony2
official documentation:
http://symfony.com/doc/current/bundles/
DoctrineMongoDBBundle/index.html
Use MongoDB with Symfony2
❖ Create a new Store Bundle
❖ Create a class that uses MongoDb
Annotations and maps every
property of documents inserted
in collection (in this case, name,
name2, name3, name4)
❖ Generate getter and setters from
CLI
antonio@mac:~$ php app/console
doctrine:mongodb:generate:documents
E656NOSqlStoreBundle
Use MongoDB with Symfony2
❖
Conclusions
❖ Response time: 0.01ms - 0.02ms for EVERY single request
❖ So, MongoDB wins the match!
❖ Now, improve MongoDB usage in other website sections,
with heavy SQL queries and heavy cache usage.
Thanks for Reading!
❖ Antonino Scalzo, Roma (Italy)
❖ http://www.e656.net
❖ https://twitter.com/AntonioScalzo84
❖ https://it.linkedin.com/pub/antonio-scalzo/2/404/71b
❖ mail: antonio.scalzo84@gmail.com

More Related Content

What's hot

MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증
박 민규
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsingJussi Pohjolainen
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
N hidden gems you didn't know hippo delivery tier and hippo (forge) could give
N hidden gems you didn't know hippo delivery tier and hippo (forge) could giveN hidden gems you didn't know hippo delivery tier and hippo (forge) could give
N hidden gems you didn't know hippo delivery tier and hippo (forge) could give
Woonsan Ko
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The Room
Makoto Ohnami
 
RESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens АuerRESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens Аuer
Yandex
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever need
Matthew Boeckman
 
Redis, a 2 minutes introduction
Redis, a 2 minutes introductionRedis, a 2 minutes introduction
Redis, a 2 minutes introduction
Mirko Calvaresi
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo dbDaeMyung Kang
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellScott Hernandez
 
Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)
Ontico
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouch
Wynn Netherland
 
Tutorial on Node File System
Tutorial on Node File SystemTutorial on Node File System
Tutorial on Node File System
iFour Technolab Pvt. Ltd.
 
Chaining 7 vulnerabilities in Citrix ShareFile On-Premise
Chaining 7 vulnerabilities in Citrix ShareFile On-PremiseChaining 7 vulnerabilities in Citrix ShareFile On-Premise
Chaining 7 vulnerabilities in Citrix ShareFile On-Premise
Johanna Curiel
 
新建 文本文档
新建 文本文档新建 文本文档
新建 文本文档mytwice
 
TopDB data transfer
TopDB data transferTopDB data transfer
TopDB data transfer
Chonpin HSU
 
Unix for Librarians
Unix for LibrariansUnix for Librarians
Unix for Librarians
Ravi Mynampaty
 

What's hot (20)

MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
 
HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증HTTP 완벽가이드- 13 다이제스트 인증
HTTP 완벽가이드- 13 다이제스트 인증
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsing
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management Demystified
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
 
N hidden gems you didn't know hippo delivery tier and hippo (forge) could give
N hidden gems you didn't know hippo delivery tier and hippo (forge) could giveN hidden gems you didn't know hippo delivery tier and hippo (forge) could give
N hidden gems you didn't know hippo delivery tier and hippo (forge) could give
 
Day 2-some fun coding
Day 2-some fun codingDay 2-some fun coding
Day 2-some fun coding
 
CouchDB in The Room
CouchDB in The RoomCouchDB in The Room
CouchDB in The Room
 
RESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens АuerRESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens Аuer
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever need
 
Redis, a 2 minutes introduction
Redis, a 2 minutes introductionRedis, a 2 minutes introduction
Redis, a 2 minutes introduction
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo db
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
 
Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouch
 
Tutorial on Node File System
Tutorial on Node File SystemTutorial on Node File System
Tutorial on Node File System
 
Chaining 7 vulnerabilities in Citrix ShareFile On-Premise
Chaining 7 vulnerabilities in Citrix ShareFile On-PremiseChaining 7 vulnerabilities in Citrix ShareFile On-Premise
Chaining 7 vulnerabilities in Citrix ShareFile On-Premise
 
新建 文本文档
新建 文本文档新建 文本文档
新建 文本文档
 
TopDB data transfer
TopDB data transferTopDB data transfer
TopDB data transfer
 
Unix for Librarians
Unix for LibrariansUnix for Librarians
Unix for Librarians
 

Viewers also liked

Evolving cu london10_11th_february_josedejuan
Evolving cu london10_11th_february_josedejuanEvolving cu london10_11th_february_josedejuan
Evolving cu london10_11th_february_josedejuanJose De Juan
 
mm13 keynote presentation | Peep Laja
mm13 keynote presentation | Peep Lajamm13 keynote presentation | Peep Laja
mm13 keynote presentation | Peep Laja
mesh group
 
Evolving Corporate Universities London10_11th_february_josedejuan
Evolving Corporate Universities London10_11th_february_josedejuanEvolving Corporate Universities London10_11th_february_josedejuan
Evolving Corporate Universities London10_11th_february_josedejuanJose De Juan
 
Build a better service level agreement by SiriusDecisions' Ally Motz
Build a better service level agreement by SiriusDecisions' Ally MotzBuild a better service level agreement by SiriusDecisions' Ally Motz
Build a better service level agreement by SiriusDecisions' Ally Motz
mesh group
 
Cu Executive Education Forum Feb17 Gas Natural
Cu Executive Education Forum Feb17 Gas NaturalCu Executive Education Forum Feb17 Gas Natural
Cu Executive Education Forum Feb17 Gas NaturalJose De Juan
 
Build a better service level agreement
Build a better service level agreementBuild a better service level agreement
Build a better service level agreementmesh group
 

Viewers also liked (6)

Evolving cu london10_11th_february_josedejuan
Evolving cu london10_11th_february_josedejuanEvolving cu london10_11th_february_josedejuan
Evolving cu london10_11th_february_josedejuan
 
mm13 keynote presentation | Peep Laja
mm13 keynote presentation | Peep Lajamm13 keynote presentation | Peep Laja
mm13 keynote presentation | Peep Laja
 
Evolving Corporate Universities London10_11th_february_josedejuan
Evolving Corporate Universities London10_11th_february_josedejuanEvolving Corporate Universities London10_11th_february_josedejuan
Evolving Corporate Universities London10_11th_february_josedejuan
 
Build a better service level agreement by SiriusDecisions' Ally Motz
Build a better service level agreement by SiriusDecisions' Ally MotzBuild a better service level agreement by SiriusDecisions' Ally Motz
Build a better service level agreement by SiriusDecisions' Ally Motz
 
Cu Executive Education Forum Feb17 Gas Natural
Cu Executive Education Forum Feb17 Gas NaturalCu Executive Education Forum Feb17 Gas Natural
Cu Executive Education Forum Feb17 Gas Natural
 
Build a better service level agreement
Build a better service level agreementBuild a better service level agreement
Build a better service level agreement
 

Similar to How do i Meet MongoDB

The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterChris Henry
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
sethfloydjr
 
MongoDB
MongoDBMongoDB
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
MongoDB
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
fwso
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
Habilelabs
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
MongoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
MongoDB
 
MongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutionMongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & Execution
iFour Technolab Pvt. Ltd.
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
NexThoughts Technologies
 
MongoDB is the MashupDB
MongoDB is the MashupDBMongoDB is the MashupDB
MongoDB is the MashupDB
Wynn Netherland
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
RoopaR36
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
Jerwin Roy
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)
MongoDB
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
johnrjenson
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
Joe Drumgoole
 

Similar to How do i Meet MongoDB (20)

The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb Cluster
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
MongoDB
MongoDBMongoDB
MongoDB
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
MongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutionMongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & Execution
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
MongoDB is the MashupDB
MongoDB is the MashupDBMongoDB is the MashupDB
MongoDB is the MashupDB
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)Introduction to MongoDB (Webinar Jan 2011)
Introduction to MongoDB (Webinar Jan 2011)
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
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
CatarinaPereira64715
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
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
 

How do i Meet MongoDB

  • 1. Antonio Scalzo How I meet MongoDb My first approach and use case with a NoSQL database
  • 2. Why MongoDb? ❖ Due to some days of illness and lot of free time :) ❖ Basically, i was founding a clear / nice way to speed up my own website localities typehead.
  • 3. Where MongoDB? ❖ http://www.e656.net, my personal website, has a section where you can look for a train station to see the timetable. Data sources come from a traditional mysql table, and the search was made in “or” + “like” using 4 db fields.
  • 4. Where MongoDB (2)? ❖ Localities are ~ 17.000 records, not too much ❖ Search results condition are more complex than the example (join with other 4 tables) ❖ So, traditional MySQL search system was really slow, especially with heavy load traffic situations (in some cases, 1500 - 2000 ms)
  • 5. My First (bad) Solution ❖ An hash table stored in cache (Memcached), where localities are partitioned using the first two letter of the name, and the search was made using php strpos() function. ❖ Quicker than MySQL alone, (100 ms with data in cache, 1000 ms without), but really dirty and with a nice memory usage. Just a Patch!
  • 6. Non Relational Database ❖ According to Wikipedia: ❖ A NoSQL (originally referring to "non SQL" or "non relational") database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases […] The data structures used by NoSQL databases (e.g. key-value, graph, or document) differ slightly from those used by default in relational databases, making some operations faster in NoSQL and others faster in relational databases. The particular suitability of a given NoSQL database depends on the problem it must solve. Sometimes the data structures used by noSQL databases are also viewed as "more flexible" than relational database tables. ❖ My idea was: build a documents structure only with mandatory data, and try MongoDB ‘regex’ search.
  • 7. Install MongoDB ❖ Server: Ubuntu 14.04 64bit ❖ Step 1: install MongoDB: ❖ Source: https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ ❖antonio@srv:~$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 antonio@srv:~$ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/ mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list antonio@srv:~$ apt-get update antonio@srv:~$ apt-get install -y mongodb-org
  • 8. Install MongoDB PHP Extension ❖ The simplest and quickest way to install MongoDB extension is using PECL ❖ Source: http://php.net/manual/en/mongo.installation.php ❖ More info on PECL / Pear: https://pecl.php.net/support.php antonio@srv:~$ pecl install mongo
  • 9. Configure MongoDB ❖ MongoDB main configuration uses /etc/mongod/mongod.conf file. ❖ Base install comes without users and authentication / security ❖ Step 1: connect to Mongo Shell and create admin user: antonio@srv:~$ mongo MongoDB shell version: 3.0.6 connecting to: test Welcome to the MongoDB shell. > use admin; switched to db admin > db.createUser({ user: "root", pwd: "yourPwd", roles: [ "root" ] }) Successfully added user: { "user" : "root", "roles" : [ "root" ] }
  • 10. Configure MongoDB ❖ Enable user authentication: ❖ edit /etc/mongodb/mongodb.conf ❖ restart MongoDB server # Enables periodic logging of CPU utilization and I/O wait #cpu = true # Turn on/off security. Off is currently the default #noauth = true auth = true GNU nano 2.2.6 File: /etc/mongodb/mongod.conf Modified antonio@srv:~$ service mongod restart mongod stop/waiting mongod start/running, process 11646
  • 11. Create Database and User ❖ MongoDB creates database on first time that it is used, so we connect to admin database using root credentials. ❖ Done! Now we are ready to use that. ❖ For more info about MongoDB Users and role: http://docs.mongodb.org/master/administration/security-user-role- management/ antonio@srv:~$ mongo admin -uroot -p MongoDB shell version: 3.0.6 Enter password: connecting to: admin > use E656Net; switched to db E656Net > db.createUser({ user: "yourUser", pwd: "password", roles: [ "readWrite", “dbAmin" ] }) Successfully added user: { "user" : "yourUser", "roles" : [ "readWrite", "dbAdmin" ] }
  • 12. Create a (simple) php data import script
  • 13. Use MongoDB with Symfony2 ❖ E656.net is written using Symfony2 and uses Doctrine as DB ORM ❖ Symfony2 has a very simple way to integrate MongoDB ODM (Object Document Mapper) in our project: DoctrineMongoDBBundle ❖ Follow installation instruction here, using Symfony2 official documentation: http://symfony.com/doc/current/bundles/ DoctrineMongoDBBundle/index.html
  • 14. Use MongoDB with Symfony2 ❖ Create a new Store Bundle ❖ Create a class that uses MongoDb Annotations and maps every property of documents inserted in collection (in this case, name, name2, name3, name4) ❖ Generate getter and setters from CLI antonio@mac:~$ php app/console doctrine:mongodb:generate:documents E656NOSqlStoreBundle
  • 15. Use MongoDB with Symfony2 ❖
  • 16. Conclusions ❖ Response time: 0.01ms - 0.02ms for EVERY single request ❖ So, MongoDB wins the match! ❖ Now, improve MongoDB usage in other website sections, with heavy SQL queries and heavy cache usage.
  • 17. Thanks for Reading! ❖ Antonino Scalzo, Roma (Italy) ❖ http://www.e656.net ❖ https://twitter.com/AntonioScalzo84 ❖ https://it.linkedin.com/pub/antonio-scalzo/2/404/71b ❖ mail: antonio.scalzo84@gmail.com