MongoDB, RabbitMQ y Applicaciones en Nube

1

description

Review de las principales tecnologías que estamos usando en cloud

Transcript of MongoDB, RabbitMQ y Applicaciones en Nube

Page 1: MongoDB, RabbitMQ y Applicaciones en Nube

MongoDB,  RabbitMQ  y    aplicaciones  en  nube  

Gustavo  Arjones  [email protected]  |  @arjones  

Page 2: MongoDB, RabbitMQ y Applicaciones en Nube

Arquitectura  orientada  a  msjs  

Page 3: MongoDB, RabbitMQ y Applicaciones en Nube

h8p://railsdog.com/blog/2009/12/generaAng-­‐pdfs-­‐on-­‐ec2-­‐with-­‐ruby/  

Page 4: MongoDB, RabbitMQ y Applicaciones en Nube
Page 5: MongoDB, RabbitMQ y Applicaciones en Nube

RabbitMQ  

•  Message  Queue  (AMQP  compliance)  •  Arquitectura  orientada  a  mensajes  

•  Desacoplado,  Aislado  •  Facil  escalabilidad  horizontal  

•  “AlternaAva”:  Kestrel  /  Twi8er  (NO  AMQP!)  

Page 6: MongoDB, RabbitMQ y Applicaciones en Nube
Page 7: MongoDB, RabbitMQ y Applicaciones en Nube

Direct  Message  

Cerveza   Vino  

Cerveza  

Cerveza  

Matching  exact  key  

Page 8: MongoDB, RabbitMQ y Applicaciones en Nube

Fanout  Exchange  

Bebida   Bebida  

Cerveza  

Cerveza   Cerveza  

Copy  to  all  

Page 9: MongoDB, RabbitMQ y Applicaciones en Nube

Topic  Exchange  

#.Vino  Comida.*  

Bebida.Vino  

Route  by  Key  with  Key  Globbing  

Bebida.#  

Bebida.Vino   Bebida.Vino  

Page 10: MongoDB, RabbitMQ y Applicaciones en Nube

Nanite  

•  Nanite  is  a  new  way  of  thinking  about  building  cloud  ready  web  applicaAons.  Having  a  scalable  message  queueing  back-­‐end  with  all  the  discovery  and  dynamic  load  based  dispatch  that  Nanite  has  is  a  very  scalable  way  to  construct  web  applicaAon  back-­‐ends.    

Page 11: MongoDB, RabbitMQ y Applicaciones en Nube
Page 12: MongoDB, RabbitMQ y Applicaciones en Nube

MongoDB  es  …  

•  DB  Orientado  a  documentos  (schemaless)  •  “Facil”  escalar  horizontal  (shard)  •  Para  mantener  estructuras  complejas  (jerarquicas)  

•  Para  estadísAcas  “simples”  

•  Para  mantener  archivos  (GridFS)  

Page 13: MongoDB, RabbitMQ y Applicaciones en Nube

MongoDB  NO  es  …  

•  Para  transaciones  •  Para  OLAP  •  RDBMS  (AcAveRecord?)  

Page 14: MongoDB, RabbitMQ y Applicaciones en Nube

Select  SELECT  first_name,  last_name    

FROM  authors  WHERE  zipcode  =  1234  

ORDER  BY  last_name  DESC  LIMIT  2,  1;  

>  db.authors.find({"zipcode"  :  1234},      {"first_name"  :  1,  "last_name"  :  1  }).sort({"last_name"  :  -­‐1  })  

 .skip(2).limit(1);  

Page 15: MongoDB, RabbitMQ y Applicaciones en Nube

Select  SELECT  *  

FROM  authors  WHERE  dob  BETWEEN  ‘1970-­‐1-­‐1’  AND  ‘1990-­‐1-­‐1’  

AND  address  IS  NULL;  

>  db.authors.find({"dbo"  :  {  $gte  :  new  Date(“1970-­‐1-­‐1”),  $lte  :  new  Date(“1990-­‐1-­‐1”)},  “address”  :  {  $exists  :  false  }  }  );  

Page 16: MongoDB, RabbitMQ y Applicaciones en Nube

Upsert  (Update  +  Insert)  

>  db.tweets.update(  query,  modify,  upsert?,  mul2ple?  );  

>  db.setup.update({},  {  $set  :  {  "in_progress"  :  false  }  },  false,  true);  

>  db.setup.update({},  {  "opAons.last_status"  :  -­‐1},  false,  true);  

Page 17: MongoDB, RabbitMQ y Applicaciones en Nube

Indexes  >  db.  tweets.ensureIndex(  

 {"user.Ame_zone"  :  1},  {background:true});  

>  db.tweets.ensureIndex(    {"created_at"  :  1,  "user.Ame_zone"  :  1,  "tokens"  :  1},    {background:true});  

background:true    no  lock  para  crear  indices  

>  db.tweets.getIndexes()  

Page 18: MongoDB, RabbitMQ y Applicaciones en Nube

Prós  •  Schemaless  

•  Rápida  instalación  •  Muchos  Drivers  disponibles  

•  Map-­‐Reduce  MUY  lento  

•  Sharding  es  BETA  •  Nuevo  set  de  commandos  

Contras  

Page 19: MongoDB, RabbitMQ y Applicaciones en Nube

Tips  •  Pensar  BIEN  el  schema  antes  de  empezar  •  Guardar  calculaAon  •  Evitar  map-­‐reduce  (unAl  r.  1.8)  •  Indexes  TIENEN  que  entrar  en  RAM  

>  db.  tweets.totalIndexSize();  1187423168  (~1.1Gb)  

>  db.  tweets.storageSize();  16670199040  (~15.5  Gb)  

Page 20: MongoDB, RabbitMQ y Applicaciones en Nube

Referencias  

•  h8p://www.rabbitmq.com/  

•  h8p://www.mongodb.org/  

•  h8p://github.com/ezmobius/nanite  

•  h8p://github.com/robey/kestrel  

•  h8p://www.slideshare.net/somic/introducAon-­‐to-­‐amqp-­‐messaging-­‐with-­‐rabbitmq  

•  h8p://www.slideshare.net/ma8ma8/rabbitmq-­‐and-­‐nanite  

Page 21: MongoDB, RabbitMQ y Applicaciones en Nube

Muchas  gracias  

Gustavo  Arjones  [email protected]  |  @arjones