SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
Staying Lean With
Application Logs
@SamirTalwar and @sleepyfox
2016-09-22T11:10:00+0200
Essay form at

https://talks.samirtalwar.com/
Reactive,

Event-Sourced, and Lean

(also with logs)
@SamirTalwar and @sleepyfox
2016-09-22T11:10:00+0200
Essay form at

https://talks.samirtalwar.com/
We're making a
game for Xbox Two.
Trials of Anubis
One of the most popular game modes.
You have two teams, Alpha and Bravo, each of three players.
Each team is trying to defeat the other one.
If you take another player down, they don’t revive in the
same round.
Players can bring their teammates back up, but it’s time-
consuming.
If all the players on the team are taken down, that team
loses.
Best out of three rounds wins the match.
Let's get down to
business.
I'm here today to talk about
infrastructure, not graphics.
Phase One
Phase One
This is a monolith.
It's easy to reason about.
But it doesn't scale past a few games.
Phase Two
Phase Two
Deploy many monoliths.
It's still easy to reason about.
The components are unbalanced.
They still have to share data.
Phase Three
Phase Three
We've split into services.
Because microservices are a thing now.
Communication via the database went
well…
for about 20 seconds, before we hit
consistency issues.
We're bottlenecked on the database.
Phase Four
Phase Four
Services manage their own data storage.
We do communication over HTTP, because
that's apparently lightweight now.
Phase Four
Four out of six service components are
just managing HTTP.
Every service needs the same kind of
components.
None of the HTTP stuff makes us money.
It’s just waste.
We can do better.
Let's make something that works with our
architecture instead.
Event Sourcing
What if, rather than consuming from
other services, each service published
every single event?
• no HTTP servers
• no HTTP logs; just publish to a
store
• still need the clients, but they're
simpler
Event Sourcing
Sounds like a solution.
Just one problem.
We'd have to rewrite everything.
Event Sourcing
Wait. We already publish events.
To STDOUT. 😮
We log everything already.
Push them to Fluentd or Logstash.
A log-powered
event bus.
It'll never work.
Let's do it.
impressive

transition

goes here
What's in a log?
Machine-readable first.
Human-readable second.
If you want to read your logs,

process them first.
Kibana will help a lot.
What's in a log?
We don't care about:
• filtering by severity,
• log rotation,
• multiple formats,
• or even logging to a file.
Those are ops concerns, not dev.
What's in a log?
Every event has a type.
The structure of the event is
determined by this type.
That structure is a public contract…
Just like a Java class.
Versioning is probably required.
ygt/microservice-logging
const Logger = require('./logger')



const log = new Logger({

now: Date.now,

output: console,

events: {

startup: 'startup',

httpRequest: 'HTTP request',

database: 'database'

}

}).with({service: 'my super service'})
ygt/microservice-logging
log.startup.info({

message: 'Ready to go.',

port: 8080

})



// later on



const requestLog = log.with({

request_id: '126bb6fa-28a2-470f-b013-eefbf9182b2d'})

requestLog.database.error({

message: 'Connection failed.'})

requestLog.httpRequest.info({

request: {method: 'GET'},

response: {status: 500}})
ygt/microservice-logging
{"timestamp":1474443152917,

"event_type":"startup",

"severity":"INFO",

"service":"my super service",

"message":"Ready to go.",

"port":8080}
{"timestamp":1474443152920,

"event_type":"database",

"severity":"ERROR",

"service":"my super service",

"request_id":"126bb6fa-28a2-470f-b013-eefbf9182b2d",

"message":"Connection failed."}
{"timestamp":1474443152921,

"event_type":"HTTP request",

"severity":"INFO",

"service":"my super service",

"request_id":"126bb6fa-28a2-470f-b013-eefbf9182b2d",

"request":{"method":"GET"},

"response":{"status":500}}
ygt/microservice-logging
Check it out.
https://github.com/ygt/microservice-logging
npm install microservice-logging
So.
We have a log of all events in the system.
There’s real-time reactive behaviour across services.
The stateless services are completely scalable…
… and there’s patterns for scaling the stateful ones.
Adding new services that derive information from the
data requires no modifications to the existing ones.
We have a model for handling catastrophic failure.
Reporting and analytics are practically free now.
So.
And my favourite:



