SlideShare a Scribd company logo
1 of 17
Download to read offline
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 MongoDBMichael 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 giveWoonsan Ko
 
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 АuerYandex
 
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 needMatthew Boeckman
 
Redis, a 2 minutes introduction
Redis, a 2 minutes introductionRedis, a 2 minutes introduction
Redis, a 2 minutes introductionMirko 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 ouchWynn Netherland
 
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-PremiseJohanna Curiel
 
新建 文本文档
新建 文本文档新建 文本文档
新建 文本文档mytwice
 
TopDB data transfer
TopDB data transferTopDB data transfer
TopDB data transferChonpin HSU
 

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 Lajamesh 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 Motzmesh 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.jsasync_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 MongoDBMongoDB
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introductionsethfloydjr
 
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 PHPfwso
 
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 DatabaseFITC
 
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.jsMongoDB
 
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.jsMongoDB
 
MongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutionMongoDB Introduction, Installation & Execution
MongoDB Introduction, Installation & ExecutioniFour Technolab Pvt. Ltd.
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxRoopaR36
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin 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 Consjohnrjenson
 
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 ApplicationJoe Drumgoole
 
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 ApplicationMongoDB
 

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

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Recently uploaded (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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