creating a mongodb based logging system in a webservice heavy environment

25
Creating MongoDB Based Logging System in Webservice Heavy Environment Arkadiusz Goralski @MongoDB London 2013 piątek, 29 marca 13

Upload: mongodb

Post on 29-Jun-2015

1.803 views

Category:

Technology


0 download

DESCRIPTION

A talk about how to create a spohisticated logging system to help you track data from several webservices in one central place. How to make the logged data searchable, so it's possible to run analytics to spot bugs in the software. It's also a story about MongoDB adoption on Youwin.com - an online bookmaker, where we integrate 30+ webservices (payment providers, game providers, etc.).

TRANSCRIPT

Page 1: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Creating MongoDB Based Logging System in Webservice Heavy Environment

Arkadiusz Goralski@MongoDB London 2013

piątek, 29 marca 13

Page 2: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Web service Heavy Environment

Web Server 1

Web Server 2

Web Server n...

Web Application

piątek, 29 marca 13

Page 3: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Web service Heavy Environment

Web Server 1

Web Server 2

Web Server n...

Web Application

Sportsbook

Live betting

Casino

Live dealer

Slots

Mini games

Poker

Account Management

Gaming Providers

piątek, 29 marca 13

Page 4: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Web service Heavy Environment

Skrill

Neteller

Visa

Ukash

Paysafe

Ecocard

Ecocard

Instadebit

Bank transfers

Mastercard Envoy Webmoney

Payment Providers

Web Server 1

Web Server 2

Web Server n...

Web Application

Sportsbook

Live betting

Casino

Live dealer

Slots

Mini games

Poker

Account Management

Gaming Providers

piątek, 29 marca 13

Page 5: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Web service Heavy Environment

Skrill

Neteller

Visa

Ukash

Paysafe

Ecocard

Ecocard

Instadebit

Bank transfers

Mastercard Envoy Webmoney

Payment Providers

Bonus engine

Price feeds Mobile API

Common Wallet

Other Subsystems

Anti fraud Geo IP

Web Server 1

Web Server 2

Web Server n...

Web Application

Sportsbook

Live betting

Casino

Live dealer

Slots

Mini games

Poker

Account Management

Gaming Providers

piątek, 29 marca 13

Page 6: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Different dialects

Web Application

SOAP

REST JSON

REST XML

JSON RPC

XML RPC

HTTP Calls

piątek, 29 marca 13

Page 7: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

How to keep sanity?

• why the deposit failed for user ... ?

• user ... claims he didn’t place this bet?

• can you give me a number of users that ... ?

• can you tell me what user ... was doing on ... ?

• why user ... couldn’t log in?

• why customer ... couldn’t open an account?

piątek, 29 marca 13

Page 8: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Why MongoDB is a good fit

• schemaless

• fire and forget

• scalable and easy to replicate

• capped collections & tailable cursor

• centralized

• easy remote access

piątek, 29 marca 13

Page 9: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

MongoDB deployment

Web Server 1

Web Server 2

Web Server n...

Web Application

piątek, 29 marca 13

Page 10: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

MongoDB deployment

Web Server 1

Web Server 2

Web Server n...

Web Application

Payment ProvidersMongoDB(host 1)

MongoDB(host 2)

MongoDB(host 3)

MongoDB(hidden)

Replica Set

piątek, 29 marca 13

Page 11: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

MongoDB deployment

Web Server 1

Web Server 2

Web Server n...

Web Application

Payment ProvidersMongoDB(host 1)

MongoDB(host 2)

MongoDB(host 3)

MongoDB(hidden)

Replica Set

Payment ProvidersReal time log viewer

Simple queries

Simple reports

Log Viewer

Real time alerts

Secondary preferred

piątek, 29 marca 13

Page 12: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

MongoDB deployment

Web Server 1

Web Server 2

Web Server n...

Web Application

Payment ProvidersMongoDB(host 1)

MongoDB(host 2)

MongoDB(host 3)

MongoDB(hidden)

Replica Set

Payment ProvidersReal time log viewer

Simple queries

Simple reports

Log Viewer

Real time alerts

Secondary preferred Hidden node only

Payment ProvidersAnalytics Heavy

queries

Data mining

piątek, 29 marca 13

Page 13: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schema

piątek, 29 marca 13

Page 14: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schemaPrepare web

service request

piątek, 29 marca 13

Page 15: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schemaPrepare web

service request

Send itJSON-ize

piątek, 29 marca 13

Page 16: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schemaPrepare web

service request

Send itJSON-ize

Get the resultJSON-ize

piątek, 29 marca 13

Page 17: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schemaPrepare web

service request

Send itJSON-ize

Get the result

Was is successful

JSON-ize

piątek, 29 marca 13

Page 18: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Log entry schemaPrepare web

service request

Send itJSON-ize

Get the result

Was is successful

JSON-ize

Save itProceed with

execution

piątek, 29 marca 13

Page 19: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

So you're logging data to MongoDB, now what?

• all data is searchable (including web service specific data)

• you can use the aggregation framework

• trace user sessions across different web services

• just sit and watch the logs

piątek, 29 marca 13

Page 20: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Detect anomalies in the data

• realtime issue analysis

• subsystem failures

• fraud

• traffic anomalies

piątek, 29 marca 13

Page 21: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Data mining• create a replica for analytics

• analyze customer behaviour

• spot fraudulent activity

• create reports

• proactive support

• deployment analytics

• police enquiries

piątek, 29 marca 13

Page 22: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Share the logs

• don’t be a human interface to MongoDB

• the more you share the more time is saved, your time

• just a simple query interface is enough

• give separate node to marketing people

piątek, 29 marca 13

Page 23: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Push notificationsWhen something goes really bad

Node.jsappMongoDB

Tailable cursorSeverityrating

Email

Text message

Call people, it's serious!

Alert Scenarios

piątek, 29 marca 13

Page 24: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Open Source Alternatives

• GrayLog (uses MongoDB)

• LogStash (MongoDB output plugins)

• Fluent (MongoDB storage)

piątek, 29 marca 13

Page 25: Creating a MongoDB Based Logging System in a Webservice Heavy Environment

Thank youHave fun with MongoDB

piątek, 29 marca 13