we don't have a database at all.
Scaling out
Load-balance, with sticky sessions based on IDs if
services keep state in memory.
Avoid in-memory state; outsource to Memcached or Redis.
On failure, respawn and replay.
Push events from Fluentd/Logstash to Kafka or Kinesis.
Flag non-JSON logs for manual review.
Store events in Elasticsearch or Cassandra.
When you need a real database, keep your events, and
populate it from there (write model and read model).
Log everything
Who's got questions?
Thank you.
@SamirTalwar
samir@noodlesandwich.com
https://talks.samirtalwar.com/
https://github.com/SamirTalwar

/logs-as-the-event-source

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (9)

Expect the unexpected: Anticipate and prepare for failures in microservices b...
Expect the unexpected: Anticipate and prepare for failures in microservices b...Expect the unexpected: Anticipate and prepare for failures in microservices b...
Expect the unexpected: Anticipate and prepare for failures in microservices b...
 
Hystrix make your app bullet proof
Hystrix   make your app bullet proofHystrix   make your app bullet proof
Hystrix make your app bullet proof
 
JavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EEJavaOne 2016 - Reactive Microservices with Java and Java EE
JavaOne 2016 - Reactive Microservices with Java and Java EE
 
Microservices with Netflix OSS & Hypermedia APIs - JavaDay Kiev
Microservices with Netflix OSS & Hypermedia APIs - JavaDay KievMicroservices with Netflix OSS & Hypermedia APIs - JavaDay Kiev
Microservices with Netflix OSS & Hypermedia APIs - JavaDay Kiev
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Mastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to MicroservicesMastering Chaos - A Netflix Guide to Microservices
Mastering Chaos - A Netflix Guide to Microservices
 
From SOA to MSA
From SOA to MSAFrom SOA to MSA
From SOA to MSA
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
 

Ähnlich wie Staying lean with application logs

Hey man, can I get a clue?
Hey man, can I get a clue?Hey man, can I get a clue?
Hey man, can I get a clue?
Voxeo Corp
 

Ähnlich wie Staying lean with application logs (20)

Life as a GlusterFS Consultant with Ivan Rossi
Life as a GlusterFS Consultant with Ivan RossiLife as a GlusterFS Consultant with Ivan Rossi
Life as a GlusterFS Consultant with Ivan Rossi
 
Fluentd v1 and Roadmap
Fluentd v1 and RoadmapFluentd v1 and Roadmap
Fluentd v1 and Roadmap
 
Functional web with clojure
Functional web with clojureFunctional web with clojure
Functional web with clojure
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
 
Building software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWSBuilding software by feature with immutable infrastructures on AWS
Building software by feature with immutable infrastructures on AWS
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war story
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
 
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
 
MongoSF 2011 - Using MongoDB for IGN's Social Platform
MongoSF 2011 - Using MongoDB for IGN's Social PlatformMongoSF 2011 - Using MongoDB for IGN's Social Platform
MongoSF 2011 - Using MongoDB for IGN's Social Platform
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
Understanding Scratch Extensions with JavaScript (Part 2 of 2)
Understanding Scratch Extensions with JavaScript (Part 2 of 2)Understanding Scratch Extensions with JavaScript (Part 2 of 2)
Understanding Scratch Extensions with JavaScript (Part 2 of 2)
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
Virtual Bash! A Lunchtime Introduction to Kafka
Virtual Bash! A Lunchtime Introduction to KafkaVirtual Bash! A Lunchtime Introduction to Kafka
Virtual Bash! A Lunchtime Introduction to Kafka
 
Hey man, can I get a clue?
Hey man, can I get a clue?Hey man, can I get a clue?
Hey man, can I get a clue?
 
Real time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.lyReal time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.ly
 
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java PerformancePracticing at the Cutting Edge: Learning and Unlearning about Java Performance
Practicing at the Cutting Edge: Learning and Unlearning about Java Performance
 
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 PeopleKafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
 
SpringOne Platform recap 정윤진
SpringOne Platform recap 정윤진SpringOne Platform recap 정윤진
SpringOne Platform recap 정윤진
 
Recent MariaDB features to learn for a happy life
Recent MariaDB features to learn for a happy lifeRecent MariaDB features to learn for a happy life
Recent MariaDB features to learn for a happy life
 
Graylog Engineering - Design Your Architecture
Graylog Engineering - Design Your ArchitectureGraylog Engineering - Design Your Architecture
Graylog Engineering - Design Your Architecture
 

Kürzlich hochgeladen

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 

Kürzlich hochgeladen (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

Staying lean with application logs