This document discusses using MongoDB to improve performance for a Drupal site called Freerice that was experiencing slow load times from MySQL queries. It describes setting up MongoDB collections to store game data like user statistics and questions/categories, instead of storing everything in MySQL. This improved performance by reducing database queries. It also covers configuring MongoDB replication to provide redundancy and distribute load. The site now has over 500k users and sees improved performance with MongoDB handling the game data.
5. Freerice v2
Easy questions and categories management
Users registration
Facebook/Twitter integration
Friendship system
Groups
Detailed game statistics per user/group/total,
rating system, user statuses
6. Round 1
Questions = Nodes. Data imported.
Categories = Nodes + Taxonomy
User profiles = Content profile module
Groups = Organic groups module
Friendship system = Flag module
Game logic, statistics = custom
Blog, comments… = Core modules
18. What is 1 right answer?
10 rice
1 update into user tables
1 update into group tables
1 update into totals tables
1 update in user status tables
…
20. statistics.grains collection
Every right answer "uid": 1,
"cid": 17555,
= 1 insert "gid": 0,
Statistics "amt": 10,
"dat": 1305496800,
recalculation every "lvl": 1
night
21. Nodes collections
node.question, node.caterogy collection
hook_nodeapi() for insert, update, delete
Full Question and Category nodes into
MongoDB
Questions and Categories SELECTs millions
time often than INSERTs/UPDATEs
Nothing changed for site administration
23. Other collections
statistic.group_totals
statistic.totals
statistic.useractivity
24. Views
Bunch of views used on site
Views produce a lot of SELECTs into MySQL
It is not possible to cache them
It is not possible to replace them
27. Sview disadvantages
Hard to support
No page/block view “from a box”, custom code
needed
28. Multilingual support
MySQL data is translated as usual
Nothing to translate from users, groups
collections
Questions and Categories nodes are fully
saved in MongoDB -> easy to translate