Download Presentación de PowerPoint

Document related concepts
no text concepts found
Transcript
Madrid Python Meetup
PYTHON Y FLINK
© GMV, 2016 Propiedad de GMV
Todos los derechos reservados
ÍNDICE
INTRODUCCIÓN
APACHE FLINK
EXPERIENCIA PYTHON
CONCLUSIONES
Madrid Python Meetup
2016/03/10
Página 2
¿QUIÉNES
SOMOS?
GMV
QUIÉNES SOMOS
UN GRUPO TECNOLÓGICO
GLOBAL
Grupo
multinacional
tecnológico
Sede principal
en España
(Madrid)
Capital
privado
Más de 1.100
empleados
Oficinas en 10 países
Fundado en
1984
Madrid Python Meetup
2016/03/10
Página 4
Aeronáutica, Espacio, Defensa,
Seguridad, Sanidad, Transporte,
Banca y finanzas, y Tecnologías de la
Información y la Comunicación
Origen
vinculado
al sector
espacial y
defensa
Ingeniería, desarrollo
e integración de
sistemas, software,
hardware, servicios y
productos
especializados
INTRODUCCIÓN
INTRODUCCIÓN
ACLARACIONES
Apache Flink no es un
servidor web ni un jefe indio
No vamos a contar palabras
¿Qué sabéis de Big Data?
Madrid Python Meetup
2016/03/10
Página 8
¿POR QUÉ APACHE FLINK?
MADUREZ DEL BIGDATA
Streaming
Procesar
Almacenar
Descartar
Madrid Python Meetup
2016/03/10
Página 9
¿POR QUÉ APACHE FLINK?
ARQUITECTURA TÍPICA
Data
adquisition
Stream Processing
Serving DB
• Es común almacenar también la información en crudo
• La base de la arquitectura suele ser un clúster con HDFS
Madrid Python Meetup
2016/03/10
Página 10
¿POR QUÉ APACHE FLINK?
DESPLIEGUE
Clúster de Kafka
K1
K2
Clúster de HDFS + Flink
Kn
M1
C1
C2
C3
C4
C5
C6
W4
2016/03/10
W5
Wn
Clúster de Cassandra
Madrid Python Meetup
W1
W2
Página 11
W3
W6
¿POR QUÉ
APACHE
FLINK?
¿POR QUÉ APACHE FLINK?
APACHE FLINK
El core de Flink es un motor
de procesamiento de flujos
de datos en streaming.
Proporciona distribución de los
datos, comunicación y tolerancia
a fallos para realizar
computación distribuida con
streams de datos.
Sobre ese core se han
desarollado dos API y varias
librerías en Scala, Java y Python
Madrid Python Meetup
2016/03/10
Página 13
FLINK: CARACTERÍSTICAS DIFERENCIADORAS
VENTANAS
2s
1s
5 2 6 3 7 5 3 8 2 1 9 4
Ventanas temporales
5 2 6 3 7 5 3 8 2 1 9 4
16
23
16
stream.timeWindowAll(Time.seconds(1)).
sum();
Ventanas deslizantes
5 2 6 3 7 5 3 8 2 1 9 4
5 2 6 3 7 5 3 8 2 1 9 4
16
Madrid Python Meetup
21
23
14
2016/03/10
16
Página 14
stream.timeWindowAll(Time.seconds(1),T
ime.milliseconds(500)).sum();
FLINK: CARACTERÍSTICAS DIFERENCIADORAS
VENTANAS POR CLAVE
2s
1s
(A,5) (B,2) (A,6) (C,3) (C,7) (A,5) (B,3) (C,8) (B,2) (A,1) (C,9) (B,4)
Ventanas fijas por clave
(A,5)
(A,6)
(A,5)
(B,2)
(A,1)
(B,3)
(C,3) (C,7)
(A,11)(B,2)(C,3)
(B,2)
(B,4)
(C,8)
(A,5)(B,3)(C,15)
(C,9)
stream.keyBy(0).timeWindow
(Time.seconds(1)).sum(1)
(A,1)(B,6)(C,9)
Ventanas por número de elementos
(A,5)
(A,6)
(A,5)
(B,2)
(A,1)
(B,3)
(C,3) (C,7)
(A,11)(B,5)
Madrid Python Meetup
(C,10)
(B,2)
(C,8)
(A,6)
2016/03/10
(C,17) (B,6)
Página 15
(B,4)
(C,9)
stream.keyBy(0).countWindow(
2).sum(1)
DATASTREAM API
TRIGGERS Y EVICTORS
Triggers
5 2 9 9 7 0 3 8 2 A 9 4
20
Pueden cancelar el procesado de los
elementos de una ventana
Permiten adelantar el procesado de una
ventana
18
Evictors
5 2 9 9 7 -1 3 8 2 1 9 4
7
25
Madrid Python Meetup
3
Podemos controlar los elementos que
llegan de las ventanas antes de
evaluarlos
8
18
16
2016/03/10
Página 16
DATASTREAM API
EL TIEMPO ES IMPORTANTE
¿Qué tiempo utilizar para construir las ventanas?
El momento en que se
procesa el evento
El momento en el que se
generó el evento
El momento en que se
recibe el evento
Flink maneja relojes diferentes para cada
uno de ellos
Madrid Python Meetup
2016/03/10
Página 17
COMPARATIVA
RENDIMIENTO
• Lo deseable es mantener un alto caudal con una latencia baja
• Flink permite ajustar los tamaños de los buffers internos para
aumentar el caudal a costa de aumentar la latencia y
viceversa.
Madrid Python Meetup
2016/03/10
Página 18
COMPARATIVA
FUNCIONALIDADES
Streaming
“true”
mini batches
“true”
API
low-level
high-level
high-level
Fault tolerance
tuple-level ACKs
State
not built-in
external
internal
Exactly once
at least once
exactly once
exactly once
Windowing
not built-in
restricted
flexible
Latency
low
medium
low
Throughput
medium
high
high
Madrid Python Meetup
2016/03/10
Página 19
RDD-based (lineage) coarse checkpointing
EXPERIENCIA
CON PYTHON
EXPERIENCIA CON PYTHON
SEGÚN LA DOCUMENTACIÓN
La mayoría de las API no están
disponibles.
¡¡No está disponible la API
para Streams!!
El API para procesado en batch
tiene todas las operaciones
(alguna más que en scala)
Los conectores de E/S son
muchos menos y con menos
opciones
Madrid Python Meetup
2016/03/10
Página 21
EXPERIENCIA CON PYTHON
PRUEBA BÁSICA
class Adder(GroupReduceFunction):
data \
def reduce(self, iterator, collector):
.map(lambda x: (1, x[5])) \
count, event = iterator.next()
.group_by(1) \
count += sum([x[0] for x in iterator])
.reduce_group(Adder()) \
collector.collect((event, count))
.map(lambda x: 'Event: %s. Freq: %s' % (x[0],x[1]))\
.write_text(output_file,write_mode=WriteMode.OVERWRITE)
if __name__ == "__main__":
output_file = 'out.txt'
env.execute(local=True)
env = get_environment()
data =
env.read_csv("/home/jordi/Development/pythonflink/final-dataset.csv",\
(INT, STRING, STRING, STRING, STRING, STRING,
STRING, STRING, BOOL, BOOL, INT, INT, INT, INT,
STRING, INT, INT, STRING, STRING, FLOAT, FLOAT,
STRING))
Madrid Python Meetup
2016/03/10
El rendimiento es más bajo que el
mismo programa en scala.
Levanta un intérprete Python que
envía el código al core de Flink
Página 22
EXPERIENCIA CON PYTHON
POCA ACIVIDAD
El último commit de la parte de Python fue hace varios meses:
En proporción, hay muy poco código Python:
Madrid Python Meetup
2016/03/10
Página 23
EXPERIENCIA CON PYTHON
CONCLUSIONES
Madrid Python Meetup
2016/03/10
Página 24
www.gmv.es
GRACIAS
José Carlos Baquero ([email protected])
Pablo González
([email protected])
Jordi Redondo
([email protected])
www.linkedin.com/company/gmv
www.facebook.com/infoGMV
@infoGMV_es
BACKUP
SLIDES
GMV
PERFORMANCE
TERASORT
Terasort es una prueba para medir el rendimiento de tecnologías
BigData. Se trata de ordenar 1 Tb de datos (o más) en el menor
tiempo posible
http://eastcirclek.blogspot.com.es/2015/06/terasort-for-spark-and-flink-with-range.html
Madrid Python Meetup
2016/03/10
Página 51
PERFORMANCE
TERASORT
http://eastcirclek.blogspot.com.es/2015/06/terasort-for-spark-and-flink-with-range.html
Madrid Python Meetup
2016/03/10
Página 52
PERFORMANCE
STREAMING - YAHOO
The job of the benchmark is to read various JSON events from Kafka, identify the
relevant events, and store a windowed count of relevant events per campaign
into Redis.
https://yahooeng.tumblr.com/post/135321837876/benchmarking-streaming-computation-engines-at
Madrid Python Meetup
2016/03/10
Página 53
PERFORMANCE
STREAMING - YAHOO
https://yahooeng.tumblr.com/post/135321837876/benchmarking-streaming-computation-engines-at
Madrid Python Meetup
2016/03/10
Página 54
PERFORMANCE
STREAMING - YAHOO
https://yahooeng.tumblr.com/post/135321837876/benchmarking-streaming-computation-engines-at
Madrid Python Meetup
2016/03/10
Página 55
VENTANAS
CONSTRUCCIÓN DE VENTANAS
http://data-artisans.com/how-apache-flink-enables-new-streaming-applications-part-1/
Madrid Python Meetup
2016/03/10
Página 56
VENTANAS
CONSTRUCCIÓN DE VENTANAS
Madrid Python Meetup
2016/03/10
Página 57