log everything!

36
1 Log everything! Dr. Stefan Schadwinkel und Mike Lohmann

Upload: icans-gmbh

Post on 04-Dec-2014

21.652 views

Category:

Documents


4 download

DESCRIPTION

Slides of a talk at the International PHP Conference 2012 on how we successfully mastered the challenge to log everything and transport the logged data into different sinks for different needs.

TRANSCRIPT

Page 1: Log everything!

1  

Log everything! Dr. Stefan Schadwinkel und Mike Lohmann

Page 2: Log everything!

2  2

Who we are.

Log everything

Mike Lohmann Architektur

Author (PHPMagazin, IX, heise.de)

Dr. Stefan Schadwinkel Analytics

Author (heise.de, Cereb.Cortex, EJN, J.Neurophysiol.)

Page 3: Log everything!

3  3

Agenda.

Log everything

§  What we do. What we need to do. What we are doing.

§  Requirement: Log everything!

§  Infrastructure and technologies.

§  We want happy business users.

 

Page 4: Log everything!

4  4

Icans GmbH

Log everything

Page 5: Log everything!

5  5

Numberfacts of PokerStrategy.com

Log everything

6.000.000 Registered Users

PokerStrategy.com Education since 2005

19 Languages

2.800.000 PI/Day

700.000 Posts/Day

7.600.000 Requests/Day

Page 6: Log everything!

6  6

Topics of this talk

Log everything

- How to use existing technologies and standards. - Scalability and simplicity of the solution - „Good enough“ for now! - Showing way from requirement to solution. - OpenSource Sf2 bundles for logging.

- Livedemo.

- Out of the box solution - Ready to use scripts  

Page 7: Log everything!

7  7

What we do.

Log everything

§  We teach Poker.

§  We create webapplications.

§  We serve millions of users in different countries respecting

a multitude of market rules.

§  We make business decisions driven by complex

data analytics.

Page 8: Log everything!

8  8

What we need to do.

Log everything

§  We need to try out other teaching topics, fast.

§  We need to gather data from all of these „try outs“ to accumulate them

and build business decisions on their analysis.

§  We need a bigger infrastructure to gather more data.

§  We need to hire more (good) people! J

Page 9: Log everything!

9  9

What we are doing.

Log everything

§  We build ECF (Education Community Framework).

§  We (can) log everything!

§  We (now) use Amazon S3 and Amazon EMR to have a scaling

storage and map reduce solution.

§  We hire (good) people! J

Page 10: Log everything!

10  10

Requirement: Log everything.

Log everything

§  „Are you mad?!“

§  „Be more specific, please!“

§  „But what about the user‘s data?!“

 

Page 11: Log everything!

11  11

Logging Tools / Technologies

Producer

Symfony2 Application Server and Databases

15.10.12

Transport

Now: RabbitMQ

Erlang Consumer

Was: Flume

Storage

Now: S3 Storage Hadoop via

Amazon EMR

Was:

Virtualized Inhouse Hadoop

Analytics

MapReduce Hive

BI via QlikView

Page 12: Log everything!

12  12

Logging Infrastructure

Producer

15.10.12

Transport

Storage

Analytics Databases

LB

S3

Rabbit MQ

Consumer

QlikView  

Graylog  

Zabbix  

Reverse Proxy

App 1-x

Hadoop - Cluster

Page 13: Log everything!

13  13

Producer

15.10.12

Page Controller

Monolog-Logger

Shovel

Local RabbitMQ

PageHit Event

Listener

Processor

Handler

Formatter

PageHit-Event

Logger::log()

LogMessage, JSON

/Home

Page 14: Log everything!

14  14

Producer

15.10.12

§  LoggingComponent: Provides interfaces, filters and handlers

§  LoggingBundle: Glues all together with Symfony2

 

h=ps://github.com/ICANS/IcansLoggingComponent  h=ps://github.com/ICANS/IcansLoggingBundle    

Page 15: Log everything!

15  15

Transport – First Try

15.10.12

§  Hey, if we use Hadoop, why not use Flume?

-  Part of the Ecosystem

-  Central config

-  Extensible via Plugins

-  Flexible Flow Configuration

-  How? : Flume Nodes à Flume Sinks

Page 16: Log everything!

16  16

Transport – First Try

15.10.12

§  But, .. wait!

-  Ecosystem? Just like Hadoop version numbers…

-  Admins say: Central config woes!

-  issues: multi-master, logical vs. physical nodes, Java heap

space, etc.

-  Will my plugin run with flume-ng?

-  Ever tried to keep your complex flow and switch reliability levels?

Read: Our admins still hate me …

Page 17: Log everything!

17  17

Transport – Second Try

15.10.12

§  RabbitMQ vs. Flume Nodes

-  Each app server has ist own local RabbitMQ

-  The local RabbitMQ shovels ist data to a central RabbitMQ

cluster

-  Similar to the Flume Node concept

-  Decentralized config: Producers and consumers simply connect

Page 18: Log everything!

18  18

Transport – Second Try

15.10.12

