2. This is our vision
Building the foundation to Build a 3B Company by FY20
Federico León
Senior Analyst
Fraud Prevention Team
Java, Groovy and Golang... developer
federico.leon@mercadolibre.com
Sobre mí
3. This is our vision
Building the foundation to Build a 3B Company by FY20
+ ¿Cómo empieza? ¿Por qué un nuevo lenguaje?
+ Características del lenguaje.
+ Concurrencia.
+ ¿Dónde lo aplicamos en Meli y qué resultados obtuvimos?
+ Q & A.
Agenda
5. This is our vision
Building the foundation to Build a 3B Company by FY20
¿Cómo empieza?
+ 21 de septiembre de 2007: Inicios. por Robert Griesemer, Rob Pike y Ken Thompson.
+ Principios de 2008: Se comienza el desarrollo del compilador. Proyecto part-time.
+ Mediados de 2008: Golang se convierte en un proyecto full-time.
+ Fines de 2008: Russ Cox se une al proyecto y con su experiencia ayuda a pasar Go de un
prototipo a una realidad.
+ 10 de noviembre de 2009: Proyecto público y open source.
6. This is our vision
Building the foundation to Build a 3B Company by FY20
¿Cómo empieza?
7. This is our vision
Building the foundation to Build a 3B Company by FY20
¿Por qué un nuevo lenguaje?
Código fuente en Google
+ 2.000.000.000 líneas de
código.
+ 86 TBs.
Distribuído entre 10
datacenters.
Fuente: Rachel Potvin @Scale
Engineering Conference
¿Qué alternativa elegir?
Compilación eficiente.
Ejecución eficiente.
Facilidad de programación.
Soporte MultiCore.
¿Cuál seleccionamos?
8. This is our vision
Building the foundation to Build a 3B Company by FY20
¿Por qué un nuevo lenguaje?
Otros problemas:
Builds lentos.
Dependencias descontroladas.
Cada programador usando un subconjunto diferente del lenguaje.
Pobre entendimiento del código, (difícil de leer, mal documentado, etc).
Duplicación de esfuerzo.
10. This is our vision
Building the foundation to Build a 3B Company by FY20
Algunas características de Go
+ Imperativo.
+ Compilado.
+ Fuerte y estáticamente tipado.
+ Diseñado para la concurrencia.
+ Framework de testing nativo.
+ Web server integrado.
11. This is our vision
Building the foundation to Build a 3B Company by FY20
¿Estáticamente tipado?
12. This is our vision
Building the foundation to Build a 3B Company by FY20
Funciones con múltiples retornos
13. This is our vision
Building the foundation to Build a 3B Company by FY20
Bucles? Sólo necesitamos uno!
14. This is our vision
Building the foundation to Build a 3B Company by FY20
Rangos
15. This is our vision
Building the foundation to Build a 3B Company by FY20
Para más tarde: defer
16. This is our vision
Building the foundation to Build a 3B Company by FY20
Servidor web integrado
18. This is our vision
Building the foundation to Build a 3B Company by FY20
Primero recordemos lo siguiente:
Concurrencia
Composición de procesos ejecutándose independientemente.
Paralelismo
Ejecución simultánea de procesos, (pueden o no estar relacionados).
La concurrencia provee una forma de estructurar la solución a un determinado
problema de forma que (si se necesitara o fuera posible) podría ejecutarse en
paralelo.
19. This is our vision
Building the foundation to Build a 3B Company by FY20
Ejemplo: Reciclemos manuales viejos!
20. This is our vision
Building the foundation to Build a 3B Company by FY20
Agregamos un gopher
21. This is our vision
Building the foundation to Build a 3B Company by FY20
Le proveemos herramientas
22. This is our vision
Building the foundation to Build a 3B Company by FY20
Podríamos pensar en paralelo...
23. This is our vision
Building the foundation to Build a 3B Company by FY20
Otro diseño
24. This is our vision
Building the foundation to Build a 3B Company by FY20
Podríamos pensar en paralelo...
25. This is our vision
Building the foundation to Build a 3B Company by FY20
Otro diseño
26. This is our vision
Building the foundation to Build a 3B Company by FY20
Podríamos pensar en paralelo...
27. This is our vision
Building the foundation to Build a 3B Company by FY20
Todo junto!
28. This is our vision
Building the foundation to Build a 3B Company by FY20
Conclusiones
+ Manuales => Contenido (json, xml, archivos, bases de datos, procesos, etc).
+ Gopher => CPU.
+ Carretilla => Tráfico de red, discos, etc.
+ Horno => Frontends, otras APIs, servicios externos.
Un diseño concurrente para un servicio web escalable.
Gophers sirviendo contenido web!
29. This is our vision
Building the foundation to Build a 3B Company by FY20
Goroutines
30. This is our vision
Building the foundation to Build a 3B Company by FY20
Canales
31. This is our vision
Building the foundation to Build a 3B Company by FY20
Select
33. This is our vision
Building the foundation to Build a 3B Company by FY20
Algunos números de MercadoLibre:
MELI Cloud
22.740 instancias.
205 TBs en memoria RAM.
100.000 CPUs.
Amazon (Fury)
1.696 instancias.
1.716 volúmenes.
536 balanceadores de carga.
34. This is our vision
Building the foundation to Build a 3B Company by FY20
Algunas APIs: Locations
35. This is our vision
Building the foundation to Build a 3B Company by FY20
Algunas APIs: Categories
36. This is our vision
Building the foundation to Build a 3B Company by FY20
Algunas APIs: Tendencias
37. This is our vision
Building the foundation to Build a 3B Company by FY20
Links de interés
+ Página oficial: https://golang.org
+ Golang tour: https://tour.golang.org/welcome
+ Effective Go: https://golang.org/doc/effective_go.html
+ Playground: https://play.golang.org/
En Argentina:
+ Meetup: http://www.meetup.com/Golang-Argentina/
+ Facebook: https://www.facebook.com/golangar/
+ Twitter: @golangar
Agregar más gophers no es suficiente. Necesitan herramientas para trabajar.
Más rápido.
Cuellos de botella.
Necesitamos sincronizar los gophers.
Diseño concurrente.
Puede o no ejecutarse en paralelo.
De ser así, este diseño es 2X más rápido que el anterior.
Concurrente.
4 gophers realizando tareas simples.
2 gophers
Una pila en el medio para acumular manuales.
16 gophers.
Puede ejecutarse tanto single thread como en paralelo.
En paralelo, la solución es casi 16X más rápida que el diseño original.
Se crean y lanzan anteponiendo la palabra reservada go.
Muy livianas.
No son threads!!!
Se basan en CSP, “Communicating Sequential Processes”, Tony Hoare, 1978.
Parten de su implementación en Erlang.
Permiten la comunicación y sincronización de varias goroutines.
Similar a un switch.
La decisión se basa en la habilidad de comunicar en vez de valores iguales.