Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OLAP cube - PHP and MongoDB

I need to create an analytics system. I already built the system using MognoDB and PHP but without using OLAP. Now my queries are really the best I can get, but the system is really slow because no cube. It can take a minute to load a report for the last 7 days. I really need the options of the cube - slice & dice.

So what would be the solution for me? Is there a good cube system build with MongoDB and that can insert & view data via PHP? Maybe MongoDB won't be good for me? Should I use another database and start all the system from 0? What OLAP solutions there are using PHP?

Edit: More info -- Well, the system is like google analytics. Need to be able to know how much views in every day, need to be able to report from only a specified traffic source and country. The system needs to handle 1,000,000 unique view each day. But not only count of views, there needs to be able to see how much users are returning, what is the average time for every user, etc.

Thanks.

like image 934
Eli_Rozen Avatar asked Oct 08 '22 07:10

Eli_Rozen


1 Answers

MongoDB isn't built for OLAP cube-type applications. I can think of two approaches:

1) Determine ahead of time what queries you'll need to do, and store your data in the optimal format ahead of time. E.g., if you want to know visits per country per day, then as each visit occurs do something like:

db.visits.update({'country':country, 'day':current_day()}, {$inc:{visits:1}})

Repeat for each metric. Fire-and-forget updates from your application to the analytics DB will add minimal overhead to serving a request to the visitor. Then your queries will be largely precomputed.

2) Try JasperSoft's MongoDB backend.

like image 118
A. Jesse Jiryu Davis Avatar answered Oct 13 '22 10:10

A. Jesse Jiryu Davis