SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Logs Distribuídos
uma introdução ao Apache Kafka
Pedro Arthur P. R. Duarte
pedroarthur.jedi@gmail.com
Conceitos básicos
2
Origens e Objetivos
Projeto criado pela equipe de arquitetura do LinkedIn. O objetivo do
projeto é prover uma insfraestrutura de mensagens de alto troughput
e fácil escalabilidade.
3
Mas... Como?
O servidores de mensagem (aka brokers) preocupam-se somente
com a manutenção do estado do cluster Kafka;
Para o mundo externo, os brokers provem somente a visão de
tópicos e offsets para que os clientes possam manter seu próprio
estado.
4
"Apache Kafka is
pusblish-subscribe
messaging rethought as a
distributed commit log"
Apache Kafka’s home page
http://kafka.apache.org
5
Log? Log tipo arquivos de log?
$ sudo tail -n 5 -f /var/log/syslog
Jun 4 19:37:07 inception systemd[1]: Time has been ch ...
Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ...
Jun 4 19:39:13 inception systemd[1]: Started Cleanup ...
Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ...
Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ...
_
6
Log? Log tipo arquivos de log?
$ sudo tail -n 5 -f /var/log/syslog
Jun 4 19:37:07 inception systemd[1]: Time has been ch ...
Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ...
Jun 4 19:39:13 inception systemd[1]: Started Cleanup ...
Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ...
Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ...
Jun 4 19:49:02 inception ntpd[711]: receive: Unexpect ...
_
6
Log? Log tipo arquivos de log?
$ sudo tail -n 5 -f /var/log/syslog
Jun 4 19:37:07 inception systemd[1]: Time has been ch ...
Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ...
Jun 4 19:39:13 inception systemd[1]: Started Cleanup ...
Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ...
Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ...
Jun 4 19:49:02 inception ntpd[711]: receive: Unexpect ...
Jun 4 19:55:31 inception kernel: [11996.667253] hrtim ...
_
6
O que é um log?
time
First entry
...
(t) entry
(t+1) entry
(t+2) entry
(t+n) entry
...
next entry
7
Onde logs são utilizados?
Sempre que precismos armazenar o que aconteceu e quando
aconteceu...
8
Onde logs são utilizados?
Sistemas de Base de Dados
– PostgreSQL’s Write-Ahead Loggind (WAL)
– Oracles 10/11G Redo Log
Sistemas de controle de versão
– Git, The Stupid Content Tracker
– Subversion
9
Git’s log: um log, mas nem tanto
$ git log --oneline
498d410 Fixes message format and adds some logging
e09c955 Enhances the ContainerStub with a StoredObject stub
18fe603 Puts topic name in a configuration companion object
89d9c5d Separates consumer from producer configuration
a9f1a76 Adds a provisory container stub
d800dfe Creates consumer configuration
fa4da8e Removes trash
4808450 Adds kafka producer
333b14f Let there be light
10
Git’s reflog: um verdadeiro log
$ git reflog
498d410 HEAD@0: commit (amend): Fixes message format and adds some ...
9147167 HEAD@1: commit (amend): Fixes message format and adds some ...
97d8661 HEAD@2: commit: Fixes message format and adds some logging
e09c955 HEAD@3: commit: Enhances the ContainerStub with a StoredOb ...
18fe603 HEAD@4: rebase finished: returning to refs/heads/master
18fe603 HEAD@5: rebase: checkout refs/remotes/origin/master
d800dfe HEAD@6: rebase finished: returning to refs/heads/master
d800dfe HEAD@7: rebase: Creates consumer configuration
fa4da8e HEAD@8: rebase: checkout refs/remotes/origin/master
701b3e6 HEAD@9: commit: Creates consumer configuration
4808450 HEAD@10: commit: Adds kafka producer
333b14f HEAD@11: clone: from https://pedroarthur@bitbucket.org/ped ...
11
Integração de Dados
12
Mais sistemas, mais dados, mais problemas...
13
Utilizando um log como um perspective broker
14
Replicação de Máquinas de
Estado
15
Replicação Ativo/Ativo e Back-up Primário
16
A Single Source of Truth
17
Detalhes do Kafka
18
Visão geral do Kafka
Zookeeper
cluster
Producer
Producer
Producer
Consumer
Group A
Consumer
Group B
Consumer
Group C
Block Storage
19
"Apache Zookeeper is an ...
server which enables
highly reliable distributed
coordination"
Apache Zookeeper’s home page
20
Zookeeper
Do ponto de vista das interfaces de programação, o Zookeeper é um
"sistema de arquivos com garantias"; por exemplo
– Diferentes clientes tentam criar um arquivo, somente um deles
receberá uma notificação positiva;
– Diferentes clientes tentam alterar um arquivo, somente um deles
receberá a notificação de escrita e os demais devem retentar a
operação
21
Anatomia de um Tópico
Partition 0 @ broker_a
Partition 1 @ broker_b
Partition 2 @ broker_c
topic
Consumer 2
Consumer 0
Consumer 1
Cosumer Group A
Producer
Producer
Producer
22
Use case
23
Anonimizado xD
A/B data
aggregation
Source A
Database
Source B
Database
A/B Aggregation
Database
A/B Aggregation
Topic
Data Enrichment
Pipeline
Data Analysis
Engine
A Topic
B Topic
Source A Data
Transformation
Source B Data
Transformation
Flume
Master Node
Data Source A
Data Source B2
Data Source B1
Query API
Publish/Subscriber
Integration API
Analysis
Database
24
Programando para Kafka
25
Producer em Scala (>= 0.9.0.0)
val properties = new Properties () {
put("bootstrap.servers", "broker1 :9092 , broker2 :9092")
put("key.serializer ",
"org.apache.kafka.common. serialization . StringSerializer ")
put("value.serializer ",
"org.apache.kafka.common. serialization . StringSerializer ")
put("acks", "1")
put("retries", "0")
/* any colour you like */
}
val producer = new KafkaProducer [String , String ]( properties )
26
Producer em Scala (>= 0.9.0.0)
val message = new ProducerRecord [String , String ](
" the_destination_topic ", "entry key", "your data")
/* just try to send data */
val future: Future[ RecordMetadata ] = producer.send(message)
/* try to send data and call -me back after it */
val futureAndCallback : Future[ RecordMetadata ] =
producer.send(message ,
new Callback () {
def onCompletion (
metadata: RecordMetadata , exception: Exception) {
/* (metadata XOR exception) is non -null :( */
}
})
producer.close () /* release */
27
Consumer em Scala (>= 0.9.0.0)
val properties = new Properties () {
put("bootstrap.servers", "broker1 :9092 , broker2 :9092")
put("group.id", " the_group_id ")
put("enable.auto.commit", "true")
put("auto.commit.interval.ms", "1000")
put("key. deserializer ",
"org.apache.kafka.common. serialization . StringDeserializer ")
put("value. deserializer ",
"org.apache.kafka.common. serialization . StringDeserializer ")
/* any colour you like */
}
val consumer = new KafkaConsumer [String , String ]( properties )
28
Consumer em Scala (>= 0.9.0.0)
/* subscribe to as many topics as you like */
consumer.subscribe(Arrays.asList(" the_destination_topic "))
while (true) {
val records: /* argument is the timeout in millis */
ConsumerRecords [String , String] = consumer.poll (100)
records foreach {
record: ConsumerRecord [String , String] =>
log.info("${record.topic ()} is at ${record.offset ()}")
}
}
29
Referência Básica
30
Jay Krep’s I Heart Logs
"Why a book about logs? Thats easy: the humble log is an
abstraction that lies at the heart of many systems, from NoSQL
databases to cryptocurrencies. Even though most engineers dont
think much about them, this short book shows you why logs are
worthy of your attention ..."
Release Date: October 2014
31
Demonstação
32
Kafkabox: sincronização de arquivos
Pequeno projeto prova de conceito utilizando Kafka, OpenStack
Swift e inotify; baixe-o com o comando a seguir:
$ git clone http://bitbucket.com/pedroarthur/kafkabox/
33
Implementação
– Inotify: escute todas as mudanças do diretório;
– Para cada mudança,
– Envie mudança para o Swift via HTTP;
– Escreva a mudança ocorrida no tópico Kafka.
34
Logs Distribuídos
uma introdução ao Apache Kafka
Pedro Arthur P. R. Duarte
pedroarthur.jedi@gmail.com

Contenu connexe

Tendances

glance replicator
glance replicatorglance replicator
glance replicator
irix_jp
 
nginx: writing your first module
nginx: writing your first modulenginx: writing your first module
nginx: writing your first module
redivy
 
Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)
Dobrica Pavlinušić
 
Porting FreeRTOS on OpenRISC
Porting FreeRTOS   on   OpenRISCPorting FreeRTOS   on   OpenRISC
Porting FreeRTOS on OpenRISC
Yi-Chiao
 

Tendances (20)

How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified Logging
 
glance replicator
glance replicatorglance replicator
glance replicator
 
GCD and OperationQueue.
GCD and OperationQueue.GCD and OperationQueue.
GCD and OperationQueue.
 
nginx: writing your first module
nginx: writing your first modulenginx: writing your first module
nginx: writing your first module
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
Containers: What are they, Really?
Containers: What are they, Really?Containers: What are they, Really?
Containers: What are they, Really?
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and Moby
 
Namespace
NamespaceNamespace
Namespace
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casual
 
Building and Deploying Application to Apache Mesos
Building and Deploying Application to Apache MesosBuilding and Deploying Application to Apache Mesos
Building and Deploying Application to Apache Mesos
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)
 
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
 
Porting FreeRTOS on OpenRISC
Porting FreeRTOS   on   OpenRISCPorting FreeRTOS   on   OpenRISC
Porting FreeRTOS on OpenRISC
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstack
 
