Skip to content

Resilience #1072

Open
Open

Description

@kszucs

Are there any plans for a highly available distributed cluster?

How much effort would it take (or is it possible at all) to:

  • periodically persist the state of the scheduler for failover?
  • or use a persistent backend instead of memory?
  • have standby schedulers (via leader election etc.)?

Activity

  1. mrocklin commented on May 10, 2017

    @mrocklin
    Member

    I don't have any such plans. Of course if you feel up to this you're welcome to do so.

    I suspect that all of these would take a non-trivial amount of effort.

    Edit

    Responding to your options:

    1. Periodically persist the state of the scheduler for failover

      Dumping data to disk doesn't sound terribly difficult.

    2. Use a persistent backend instead of memory

      My intuition says that this would be exceedingly slow. We operate in memory for a reason

    3. Standby schedulers

      You would need to keep scheduler state updated, this is feasible but probably challenging

    My preference

    If I were to do this myself (which I have no short-term plans of doing) I would instead have all of the workers and clients update a new scheduler with their state when the new scheduler comes online. This would require the clients to keep track of the graphs that they have sent so far. It would also require some non-trivial manipulations of the scheduler state.

    Avoid the question entirely

    Many people have asked about this question, but it's not clear that they need full resilience of the scheduler. Many times their needs are entirely satisfied by coupling Dask with a system like Kubernetes or Marathon that keeps a scheduler up, but doesn't guarantee persistence of fine-grained state. In the event of a failure people have to resubmit their computations, which, in some cases, they may be ok with.

  2. mrocklin commented on May 11, 2017

    @mrocklin
    Member

    To be more clear (I have slightly more time now)

    periodically persist the state of the scheduler for failover?

    Your guess is as good as mine. Don't forget that you'd also have to ensure that workers respected this state at least somewhat on recovery.

    or use a persistent backend instead of memory?

    I don't know of any persistent system that operates fast enough for this

    have standby schedulers (via leader election etc.)?

    Having a standby scheduler isn't hard. Maintaining updates might be hard.

    My previous thought on how to solve this problem was to have everyone re-submit what they know about the state of things if the scheduler goes down and comes up again. Clients resubmit computations, workers check in with what they have. I don't know if this is best though.

    Would love to see work here. I'm personally unlikely to work on this in the near future without serious enticement.

  3. kszucs commented on May 11, 2017

    @kszucs
    ContributorAuthor

    This is a good read: http://mesos.apache.org/documentation/latest/high-availability-framework-guide/

    If I understand correctly the mesos agents (workers in our case) recovers their state to the newly elected master.

    Do workers maintain such state?

  4. mrocklin commented on May 11, 2017

    @mrocklin
    Member
  5. changed the title [-][RFC] Resilience improvements[/-] [+]Resilience[/+] on Sep 2, 2017
  6. pitrou commented on Nov 2, 2017

    @pitrou
    Member

    A possible way to approach this would be to have the scheduler dump its state to workers periodically (perhaps choosing a small number of different workers each time, to reduce the overall load). Then when a new scheduler instance goes up, reconnecting workers can announce they have some saved state of an old scheduler (e.g. tagged with a timestamp and a unique id). If the scheduler recognizes itself, it asks the worker with the most recent timestamp and asks to receive the saved state.

  7. pitrou commented on Nov 2, 2017

    @pitrou
    Member

    @mrocklin do you know how many tasks can the scheduler of a large cluster typically keep track of at any given time?

  8. mrocklin commented on Nov 3, 2017

    @mrocklin
    Member

    A possible way to approach this would be to have the scheduler dump its state to workers periodically (perhaps choosing a small number of different workers each time, to reduce the overall load). Then when a new scheduler instance goes up, reconnecting workers can announce they have some saved state of an old scheduler (e.g. tagged with a timestamp and a unique id). If the scheduler recognizes itself, it asks the worker with the most recent timestamp and asks to receive the saved state.

    How would we handle state created/destroyed in the meantime?

    If clients maintain their submitted task graphs then I think that we have a full copy of the scheduler state already, and with full accuracy and timeliness.

  9. mrocklin commented on Nov 3, 2017

    @mrocklin
    Member

    @mrocklin do you know how many tasks can the scheduler of a large cluster typically keep track of at any given time?

    This varies highly, ranging from hundreds to millions of tasks.

  10. pitrou commented on Nov 3, 2017

    @pitrou
    Member

    How would we handle state created/destroyed in the meantime?

    I was going to say "we don't"... but I was only thinking about created state, not destroyed. If the scheduler doesn't know that some keys were released in the meantime, there's a memory leak :-/

    If clients maintain their submitted task graphs then I think that we have a full copy of the scheduler state already, and with full accuracy and timeliness.

    The clients and workers, I assume? But is it important to keep, say, dependencies or restrictions information for finished tasks (in the "memory" or "erred" state...)? Perhaps an explicit retry functionality would need it, but otherwise?

  11. pitrou commented on Nov 3, 2017

    @pitrou
    Member

    This varies highly, ranging from hundreds to millions of tasks.

    I think in the millions case, the idea of dumping the whole scheduler state somewhere becomes impractical. It sounds plausible that the serialized dump will have from 100 to 1000 bytes per key, so that would mean hundreds of megabytes to ship to a worker (or write to disk on a shared location). Perhaps in common cases it would be smaller (because pickle is quite good at compressing when a given object, e.g. string key, appears a lot of times), but still.

  12. mrocklin commented on Nov 3, 2017

    @mrocklin
    Member

    I was going to say "we don't"... but I was only thinking about created state, not destroyed. If the scheduler doesn't know that some keys were released in the meantime, there's a memory leak :-/

    FWIW I don't have much confidence in the periodic-backup approach. We would also need to keep some sort of short term real-time log, which probably isn't feasible for us for performance reasons (and it'd be a hassle to move it around in case of failure).

  13. martindurant commented on Nov 3, 2017

    @martindurant
    Member

    How about the concept of user-initiated checkpointing? It can then take a while, saving everything to disc in a thread, but happen only rarely.

  14. mrocklin commented on Nov 3, 2017

    @mrocklin
    Member

    There are many sensible approaches. I think that maintaining state on the client is simpler, automatic, and fits nicely with the already existing infrastructure.

  15. Dracio commented on Sep 25, 2018

    @Dracio

    Is there any plans to implement resilience if a scheduler reboots? I was hoping to use dask, but my tasks can range from 1 min to several hours.

    I like this idea:

    If I were to do this myself (which I have no short-term plans of doing) I would instead have all of the workers and clients update a new scheduler with their state when the new scheduler comes online. This would require the clients to keep track of the graphs that they have sent so far. It would also require some non-trivial manipulations of the scheduler state.

  16. mrocklin commented on Sep 25, 2018

    @mrocklin
    Member

    Is there any plans to implement resilience if a scheduler reboots?

    The plan is the same as what is above. No one has implemented this, nor do I think that anyone has any plans to implement this. This could be accelerated if someone volunteers to do this work, or if an institution chooses to fund this work.

    I was hoping to use dask, but my tasks can range from 1 min to several hours.

    Do you expect your scheduler to go down in this period? Schedulers can live indefinitely if nothing else kills them.

  17. Dracio commented on Sep 25, 2018

    @Dracio

    I was planning to run it indefinitely, but when if the scheduler goes down (machine dies), it would be nice for the scheduler to see if the workers are already executing a task, so it does try to send another task.

  18. mrocklin commented on Sep 25, 2018

    @mrocklin
    Member
  19. added a commit that references this issue on Oct 15, 2018
  20. PatrikZhong commented on Mar 2, 2023

    @PatrikZhong

    I’ve been looking to prototype a replicated/highly-available scheduler with a primary scheduler and a few backups. The idea is that the primary continuously replicate its state to the backups so that in case the primary crashes, a backup scheduler can take over without having to restart the computations. My main question is what data structures from the scheduler-side would be needed to be replicated in order for backups to know which executions have happened in the task graph?

    Looking into the source code for the scheduler and the API docs, the scheduler contains the states of all tasks in the “tasks dict”, and a log of all transitions that have happened can be found in the transition log. Are there any other data structures that would be necessary to keep a track of to keep the other schedulers consistent?

  21. fjetter commented on Mar 3, 2023

    @fjetter
    Member

    FWIW I doubt that simply replicating the scheduler state somewhere will be sufficient to ensure you can continue without recomputation unless you have a perfect copy , e.g. without any delays. You'll need some kind of state reconciliation that includes the state of all still-alive workers to account for the state drift and any lost messages while the first scheduler was down.

    Note: Right now, workers are hard wired to shut down in case the scheduler dies. We actually removed the possibilities for workers to reconnect a while ago because we were struggling to correct this state drift properly (even, or particularly, when reconnecting to the same instance). See #6361 Reintroducing the reconnect is very easy iff state drift can be corrected properly.

    My main question is what data structures from the scheduler-side would be needed to be replicated in order for backups to know which executions have happened in the task graph?

    Concretely, you'll likely need everything in the class SchedulerState and additionally even a couple of "extensions" depending what kind of features should survive this (e.g. WorkStealing, P2PShuffling)
    A word of caution: These low level internals are subject to frequent change and stability varies.

  22. PatrikZhong commented on Mar 8, 2023

    @PatrikZhong

    Assuming that we have managed to replicate a consistent state of the scheduler, how can we use it to restart a new scheduler with that state (to take over if the primary scheduler fails)?

    As I understand it, extracting the state from the scheduler can be done by simply interacting with the Scheduler object and extracting its attributes, but giving the scheduler an existing state seems trickier, as there's no obvious entry point in the API or in the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions