Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Finagle Overview

Moses Nakamura
February 19, 2014

Finagle Overview

Finagle Overview presented to the NY Scala Meetup

Moses Nakamura

February 19, 2014
Tweet

Other Decks in Technology

Transcript

  1. Finagle Extensible RPC Implement a feature once => get the

    feature in every service => get the feature in every protocol
  2. Twitter Futures trait Future[+A] { def map[B](fn: A => B):

    Future[B] def flatMap[B](fn: A => Future[B]): Future[B] def rescue[B](fn: PartialFunction[Throwable, Future [B]]): Future[B] def handle[B](fn: PartialFunction[Throwable, B]): Future [B] }
  3. Load Balancing Load balances to the least loaded Internally organized

    as a heap Implicitly sends more requests to faster servers
  4. Rolling Restart Support If we can’t establish a connection to

    a host, blackhole it and try to reestablish in the background “Fail Fast”
  5. Stats Collection We collect stats on every request, including histograms

    of request latency, success rate etc. See: Metrics, Metrics Everywhere (codahale)
  6. Distributed Tracing Hackweek project inspired by Dapper Sample a small

    number of requests Lets you see which upstreams are pummeling your service during an incident Profiling is good for debugging average latency Tracing is good for debugging long tail latency
  7. finagle 6 apis ClientBuilder => Protocol.new Cargo Culting :( Finagle

    notoriously hard to configure Zero configuration! Works out of the box.
  8. old style val client: Service[HttpRequest, HttpResponse] = ClientBuilder() .codec(Http()) .hosts(address)

    .hostConnectionLimit(1) .tcpConnectTimeout(50.milliseconds) .failFast(true) .daemon(true) .retries(3) .trace(ZipkinTracer.mk(host, port) .build()
  9. error encoding Means you can handle errors separately by just

    reading the first byte Easy to imagine dropping errors, or minimizing copies etc
  10. discard No longer care about response Current world: close connection

    Biggest cause of connection churn New world: send a discard request