creating a mongodb based logging system in a webservice heavy environment
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
Creating MongoDB Based Logging System in Webservice Heavy Environment
Arkadiusz Goralski@MongoDB London 2013
piątek, 29 marca 13
Web service Heavy Environment
Web Server 1
Web Server 2
Web Server n...
Web Application
piątek, 29 marca 13
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
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
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
Different dialects
Web Application
SOAP
REST JSON
REST XML
JSON RPC
XML RPC
HTTP Calls
piątek, 29 marca 13
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
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
MongoDB deployment
Web Server 1
Web Server 2
Web Server n...
Web Application
piątek, 29 marca 13
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
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
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
Log entry schema
piątek, 29 marca 13
Log entry schemaPrepare web
service request
piątek, 29 marca 13
Log entry schemaPrepare web
service request
Send itJSON-ize
piątek, 29 marca 13
Log entry schemaPrepare web
service request
Send itJSON-ize
Get the resultJSON-ize
piątek, 29 marca 13
Log entry schemaPrepare web
service request
Send itJSON-ize
Get the result
Was is successful
JSON-ize
piątek, 29 marca 13
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
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
Detect anomalies in the data
• realtime issue analysis
• subsystem failures
• fraud
• traffic anomalies
piątek, 29 marca 13
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
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
Push notificationsWhen something goes really bad
Node.jsappMongoDB
Tailable cursorSeverityrating
Text message
Call people, it's serious!
Alert Scenarios
piątek, 29 marca 13
Open Source Alternatives
• GrayLog (uses MongoDB)
• LogStash (MongoDB output plugins)
• Fluent (MongoDB storage)
piątek, 29 marca 13
Thank youHave fun with MongoDB
piątek, 29 marca 13