Mesos + Docker = ❤






Engineer @Airwoot
@abishekk92 



"There is no just getting around to it.You're building a Distributed System."






Mark Cavage



High Availability and Cluster Utilisation(Maximize)


High Availability



All the services are running all the time. i.e even if something goes down it is "automagically" taken care of and the entire service will not have to go into a downtime.


Cluster is under utilised or over utilised depending on how the resources are allocated. So why not allocate them?

  • Resource allocation is hard.
  • Doing it elastically is even harder.
  • Top it with the rigidity each one of these framework come with




Let there be a resource allocator!
Apache Mesos




  1. Initially published as a research paper by  Benj Hindman et al at UCB.
  2. Later on adopted and extended at Twitter.  (Almost all of Twitter's Infra is now on Mesos)
  3. One of the top Apache projects.
  4. Airbnb, Opentable, Categorized are using Mesos to manage their cluster.





"Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications. Mesos can run Hadoop, Jenkins, Spark, Aurora, and other applications on a dynamically shared pool of nodes."




Mesos lets you treat a cluster, or a data center infact as a 
single computing entity.

Architecture



Image credit : Mesos Paper Benj Hindman et al

Image credit : Mesos Paper Benj Hindman et al



Building a Framework on Mesos


Each framework in Mesos has two components.


  • Framework Scheduler
  • Framework Executor



DEMO




It is just too much to create custom Schedulers and Executors for all the frameworks/services in the cluster!
Marathon




  • Developed by Mesosphere
  • Useful for long running jobs.
  • Metaframework for getting things to work on Mesos.




Marathon is like Upstart or init. It is just the first framework you run on Mesos. Once up , you can run whatever you want on it, even Marathon itself.

Marathon Architecture


Marathon is completely RESTful.




 {"id" : "foo-app",  "cmd" : "cd foo-app && bundle install && bundle exec unicorn -p $PORT",  "mem" : 512,  "cpu" : 1.0,  "instances" : 5,  "uris" : ["http://<url-to-your-tarball-zip-or-jar"],  "env"  : [<your-list-env-variables>],  "ports" : [8080],  "constraints" : ["hostname", "UNIQUE", ""]}  

There is just one huge drawback!



It is just too painful to package your app and its dependencies into a tarball or JAR. Too much bloat.  And yeah you would need to have all your system dependencies pre installed on each one of your nodes.









Can we better this?
Docker


"Docker is a container management system. You can also create file system images and launch containers from them"







AMIs anyone?





Docker images are similar but a gazillion times  better. 

AUFS



Another Union File System.

You can just start with a base file system state and keep adding layers on top of them. Each of these layers can be "unioned" together and viewed as a  single file system.  

Anatomy of a docker COntainer



Image credit : Docker Website


Containers make packaging an application and it's dependencies a breeze!




Okay, now let us bring Mesos and Docker together into the equation.



Docker Executor


Image credits mesos-docker project


So putting everything together


  1. Resource Allocation and HA - Mesos.
  2. Extending frameworks via Marathon.
  3. Managing Application dependencies Docker.


Questions




Tweet your questions or just say Hi 
@abishekk92

Mesos + Docker

By Abishek Bhat

Mesos + Docker

This is my talk at RootConf Delhi on building elastic clusters using Apache Mesos and Docker.

  • 2,224