Slide 1

Slide 1 text

LIGHTWEIGHT BUSINESS INTELLIGENCE – WITH – RUBY, RAILS, & MONGODB COREY EHMKE @BANTIK

Slide 2

Slide 2 text

WHO AM I? A developer with a long memory and a longer career Sr. developer at Apartments.com Co-founder of LGBTech A lifelong learner and autodidact

Slide 3

Slide 3 text

WHAT IS BUSINESS INTELLIGENCE? Collection & organization of mission-critical knowledge Historical view of business operations Tools to support decision making

Slide 4

Slide 4 text

PRELUDE: THE MARRIAGE OF BUSINESS & TECHNOLOGY

Slide 5

Slide 5 text

The foundation on which the fun stuff is built A science unto itself Not of great interest to most developers INFRASTRUCTURE

Slide 6

Slide 6 text

Enable the delivery of products and services Optimize business processes Provide leverage for scaling the business APPLICATIONS

Slide 7

Slide 7 text

DATA Exists to support critical business decisions Better data leads to better decisions ∴ Data must be as timely and useful as possible

Slide 8

Slide 8 text

WHEN DEVELOPERS MAKE FRIENDS WITH DATA...

Slide 9

Slide 9 text

BUSINESS INTELLIGENCE: A FIT IN THREE ACTS

Slide 10

Slide 10 text

ACT 1: THE NAÏVE APPROACH

Slide 11

Slide 11 text

THE NAÏVE APPROACH Reporting out of the transactional database Raw SQL embedded in your code for “performance” Granting direct database access to stakeholders

Slide 12

Slide 12 text

THE NAÏVE APPROACH: SHORTCOMINGS Fighting the schema with complex joins Poor performance Impact on production resources Chance of catastrophic data loss due to...

Slide 13

Slide 13 text

DON’T TRUST THIS GUY WITH YOUR DATABASE.

Slide 14

Slide 14 text

ACT 2: THE ENTERPRISE APPROACH

Slide 15

Slide 15 text

THE ENTERPRISE APPROACH Distinct infrastructure/stack Nightly ETL (extract, transform, load) processes Schema designed for reporting Combination of static and dynamic reports

Slide 16

Slide 16 text

THE ENTERPRISE APPROACH: SHORTCOMINGS 24 hour delay in data availability Expensive to configure and maintain Requires highly specialized resources Hard to change your mind or adapt Enterprise-y

Slide 17

Slide 17 text

VERY, VERY ENTERPRISE-Y

Slide 18

Slide 18 text

DON’T TRUST THESE GUYS WITH YOUR DATABASE, EITHER.

Slide 19

Slide 19 text

TRADITIONAL BI: THE WRONG HAMMER

Slide 20

Slide 20 text

TRADITIONAL BI: THE WRONG HAMMER Waterfall approach Painful data migrations Brittle ETL processes No automated testing Logic embedded in the data store “Retro” user interfaces

Slide 21

Slide 21 text

IN SHORT... TRADITIONAL BI DOESN’T FEEL AGILE.

Slide 22

Slide 22 text

ACT 3: LIGHTWEIGHT BI

Slide 23

Slide 23 text

THE FOUR NOBLE GOALS OF THE LIGHTWEIGHT BI APPROACH Provide real-time data to support decisions Leverage familiar technology & infrastructure Use existing development staff Support an iterative, agile approach

Slide 24

Slide 24 text

TRUST YOUR DEVELOPERS.

Slide 25

Slide 25 text

GETTING STARTED Collaborate! Determine the KPIs that actually matter Figure out what questions the business is asking on a daily basis

Slide 26

Slide 26 text

TURN INFERENCES INTO FACTS Find a way to tell a story with your data Design your schema based on facts De-normalize like a boss

Slide 27

Slide 27 text

PRESENT ANSWERS Provide a central, single source of truth Present the data wherever it’s needed Dashboard design is harder than you think Plan for iterations & ongoing collaboration

Slide 28

Slide 28 text

PLEASE GODS NO.

Slide 29

Slide 29 text

DON’T MAKE THESE.

Slide 30

Slide 30 text

BRING RUBY TO THE PARTY Makes agile, test-driven development easy Quickly deploy new apps Plenty of visualization libraries Powerful SQL & NoSQL ORMs Great data munging capabilities

Slide 31

Slide 31 text

LEVERAGE MONGODB Flexible and dynamic schemas Support for native datatypes Powerful querying, map/ reduce, and aggregation Fast and performant Easy to scale up

Slide 32

Slide 32 text

GO AHEAD... TRY THIS AT HOME LIGHTWEIGHT BI TECHNIQUES

Slide 33

Slide 33 text

PARALLEL DB DEPLOYMENT Modern frameworks support multiple ORMs Use SQL for transactions Use NoSQL for reporting Business logic in your apps, not in your database

Slide 34

Slide 34 text

STATISTICAL MODELS Collections of facts, not attributes Data spanning deep and wide object graphs De-normalized and optimized for reporting

Slide 35

Slide 35 text

module  MemberDataProfiles    class  Performance        include  Mongoid::Document        include  Mongoid::Timestamps        field  :member_id,                                  :type  =>  Integer        field  :annual_trunk_frequency,        :type  =>  Integer,    :default  =>  0        field  :average_trunk_value,              :type  =>  Float,        :default  =>  0.0        field  :is_customer,                              :type  =>  Boolean,    :default  =>  false        field  :keep_rate,                                  :type  =>  Float,        :default  =>  0.0        field  :last_transaction_date,          :type  =>  Date        field  :member_creation_date,            :type  =>  Date        field  :total_value,                              :type  =>  Float,        :default  =>  0.0        field  :total_number_of_trunks,        :type  =>  Integer,    :default  =>  0    end end

Slide 36

Slide 36 text

STREAMING ETL Event-triggered, continuous data extraction Calculations are defined in code rather than SQL or ETL scripts Allow resource-intensive data munging to happen in the background Provide near-real-time data

Slide 37

Slide 37 text

APIS EVERYWHERE Provide easy access to your data Allow reuse of data in novel ways Quickly build dashboards and data explorers Use the Faceted gem to make building APIs easy

Slide 38

Slide 38 text

EPILOGUE: ENTER THE LEVIATHAN

Slide 39

Slide 39 text

A TYPICAL SMALL APP ECOSYSTEM Persistence Service Postgres Ops Members Sales iOS App Inventory Outfitting Messaging Dashboard Reporting Service MongoDB Business Objects MySQL

Slide 40

Slide 40 text

LEVIATHAN Records events from all applications Subscribes to all message queues Collects and displays real-time data Browse, search, & drill-down interface Longitudinal analysis with dynamic cohorts

Slide 41

Slide 41 text

CRITICAL DATA POINTS Marketing campaign performance Member on-boarding funnels Order lifecycles Customer service interactions Product performance

Slide 42

Slide 42 text

class  Event    include  Mongoid::Document    include  Mongoid::Timestamps    field  :label    field  :application    field  :details,  :type  =>  Hash,  :default  =>  {}    def  self.record!(label,  application,  params={})        Event.create(            :label  =>  label,            :application  =>  application,            :details  =>  params        )    end    def  self.search_details(criteria={})        where("details.#{criteria.keys.first}"  =>  /#{criteria.values.first}/i)    end end

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

THANKS! Corey Ehmke @bantik bantik.github.com