mongodb, rabbitmq y applicaciones en nube
DESCRIPTION
Review de las principales tecnologías que estamos usando en cloudTRANSCRIPT
![Page 2: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/2.jpg)
Arquitectura orientada a msjs
![Page 3: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/3.jpg)
h8p://railsdog.com/blog/2009/12/generaAng-‐pdfs-‐on-‐ec2-‐with-‐ruby/
![Page 4: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/4.jpg)
![Page 5: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/5.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/6.jpg)
![Page 7: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/7.jpg)
Direct Message
Cerveza Vino
Cerveza
Cerveza
Matching exact key
![Page 8: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/8.jpg)
Fanout Exchange
Bebida Bebida
Cerveza
Cerveza Cerveza
Copy to all
![Page 9: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/9.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/10.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/11.jpg)
![Page 12: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/12.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/13.jpg)
MongoDB NO es …
• Para transaciones • Para OLAP • RDBMS (AcAveRecord?)
![Page 14: MongoDB, RabbitMQ y Applicaciones en Nube](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/14.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/15.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/16.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/17.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/18.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/19.jpg)
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](https://reader033.vdocuments.mx/reader033/viewer/2022052909/5598989e1a28ab484b8b47f3/html5/thumbnails/20.jpg)
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