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

Netty at Twitter with Finagle

Netty at Twitter with Finagle

A minimal set of slides used to present an overview of Finagle, an RPC library built atop Netty

Evan Meagher

July 29, 2014
Tweet

More Decks by Evan Meagher

Other Decks in Programming

Transcript

  1. @Twitter 2 Agenda Why and what is Finagle? What does

    it do? What are we working on now?
  2. @Twitter 8 Monolithic Rails app MySQL Monolithic Rails app MySQL

    Monolithic Rails app MySQL … Monolithic Rails app MySQL … …
  3. @Twitter 23 val server = new Service[HttpReq, HttpRep] { def

    apply(req: HttpReq): Future[HttpRep] = Future.value(HttpRep(Status.OK, req.body)) } ! Http.serve(":80", server)
  4. @Twitter 24 val client: Service[HttpReq, HttpRep] = Http.newService(“twitter.com:80") ! val

    futureResponse: Future[HttpRep] = client(HttpReq(“/")) ! futureResponse map { response => println(response) }
  5. @Twitter 26 type Service[Req, Rep] = Req => Future[Rep] !

    type Filter[Req, Rep] = (Req, Service[Req, Rep]) => Future[Rep]
  6. @Twitter 27 type Service[Req, Rep] = Req => Future[Rep] !

    type Filter[Req, Rep] = (Req, Service[Req, Rep]) => Future[Rep] Filter Filter Server Client
  7. @Twitter 28 def isAuthed(req: Req): Boolean val authFilter: Filter[HttpReq, HttpRes]

    = { (req, svc) => if (isAuthed(req)) svc(req) else Future.exception(new AccessDenied) } ! val authedServer: Service[HttpReq, HttpRes] = authFilter andThen server
  8. @Twitter 31 Service discovery See the “Names” page on the

    Finagle user guide: http://twitter.github.io/finagle/guide/Names.html ! val client = Http.newService( “zk!myzkhost.mycompany.com:2181!/my/zk/path” )
  9. @Twitter 33 Request multiplexing See the “Protocols” page on the

    Finagle user guide: http://twitter.github.io/finagle/guide/Protocols.html