Learn how to design, build and implement a completely serverless and event driven real time analytics pipeline based on most of the newest and more sophisticated AWS services
I will share with you the experiences and the lessons we’ve learned working with these technologies in a real world scenario
2. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
2
Do it later, do it better
hacelo después, hacelo mejor
Lucas Ceballos
IT Director @ Headway
3. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
3
Real time data streaming!
Como procesar mas de 100k eventos por segundo y no morir en el intento
13. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
13
Arquitectura IdealEscalabilidad, elasticidad y optimización de costos
EVENT DRIVENSERVERLESSASINCRONA COST EFFECTIVE
15. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
15
En númerosPromedio de analytics de los últimos tres meses
Impresión
1º 2º 3º 4º
+50K / SEG
Click Install AcDvidad
+2K / SEG +7K / HOUR +15K / HOUR
17. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
17
Escenario #1
Fines de 2013
18. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
18
InfraEscenario #1
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
19. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
18
InfraEscenario #1
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
20. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
19
Lecciones Aprendidas
Escenario #1
Excel no funciona bien con +200k rows.
MySQL es muy difícil de escalar horizontalmente
1
MySQL es caro en un escenario de high throughput
2
3
21. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
20
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Escenario #2
Escenario #2
Escenario #4
Test Arquitectura Ideal
Escenario #1
22. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
21
Escenario #2
Junio/Julio 2014
23. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
22
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
InfraEscenario #2
24. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
22
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
SQS
Multiple Queues
EC2
Node Workers
EC2
Mongo RS
InfraEscenario #2
25. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
23
Lecciones Aprendidas
Escenario #2
SQS tiene muchas limitaciones (batches chicos, max in-flight
messages)
SQS es difícil de escalar (por sus limitaciones)
SQS no aseguraba estructura FIFO ni de-duplication
SQS es lento (funciona bajo HTTP)
1
Los mensajes puede ser procesados por un solo consumer
simultáneamente
2
3
4
5
26. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
24
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Escenario #2
Escenario #4
Test Arquitectura Ideal
Escenario #2
Escenario #2
27. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
24
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Escenario #2
Escenario #4
Test Arquitectura Ideal
Escenario #2
Escenario #2
28. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
25
Escenario #3
Septiembre 2015
29. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
26
EC2
Mongo RS
InfraEscenario #3
SQS
Multiple QueuesEC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
EC2
Node Workers
30. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
26
EC2
Mongo RS
InfraEscenario #3
SQS
Multiple QueuesEC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
EC2
Node Workers
31. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
26
EC2
Mongo RS
InfraEscenario #3
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
Kinesis
Multiple Streams EC2
Node Workers
32. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
26
Lambda
Node Functions
EC2
Mongo RS
InfraEscenario #3
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
Kinesis
Multiple Streams
33. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
27
Lecciones Aprendidas
Escenario #3
Kinesis no tiene una solución de auto scaling out of the box1
El procedimiento para escalar kinesis es tedioso, lento y a veces
poco estable
2
3
Kinesis nos permite tener multiples consumers por shard (hasta 5
lecturas por shard/s)
4
Las funciones lambda tienen un retry automático ante casos de
failure
5
La RAM de las funciones lambda es proporcional a la capacidad de
CPU
6 La paralelización está limitada por la cantidad de shards existentes
34. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
28
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Escenario #4
Test Arquitectura Ideal
¿Cumple el escenario con las condiciones?
Escenario #2
Escenario #3
35. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
28
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Escenario #4
Test Arquitectura Ideal
¿Cumple el escenario con las condiciones?
Escenario #2
Escenario #3
36. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
29
Escenario #4 (extra)
Enero 2017
37. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
30
InfraEscenario #4
Kinesis
Multiple Streams
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
fluentd
EC2
Mongo RS
Lambda
NodeJS Functions
38. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
30
InfraEscenario #4
Kinesis
Multiple Streams
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
fluentd
EC2
Mongo RS
Lambda
NodeJS Functions
39. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
30
InfraEscenario #4
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
fluentd
EC2
Mongo RS
Lambda
NodeJS Functions
S3
Buckets
SNS
Topics
40. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
30
InfraEscenario #4
EC2
Auto Scaling
Elasticache
Memcache
ELB
Event Tracking
RDS
Mysql Multi AZ
fluentd
EC2
Mongo RS
Lambda
NodeJS Functions
S3
Buckets
SNS
Topics
41. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
31
Lecciones Aprendidas
Escenario #4
Los costos de S3 pueden aumentar si se hacen muchos PUTs de
files muy pequeños
1
No es conveniente conectar S3 directo a Lambda, conviene hacerlo
a través de topics SNS (multiplexación, manejo de versiones, etc)
2
El payload de los mensajes de SNS tiene un máximo de 256 KB3
Las funciones lambdas que interactuan con S3 deben usar VPC
endpoints para ser mas eficientes (- transferencia, + velocidad)
4
Cuidado en la configuración de los triggers de las funciones lambdas,
se pueden generar referencias circulares.
5
42. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
32
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Test Arquitectura Ideal
¿Cumple el escenario con las condiciones?
Escenario #2
Escenario #3
Escenario #4
43. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
32
Event Driven Serverless Asíncrona Cost Effective
Escenario #1
Test Arquitectura Ideal
¿Cumple el escenario con las condiciones?
Escenario #2
Escenario #3
Escenario #4
44. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
33
www.headwaydigital.comlucas@headwaydigital.com
COMPANY NAME
1234 Long Beach
Los Angeles California
lucas-ceballos
We’re hiring!
45. Lucas Ceballos
Do it later, do it better @ Nerdearla 2017
33
www.headwaydigital.comlucas@headwaydigital.com
COMPANY NAME
1234 Long Beach
Los Angeles California
Gracias!Q&A
lucas-ceballos
We’re hiring!