Download - Meetup - NGinx - 08/2014

Transcript
Page 1: Meetup - NGinx - 08/2014

Meetup - Nginx04/08

Page 2: Meetup - NGinx - 08/2014

● Introducción○ Qué problemas teníamos?○ Cómo los resolvimos?

● Nginx○ Qué es?○ Cómo funciona?○ Benchmark○ Demo○ Tráfico/Números

● NGinx Mejoras○ AB Test implementation○ Mobile detection○ Testing rules○ Logs / Tracking

● Preguntas

Agenda

Page 3: Meetup - NGinx - 08/2014

Introducción

Page 4: Meetup - NGinx - 08/2014

WebServerJava 1.5

BD

Web

F5InfrastructureDevelopment

Qué problemas teníamos?

WebServerJava 1.5

WebServerJava 1.5

WebServerJava 1.5

Page 5: Meetup - NGinx - 08/2014

80 mb

Qué problemas teníamos?

Page 6: Meetup - NGinx - 08/2014

● Deploy lento - Jar ~ 80mb

● Incertidumbre y dificultad de upgrade de versiones

● Innovación acotada

● Solo contratábamos desarrolladores java

● Dependencia externa para configurar reglas

● Dificultad para dedicar hardware a ciertas funcionalidades

● ....

“if the only tool you have is a hammer, to treat everything as if it were a nail”. Abraham Maslow

Qué problemas teníamos?

Page 7: Meetup - NGinx - 08/2014

Qué problemas teníamos?

Page 8: Meetup - NGinx - 08/2014

● Deploy lento - ~Jar 80mb Aplicaciones acotadas!

● Incertidumbre y dificultad de upgrade de versiones Aplicaciones independientes!

● Innovación acotada Stack libre!

● Solo contratábamos desarrolladores java Developers en cualquier lenguaje!

● Dependencia externa para configurar reglas Acceso abierto a reglas!

● Dificultad para dedicar hw a ciertas funcionalidades Crear equipos facilmente!

● Open platform!

Cómo los resolvimos?

Page 9: Meetup - NGinx - 08/2014

Web

F5

InfrastructureDevelopment

NGinx

Node JS Play!Tomcat

Elastic search

NGinx

F5

Grails Rails

api.mercadolibre.com

[Enter your HTTP server

here]

Cómo los resolvimos?

Page 10: Meetup - NGinx - 08/2014
Page 11: Meetup - NGinx - 08/2014

Fuente: http://static.thegeekstuff.com/wp-content/uploads/2013/11/nginx-architecture.png

Cómo funciona?

Page 12: Meetup - NGinx - 08/2014

Fuente: http://joeandmotorboat.com/2008/02/28/apache-vs-nginx-web-server-performance-deathmatch/

Apache

NGINX

Benchmark

Page 13: Meetup - NGinx - 08/2014

Demo

Page 14: Meetup - NGinx - 08/2014

Server4 CPUs x Intel Core(TM)26 GB RAM

Ubuntu 12.04Linux 3.2.0-31-generic x86_64

Tráfico/Números

APIs 8,050,000 req x min 57 servers

Frontends 1,000,000 req x min 28 servers

Total 9,050,000 req x min 85 servers

Page 15: Meetup - NGinx - 08/2014

Mejoras

Page 16: Meetup - NGinx - 08/2014

upstream old_upstream {

server 127.0.0.1:1234;

}

upstream new_upstream {

server 127.0.0.1:4321;

}

split_clients $vars* $split_upstream {

10% _new_upstream;

- _old_upstream;

}

server {

location / {

proxy_pass http://$split_upstream$request_uri;

}

}

$vars* eg: $remote_addr / $request_uri

A/B Testing

upstream old_upstream {

server 127.0.0.1:1234;

}

upstream new_upstream {

server 127.0.0.1:4321;

}

location / {

if ($http_cookie ~* "test=yes") { proxy_pass

http://new_upstream; break; }

proxy_pass http://old_upstream;

}

Consistent hashing Custom hashing

Page 17: Meetup - NGinx - 08/2014

map $http_user_agent $xDeviceType { ~*(ipad|Silk.1.0.22.79|android(?!(.*mobile|.*kindle|.*A2107A|.*HP.

7|.*HP.Slate.7|.*B1-710|.*GT-P3100|.*IdeaTabA1000|.*gt-P3110|.*gt-P3113|.*ME172V|.*B1-A71|.*A200|.*A100|.

*SM-T210R|.*SGPT12|.*SM-T310))(?!(.*MMS-V))|xoom|sch-i800|playbook|tablet|gt-P1000|gt-P5100|gt-P7500|gt-

P7510|kindle.fire|.*KFOT.Build|.*KFTT.Build|.*KFJWI.Build|.*KFJWA.Build) "tablet";

~*(blackberry|android|iphone|ipod|symb|googlebot-mobile|Playstation.Vita|kindle|symbian|windows.

phone|BB10|Mobile.*Firefox|Nokia[0-9][0-9]|Nokia[A-Z][0-9]|LG-[A-Z][0-9]|SAMSUNG-GT|SPICE|Opera.Mini)

"mobile";

default "desktop";

}

proxy_set_header X-Device-Type "$xDeviceType";

map $http_user_agent $xDeviceJs {

~*(SPICE|BB10|SAMSUNG-GT-C3322|SAMSUNG-GT-E2200|SAMSUNG-GT-S5222|SAMSUNG-GT-

S3570|S3570XILH1|blackberry|symbian|opera.mini|windows.phone|Nokia[0-9][0-9]|Nokia[A-Z][0-9]|LG-C[0-9]

|LG-T[0-9]) false;

default true;

}

proxy_set_header X-Device-JS "$xDeviceJs";

Mobile detection

if(headers['X-Device-Type']=='desktop'){

render('desktop_tpl');

else{

render('mobile_table_tpl');

}

Backend - JS

Page 18: Meetup - NGinx - 08/2014

Logs/Tracking

NGinx

WS

X-D

ATA

: [R

ES

PO

NS

E_D

ATA

]

Stream

Hadoop

Real Time Consumers

● Live Streaming

● Información del Request completo.

● Trackeo por Browser, Session y Request.

● 100% de Trackeo.

● Información agregada client-side y server-side.

Page 19: Meetup - NGinx - 08/2014

Drone.io

curl b.ml.com

-> -> 10.3.2.5?

curl c.ml.com

-> -> 10.3.2.6?

curl d.ml.com

-> -> 10.3.2.7?

curl a.ml.com

-> -> 10.3.2.4?

1

Pull req

Launch CIRun tests

OK / Fail OK / Fail

OK

/ Fa

il

OK

?

23

4 5

7

6

Deploy

Testing rules

Coming soon open-source!

Page 20: Meetup - NGinx - 08/2014

Preguntas

We are hiring!