Hans Fugal

Futures-based concurrency at Facebook was inspired by a Finagle, at Scala RPC project from Twitter. Futures are a value that will become determined in the future. You can construct these values, and then selectively block one to wait until the value is available. Once it’s available you can continue the computation.

One interesting thing about this futures library is that you can assign each individual future to run in whatever scheduler you like. These schedulers are called Executors, and expose a simple interface to add a unit of work to a queue. Implementations are free to schedule and execute that work as they wish, either on OS threads, green threads, or whatnot. So you can do things like this:

  .then(executor1, future1)
  .then(executor2, future2)

And future1 will be scheduled and executed with executor1 and future2 will be scheduled and executoed on executor2.

Question: Which schedulers do developers use in practice?
Answer: There are a few in use, but for the most part picking a scheduler tailored for CPU-heavy workloads or one tailored for IO-heavy workloads is enough choice to cover most use-cases.

Question: Can you do cluster scheduling with this?
Answer: It’s limited to a scheduling on a single box.