Embedded systems
Embedded systems Embedded systems
Embedded systems
 

En vedette

Desvendando a Plataforma de Serviços Windows Azure
Desvendando a Plataforma de Serviços Windows AzureDesvendando a Plataforma de Serviços Windows Azure
Desvendando a Plataforma de Serviços Windows Azure
LucasRomao
 

En vedette (20)

Big data architectures and the data lake
Big data architectures and the data lakeBig data architectures and the data lake
Big data architectures and the data lake
 
Desvendando a Plataforma de Serviços Windows Azure
Desvendando a Plataforma de Serviços Windows AzureDesvendando a Plataforma de Serviços Windows Azure
Desvendando a Plataforma de Serviços Windows Azure
 
BIG DATA, de Fabiana Andrade
BIG DATA, de Fabiana AndradeBIG DATA, de Fabiana Andrade
BIG DATA, de Fabiana Andrade
 
A plataforma Azure da Microsoft
A plataforma Azure da MicrosoftA plataforma Azure da Microsoft
A plataforma Azure da Microsoft
 
Big Data, JVM e Redes Sociais
Big Data, JVM e Redes SociaisBig Data, JVM e Redes Sociais
Big Data, JVM e Redes Sociais
 
Introdução à computação na nuvem e Windows Azure
Introdução à computação na nuvem e Windows AzureIntrodução à computação na nuvem e Windows Azure
Introdução à computação na nuvem e Windows Azure
 
AAB308 - Cloud Computing Windows Azure - wcamb.pdf
AAB308 - Cloud Computing Windows Azure - wcamb.pdfAAB308 - Cloud Computing Windows Azure - wcamb.pdf
AAB308 - Cloud Computing Windows Azure - wcamb.pdf
 
Sistemas para o Mundo Real - TDC 2012
Sistemas para o Mundo Real - TDC 2012Sistemas para o Mundo Real - TDC 2012
Sistemas para o Mundo Real - TDC 2012
 
Desenvolvendo para o Windows Azure e SQL Azure
Desenvolvendo para o Windows Azure e SQL AzureDesenvolvendo para o Windows Azure e SQL Azure
Desenvolvendo para o Windows Azure e SQL Azure
 
O que há de novo no Microsoft Azure IaaS
O que há de novo no Microsoft Azure IaaSO que há de novo no Microsoft Azure IaaS
O que há de novo no Microsoft Azure IaaS
 
Cidades Inteligentes e Big Data
Cidades Inteligentes e Big DataCidades Inteligentes e Big Data
Cidades Inteligentes e Big Data
 
Big Data em 8 perguntas - 09.10.2014 - DATANORTE / GOV RN
Big Data em 8 perguntas -  09.10.2014 - DATANORTE / GOV RNBig Data em 8 perguntas -  09.10.2014 - DATANORTE / GOV RN
Big Data em 8 perguntas - 09.10.2014 - DATANORTE / GOV RN
 
Big Data na Nuvem
Big Data na NuvemBig Data na Nuvem
Big Data na Nuvem
 
Mongo db no mundo real slides
Mongo db no mundo real   slidesMongo db no mundo real   slides
Mongo db no mundo real slides
 
Hadoop, Big Data e Cloud Computing
Hadoop, Big Data e Cloud ComputingHadoop, Big Data e Cloud Computing
Hadoop, Big Data e Cloud Computing
 