§  But, .. wait! We still need Sinks.

-  Custom crafted RabbitMQ consumers

-  We could write them in PHP, but ..

-  Erlang, teh awesome!

- Battle-hardened OTP framework.

-  „Let it crash!“ .. and recover.

- Hot code change. If you want.

Read: Runs forever.

Page 19: Log everything!

19  19

Storage – First Try

15.10.12

§  Use out-of-the-box Hadoop (Cloudera)

§  But:

-  Virtualized Infrastructure

-  Unknown usage patterns

-  Must be cost effective

-  Major Hadoop version upgrades

Hadoop

Page 20: Log everything!

20  20

Storage – Second Try

15.10.12

§  Use Amazon Webservices

§  Provides flexible virtualized infrastructure

§  Cost-effective storage: S3

§  Hadoop on demand: EMR

Amazon S3

Page 21: Log everything!

21  21

Storage – Storage Amazon S3

15.10.12

§  Erlang RabbitMQ consumer simply copies the

incoming data to S3

- Easy: exchange „hadoop“ command with „s3cmd“

Amazon S3

Page 22: Log everything!

22  22

Storage – Storage Amazon S3

15.10.12

§  S3 bucket receives many small, compressed log file chunks

§  Amazon provides s3DistCp which does distributed data copy:

-  Aggregate many small files into partitioned large chunks

-  Change compression

Amazon S3

Page 23: Log everything!

23  23

Analytics

15.10.12

§  We want happy business users.

§  We want to answer questions.

- People want answers to questions they have. Now.

- No, they couldn‘t tell you that question yesterday. If they had

known, they would have already asked for the answer. Yesterday.

§  We also want data-driven applications.

-  Production system analysis.

-  Fraud prevention.

-  Recommendations.

-  Social metrics for our users.

 

Page 24: Log everything!

24  24

Analytics

15.10.12

§  Remember MapReduce.

- Custom Jobs.

- Streaming: Use your favorite.

-  Java API: Cascading. Use your favorite: Java, Groovy, Clojure,

Scala.

-  Data Queries.

-  Hive: similar to SQL.

-  Pig: Data flow.

-  Cascalog: Datalog-like QL using Clojure and Cascading.

 

Page 25: Log everything!

25  25

Analytics

15.10.12

§  Cascalog is Clojure, Clojure is Lisp

(?<- (stdout) [?person] (age ?person ?age) … (< ?age 30))

Query Operator

Cascading Output Tap

Columns of the dataset generated

by the query

„Generator“ „Predicate“

§  as many as you want

§  both can be any clojure function

§  clojure can call anything that is

available within a JVM

Page 26: Log everything!

26  26

Analytics

15.10.12

§  We use Cascalog to preprocess and organize that incoming flow of log messages:

Page 27: Log everything!

27  27

Analytics

15.10.12

§  Let‘s run the Cascalog processing on Amazon EMR:

./elastic-mapreduce --create --name „Log Message Compaction"

--bootstrap-action s3://[BUCKET]/mapreduce/configure-daemons

--num-instances $NUM

--slave-instance-type m1.large

--master-instance-type m1.large

--jar s3://[BUCKET]/mapreduce/compaction/icans-cascalog.jar

--step-action TERMINATE_JOB_FLOW

--step-name "Cascalog"

--main-class icans.cascalogjobs.processing.compaction

--args "s3://[BUCKET]/incoming/*/*/*/","s3://[BUCKET]/icanslog","s3://[BUCKET]/icanslog-error

Page 28: Log everything!

28  28

Analytics

15.10.12

§  After the Cascalog Query we have:

s3://[BUCKET]/icanslog/[WEBSITE]/icans.content/year=2012/month=10/day=01/part-00000.lzo

Hive  ParSSoning!  

Page 29: Log everything!

29  29

Analytics

15.10.12

§  Now  we  can  access  the  log  data  within  Hive:

Page 30: Log everything!

30  30

Analytics

15.10.12

§  Now  we  can  run  Hive  queries  on  the  [WEBSITE]_icanslog_content  table!  

§  But  we  also  want  to  store  the  result  to  S3.

Page 31: Log everything!

31  31

Analytics

15.10.12

§  Now,  get  the  stats:

Page 32: Log everything!

32  32

Analytics

15.10.12

§  We can now simply copy the data from S3 and import in any local analytical tool, like:

-  Excel (It must really make business people happy…)

-  QlikView (Anyone can be happy with it…)

-  R (If I want an answer…)

Page 33: Log everything!

33  33

Merci.

15.10.12

Questions

?

Page 34: Log everything!

34  34

Contacts.

15.10.12

Dr. Stefan Schadwinkel

[email protected]

ICANS_StScha

Mike Lohmann

[email protected]

mikelohmann

Page 35: Log everything!

35  35

Tools/Technologies

15.10.12

Page 36: Log everything!

36  

ICANS GmbH Valentinskamp 18 20354 Hamburg Germany Phone: +49 40 22 63 82 9-0 Fax: +49 40 38 67 15 92 Web: www.icans-gmbh.com