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 & Tricks
MongoDB
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsing
Jussi Pohjolainen
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management Demystified
MongoDB
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo db
DaeMyung Kang
 
Mastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript Shell
Scott Hernandez
 
新建 文本文档
新建 文本文档新建 文本文档
新建 文本文档
mytwice
 

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 (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 Cluster
Chris Henry
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
RoopaR36
 

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

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 

Recently uploaded (20)

Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 

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