TDC2016POA | Trilha Agile - Agile Marketing: os resultados alcançados com pri...
TDC2016POA | Trilha Agile - Agile Marketing: os resultados alcançados com pri...TDC2016POA | Trilha Agile - Agile Marketing: os resultados alcançados com pri...
TDC2016POA | Trilha Agile - Agile Marketing: os resultados alcançados com pri...
 
TDC2016POA | Trilha Analise de Negocios - Como fatiar seu produto em estórias...
TDC2016POA | Trilha Analise de Negocios - Como fatiar seu produto em estórias...TDC2016POA | Trilha Analise de Negocios - Como fatiar seu produto em estórias...
TDC2016POA | Trilha Analise de Negocios - Como fatiar seu produto em estórias...
 
TDC2016POA | Trilha Analise de Negocios - Business Coach, o Analista de Negó...
TDC2016POA | Trilha Analise de Negocios -  Business Coach, o Analista de Negó...TDC2016POA | Trilha Analise de Negocios -  Business Coach, o Analista de Negó...
TDC2016POA | Trilha Analise de Negocios - Business Coach, o Analista de Negó...
 
TDC2016POA | Trilha Analise de Negocios - Inovando em negócios com foco na eX...
TDC2016POA | Trilha Analise de Negocios - Inovando em negócios com foco na eX...TDC2016POA | Trilha Analise de Negocios - Inovando em negócios com foco na eX...
TDC2016POA | Trilha Analise de Negocios - Inovando em negócios com foco na eX...
 
TDC2016POA | Trilha Agile - Agilidade além da TI: Um Relato de Experiencia
TDC2016POA | Trilha Agile - Agilidade além da TI: Um Relato de ExperienciaTDC2016POA | Trilha Agile - Agilidade além da TI: Um Relato de Experiencia
TDC2016POA | Trilha Agile - Agilidade além da TI: Um Relato de Experiencia
 

Similaire à TDC2016POA | Trilha Arquitetura - Apache Kafka: uma introdução a logs distribuídos

Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
Joe Stein
 

Similaire à TDC2016POA | Trilha Arquitetura - Apache Kafka: uma introdução a logs distribuídos (20)

Big Data Open Source Security LLC: Realtime log analysis with Mesos, Docker, ...
Big Data Open Source Security LLC: Realtime log analysis with Mesos, Docker, ...Big Data Open Source Security LLC: Realtime log analysis with Mesos, Docker, ...
Big Data Open Source Security LLC: Realtime log analysis with Mesos, Docker, ...
 
Developing Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache KafkaDeveloping Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache Kafka
 
Real-Time Log Analysis with Apache Mesos, Kafka and Cassandra
Real-Time Log Analysis with Apache Mesos, Kafka and CassandraReal-Time Log Analysis with Apache Mesos, Kafka and Cassandra
Real-Time Log Analysis with Apache Mesos, Kafka and Cassandra
 
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming ApplicationsRunning Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
 
Introduction to apache kafka
Introduction to apache kafkaIntroduction to apache kafka
Introduction to apache kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
 
containerD
containerDcontainerD
containerD
 
Ippevent : openshift Introduction
Ippevent : openshift IntroductionIppevent : openshift Introduction
Ippevent : openshift Introduction
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Introduction To Apache Mesos
Introduction To Apache MesosIntroduction To Apache Mesos
Introduction To Apache Mesos
 
KAFKA Quickstart
KAFKA QuickstartKAFKA Quickstart
KAFKA Quickstart
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
 
Apache Kafka - Scalable Message Processing and more!
Apache Kafka - Scalable Message Processing and more!Apache Kafka - Scalable Message Processing and more!
Apache Kafka - Scalable Message Processing and more!
 
Open Source LinkedIn Analytics Pipeline - BOSS 2016 (VLDB)
Open Source LinkedIn Analytics Pipeline - BOSS 2016 (VLDB)Open Source LinkedIn Analytics Pipeline - BOSS 2016 (VLDB)
Open Source LinkedIn Analytics Pipeline - BOSS 2016 (VLDB)
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 

Plus de tdc-globalcode

Plus de tdc-globalcode (20)

TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidadeTDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
 
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
 
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de SucessoTDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
 
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPATDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
 
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVinoTDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
 
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
 
TDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devicesTDC2019 Intel Software Day - Inferencia de IA em edge devices
TDC2019 Intel Software Day - Inferencia de IA em edge devices
 
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca PublicaTrilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
 
Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#Trilha .Net - Programacao funcional usando f#
Trilha .Net - Programacao funcional usando f#
 
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case EasylocusTDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Go - Case Easylocus
 
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
 
TDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em GolangTDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - Clean architecture em Golang
 
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QATDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
 
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendenciaTDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
 
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR ServiceTDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
 
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NETTDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
 
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
 
TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - .NET funcional com F#
 
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net CoreTDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor  em .Net Core
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
 

Dernier

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 

Dernier (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

TDC2016POA | Trilha Arquitetura - Apache Kafka: uma introdução a logs distribuídos

  • 1. Logs Distribuídos uma introdução ao Apache Kafka Pedro Arthur P. R. Duarte pedroarthur.jedi@gmail.com
  • 3. Origens e Objetivos Projeto criado pela equipe de arquitetura do LinkedIn. O objetivo do projeto é prover uma insfraestrutura de mensagens de alto troughput e fácil escalabilidade. 3
  • 4. Mas... Como? O servidores de mensagem (aka brokers) preocupam-se somente com a manutenção do estado do cluster Kafka; Para o mundo externo, os brokers provem somente a visão de tópicos e offsets para que os clientes possam manter seu próprio estado. 4
  • 5. "Apache Kafka is pusblish-subscribe messaging rethought as a distributed commit log" Apache Kafka’s home page http://kafka.apache.org 5
  • 6. Log? Log tipo arquivos de log? $ sudo tail -n 5 -f /var/log/syslog Jun 4 19:37:07 inception systemd[1]: Time has been ch ... Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ... Jun 4 19:39:13 inception systemd[1]: Started Cleanup ... Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ... Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ... _ 6
  • 7. Log? Log tipo arquivos de log? $ sudo tail -n 5 -f /var/log/syslog Jun 4 19:37:07 inception systemd[1]: Time has been ch ... Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ... Jun 4 19:39:13 inception systemd[1]: Started Cleanup ... Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ... Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ... Jun 4 19:49:02 inception ntpd[711]: receive: Unexpect ... _ 6
  • 8. Log? Log tipo arquivos de log? $ sudo tail -n 5 -f /var/log/syslog Jun 4 19:37:07 inception systemd[1]: Time has been ch ... Jun 4 19:37:07 inception systemd[1]: apt-daily.timer: ... Jun 4 19:39:13 inception systemd[1]: Started Cleanup ... Jun 4 19:40:01 inception CRON[5892]: (root) CMD (test ... Jun 4 19:44:51 inception org.kde.kaccessibleapp[6056] ... Jun 4 19:49:02 inception ntpd[711]: receive: Unexpect ... Jun 4 19:55:31 inception kernel: [11996.667253] hrtim ... _ 6
  • 9. O que é um log? time First entry ... (t) entry (t+1) entry (t+2) entry (t+n) entry ... next entry 7
  • 10. Onde logs são utilizados? Sempre que precismos armazenar o que aconteceu e quando aconteceu... 8
  • 11. Onde logs são utilizados? Sistemas de Base de Dados – PostgreSQL’s Write-Ahead Loggind (WAL) – Oracles 10/11G Redo Log Sistemas de controle de versão – Git, The Stupid Content Tracker – Subversion 9
  • 12. Git’s log: um log, mas nem tanto $ git log --oneline 498d410 Fixes message format and adds some logging e09c955 Enhances the ContainerStub with a StoredObject stub 18fe603 Puts topic name in a configuration companion object 89d9c5d Separates consumer from producer configuration a9f1a76 Adds a provisory container stub d800dfe Creates consumer configuration fa4da8e Removes trash 4808450 Adds kafka producer 333b14f Let there be light 10
  • 13. Git’s reflog: um verdadeiro log $ git reflog 498d410 HEAD@0: commit (amend): Fixes message format and adds some ... 9147167 HEAD@1: commit (amend): Fixes message format and adds some ... 97d8661 HEAD@2: commit: Fixes message format and adds some logging e09c955 HEAD@3: commit: Enhances the ContainerStub with a StoredOb ... 18fe603 HEAD@4: rebase finished: returning to refs/heads/master 18fe603 HEAD@5: rebase: checkout refs/remotes/origin/master d800dfe HEAD@6: rebase finished: returning to refs/heads/master d800dfe HEAD@7: rebase: Creates consumer configuration fa4da8e HEAD@8: rebase: checkout refs/remotes/origin/master 701b3e6 HEAD@9: commit: Creates consumer configuration 4808450 HEAD@10: commit: Adds kafka producer 333b14f HEAD@11: clone: from https://pedroarthur@bitbucket.org/ped ... 11
  • 15. Mais sistemas, mais dados, mais problemas... 13
  • 16. Utilizando um log como um perspective broker 14
  • 18. Replicação Ativo/Ativo e Back-up Primário 16
  • 19. A Single Source of Truth 17
  • 21. Visão geral do Kafka Zookeeper cluster Producer Producer Producer Consumer Group A Consumer Group B Consumer Group C Block Storage 19
  • 22. "Apache Zookeeper is an ... server which enables highly reliable distributed coordination" Apache Zookeeper’s home page 20
  • 23. Zookeeper Do ponto de vista das interfaces de programação, o Zookeeper é um "sistema de arquivos com garantias"; por exemplo – Diferentes clientes tentam criar um arquivo, somente um deles receberá uma notificação positiva; – Diferentes clientes tentam alterar um arquivo, somente um deles receberá a notificação de escrita e os demais devem retentar a operação 21
  • 24. Anatomia de um Tópico Partition 0 @ broker_a Partition 1 @ broker_b Partition 2 @ broker_c topic Consumer 2 Consumer 0 Consumer 1 Cosumer Group A Producer Producer Producer 22
  • 26. Anonimizado xD A/B data aggregation Source A Database Source B Database A/B Aggregation Database A/B Aggregation Topic Data Enrichment Pipeline Data Analysis Engine A Topic B Topic Source A Data Transformation Source B Data Transformation Flume Master Node Data Source A Data Source B2 Data Source B1 Query API Publish/Subscriber Integration API Analysis Database 24
  • 28. Producer em Scala (>= 0.9.0.0) val properties = new Properties () { put("bootstrap.servers", "broker1 :9092 , broker2 :9092") put("key.serializer ", "org.apache.kafka.common. serialization . StringSerializer ") put("value.serializer ", "org.apache.kafka.common. serialization . StringSerializer ") put("acks", "1") put("retries", "0") /* any colour you like */ } val producer = new KafkaProducer [String , String ]( properties ) 26
  • 29. Producer em Scala (>= 0.9.0.0) val message = new ProducerRecord [String , String ]( " the_destination_topic ", "entry key", "your data") /* just try to send data */ val future: Future[ RecordMetadata ] = producer.send(message) /* try to send data and call -me back after it */ val futureAndCallback : Future[ RecordMetadata ] = producer.send(message , new Callback () { def onCompletion ( metadata: RecordMetadata , exception: Exception) { /* (metadata XOR exception) is non -null :( */ } }) producer.close () /* release */ 27
  • 30. Consumer em Scala (>= 0.9.0.0) val properties = new Properties () { put("bootstrap.servers", "broker1 :9092 , broker2 :9092") put("group.id", " the_group_id ") put("enable.auto.commit", "true") put("auto.commit.interval.ms", "1000") put("key. deserializer ", "org.apache.kafka.common. serialization . StringDeserializer ") put("value. deserializer ", "org.apache.kafka.common. serialization . StringDeserializer ") /* any colour you like */ } val consumer = new KafkaConsumer [String , String ]( properties ) 28
  • 31. Consumer em Scala (>= 0.9.0.0) /* subscribe to as many topics as you like */ consumer.subscribe(Arrays.asList(" the_destination_topic ")) while (true) { val records: /* argument is the timeout in millis */ ConsumerRecords [String , String] = consumer.poll (100) records foreach { record: ConsumerRecord [String , String] => log.info("${record.topic ()} is at ${record.offset ()}") } } 29
  • 33. Jay Krep’s I Heart Logs "Why a book about logs? Thats easy: the humble log is an abstraction that lies at the heart of many systems, from NoSQL databases to cryptocurrencies. Even though most engineers dont think much about them, this short book shows you why logs are worthy of your attention ..." Release Date: October 2014 31
  • 35. Kafkabox: sincronização de arquivos Pequeno projeto prova de conceito utilizando Kafka, OpenStack Swift e inotify; baixe-o com o comando a seguir: $ git clone http://bitbucket.com/pedroarthur/kafkabox/ 33
  • 36. Implementação – Inotify: escute todas as mudanças do diretório; – Para cada mudança, – Envie mudança para o Swift via HTTP; – Escreva a mudança ocorrida no tópico Kafka. 34
  • 37. Logs Distribuídos uma introdução ao Apache Kafka Pedro Arthur P. R. Duarte pedroarthur.jedi@gmail.com