SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
Real-time web analytics com
                                    MongoDB


                                       Victor Augusto de Campos - Outubro/2011
                                                                @victorcampos


Tuesday, 25 October 2011
Introdução



Tuesday, 25 October 2011
Por que o MongoDB?


                           Upserts rápidos, flexibilidade de documentos




Tuesday, 25 October 2011
Conceito

                             Um documento por item, dia e hora,
                           contendo um mapa de ações e seus totais

                               Totalização feita com mapreduce




Tuesday, 25 October 2011
Estrutura do documento
                               duh.

                                   { “id” : identificador do item,
                                     “date” : data ISO (yyyy-mm-dd),
              granularidade          “hour” : hora (0-23),
                                     “actions” : { “access” : 1,
                                                    “clicks” : 2,
                                                    “show” : 1,
                                                    etc, etc. }}

                  a mágica de um document database



Tuesday, 25 October 2011
Índices

                                índice simples para busca de um item
                                           { “id” : ASC }



                           índice composto para busca de um range de data
                                          { “id” : ASC,
                                            “date” : DESC,
                                            “hour” : DESC }




Tuesday, 25 October 2011
Map Reduce
                                   map                                               reduce

                      function() {                        function(k, vals) {
                         for(i in this.actions) {           total = {};
                           var action = {};                 for (i in vals) {
                           action[i] = this.actions[i];       for (action_type in vals[i]) {
                           emit(this.date, action);             if(!total[action_type]) {
                        }                                         total[action_type] = 0;
                      }                                         }

                                                                      total[action_type] += vals[i][action_type];
                                                                  }
                                                              }

                                                              return total;
                                                          }



Tuesday, 25 October 2011
Um pequeno demo



Tuesday, 25 October 2011
O código está disponível em
                           github.com/victorcampos/nosqlbr_lightning




Tuesday, 25 October 2011

Mais conteúdo relacionado

Último

Assessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdfAssessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdf
Natalia Granato
 

Último (6)

ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docxATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
ATIVIDADE 1 - CUSTOS DE PRODUÇÃO - 52_2024.docx
 
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docxATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
 
Boas práticas de programação com Object Calisthenics
Boas práticas de programação com Object CalisthenicsBoas práticas de programação com Object Calisthenics
Boas práticas de programação com Object Calisthenics
 
Padrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemploPadrões de Projeto: Proxy e Command com exemplo
Padrões de Projeto: Proxy e Command com exemplo
 
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docxATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
ATIVIDADE 1 - LOGÍSTICA EMPRESARIAL - 52_2024.docx
 
Assessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdfAssessement Boas Praticas em Kubernetes.pdf
Assessement Boas Praticas em Kubernetes.pdf
 

Destaque

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Real time analytics - MongoDB - nosqlbr

  • 1. Real-time web analytics com MongoDB Victor Augusto de Campos - Outubro/2011 @victorcampos Tuesday, 25 October 2011
  • 3. Por que o MongoDB? Upserts rápidos, flexibilidade de documentos Tuesday, 25 October 2011
  • 4. Conceito Um documento por item, dia e hora, contendo um mapa de ações e seus totais Totalização feita com mapreduce Tuesday, 25 October 2011
  • 5. Estrutura do documento duh. { “id” : identificador do item, “date” : data ISO (yyyy-mm-dd), granularidade “hour” : hora (0-23), “actions” : { “access” : 1, “clicks” : 2, “show” : 1, etc, etc. }} a mágica de um document database Tuesday, 25 October 2011
  • 6. Índices índice simples para busca de um item { “id” : ASC } índice composto para busca de um range de data { “id” : ASC, “date” : DESC, “hour” : DESC } Tuesday, 25 October 2011
  • 7. Map Reduce map reduce function() { function(k, vals) { for(i in this.actions) { total = {}; var action = {}; for (i in vals) { action[i] = this.actions[i]; for (action_type in vals[i]) { emit(this.date, action); if(!total[action_type]) { } total[action_type] = 0; } } total[action_type] += vals[i][action_type]; } } return total; } Tuesday, 25 October 2011
  • 8. Um pequeno demo Tuesday, 25 October 2011
  • 9. O código está disponível em github.com/victorcampos/nosqlbr_lightning Tuesday, 25 October 2011