Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistent storage for Apache Mesos

Recently I've discovered such a thing as a Apache Mesos.

It all looks amazingly in all that demos and examples. I could easily imagine how one would run for stateless jobs - that fits to the whole idea naturally.

Bot how to deal with long running jobs that are stateful?

Say, I have a cluster that consists of N machines (and that is scheduled via Marathon). And I want to run a postgresql server there.

That's it - at first I don't even want it to be highly available, but just simply a single job (actually Dockerized) that hosts a postgresql server.

1- How would one organize it? Constraint a server to a particular cluster node? Use some distributed FS?

2- DRBD, MooseFS, GlusterFS, NFS, CephFS, which one of those play well with Mesos and services like postgres? (I'm thinking here on the possibility that Mesos/marathon could relocate the service if goes down)

3- Please tell if my approach is wrong in terms of philosophy (DFS for data servers and some kind of switchover for servers like postgres on the top of Mesos)

Question largely copied from Persistent storage for Apache Mesos, asked by zerkms on Programmers Stack Exchange.

like image 284
Carlos Castellanos Avatar asked Feb 06 '15 15:02

Carlos Castellanos


People also ask

Is Mesos deprecated?

Note: Apache Mesos support is deprecated as of Apache Spark 3.2. 0. It will be removed in a future version.

Which framework is used by Mesos to schedule containers?

Marathon is the first framework to be launched, running directly alongside Mesos. This means the Marathon scheduler processes are started directly using init , upstart , or a similar tool. Marathon is a powerful way to run other Mesos frameworks: in this case, Chronos.

How does Apache Mesos work?

Mesos consists of a master daemon that manages agent daemons running on each cluster node, and Mesos frameworks that run tasks on these agents. The master enables fine-grained sharing of resources (CPU, RAM, …) across frameworks by making them resource offers.

What is a Mesos cluster?

Apache Mesos is an open source cluster manager that handles workloads in a distributed environment through dynamic resource sharing and isolation. Mesos is suited for the deployment and management of applications in large-scale clustered environments.


1 Answers

Excellent question. Here are a few upcoming features in Mesos to improve support for stateful services, and corresponding current workarounds.

  1. Persistent volumes (0.23): When launching a task, you can create a volume that exists outside of the task's sandbox and will persist on the node even after the task dies/completes. When the task exits, its resources -- including the persistent volume -- can be offered back to the framework, so that the framework can launch the same task again, launch a recovery task, or launch a new task that consumes the previous task's output as its input.
    • Current workaround: Persist your state in some known location outside the sandbox, and have your tasks try to recover it manually. Maybe persist it in a distributed filesystem/database, so that it can be accessed from any node.
  2. Disk Isolation (0.22): Enforce disk quota limits on sandboxes as well as persistent volumes. This ensures that your storage-heavy framework won't be able to clog up the disk and prevent other tasks from running.
    • Current workaround: Monitor disk usage out of band, and run periodic cleanup jobs.
  3. Dynamic Reservations (0.23): Upon launching a task, you can reserve the resources your task uses (including persistent volumes) to guarantee that they are offered back to you upon task exit, instead of going to whichever framework is furthest below its fair share.
    • Current workaround: Use the slave's --resources flag to statically reserve resources for your framework upon slave startup.

As for your specific use case and questions:

1a) How would one organize it? You could do this with Marathon, perhaps creating a separate Marathon instance for your stateful services, so that you can create static reservations for the 'stateful' role, such that only the stateful Marathon will be guaranteed those resources.

1b) Constraint a server to a particular cluster node? You can do this easily in Marathon, constraining an application to a specific hostname, or any node with a specific attribute value (e.g. NFS_Access=true). See Marathon Constraints. If you only wanted to run your tasks on a specific set of nodes, you would only need to create the static reservations on those nodes. And if you need discoverability of those nodes, you should check out Mesos-DNS and/or Marathon's HAProxy integration.

1c) Use some distributed FS? The data replication provided by many distributed filesystems would guarantee that your data can survive the failure of any single node. Persisting to a DFS would also provide more flexibility in where you can schedule your tasks, although at the cost of the difference in latency between network and local disk. Mesos has built-in support for fetching binaries from HDFS uris, and many customers use HDFS for passing executor binaries, config files, and input data to the slaves where their tasks will run.

2) DRBD, MooseFS, GlusterFS, NFS, CephFS? I've heard of customers using CephFS, HDFS, and MapRFS with Mesos. NFS would seem an easy fit too. It really doesn't matter to Mesos what you use as long as your task knows how to access it from whatever node where it's placed.

Hope that helps!

like image 144
Adam Avatar answered Sep 21 '22 13:09

Adam