Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Finagle Overview
Search
Moses Nakamura
February 19, 2014
Technology
4
1.1k
Finagle Overview
Finagle Overview presented to the NY Scala Meetup
Moses Nakamura
February 19, 2014
Tweet
Share
Other Decks in Technology
See All in Technology
戦略的DDDを実践するための跳躍力 / OOC 2024
pictiny
6
4.3k
OpenTelemetry実践 はじめの一歩
taxin
0
330
10分でわかるfreeeのQA
freee
0
260
社内共通ルールを値オブジェクトにして社内ライブラリとして運用してみた話
leveragestech
2
1.2k
2023 Japan AWS Jr.Championsに選出されての振り返りとこれから
hiropy877
1
130
SREsのためのSRE定着ガイド
netmarkjp
10
1.7k
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
7
100k
関数型DDDの理論と実践:「決定を遅らせる」を先につくり、 ビジネスの機動力と価値をあげる
knih
2
500
データ品質をコード化! LINEヤフーのMLOpsを最適化する "ACP Data Quality" の紹介
lycorptech_jp
PRO
2
290
匠MethodとRDRAとICONIXとDDDで実現する一気通貫オブジェクト指向開発
haru860
4
2.1k
業務で使えるかもしれない…!?GitHub Actions の Tips 集 / CI/CD Test Night #7
ponkio_o
PRO
24
7.3k
期待しすぎずに取り組む両面 TypeScript
shozawa
4
580
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
Gamification - CAS2011
davidbonilla
76
4.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
242
20k
What's new in Ruby 2.0
geeforr
335
31k
Optimizing for Happiness
mojombo
369
69k
Designing for humans not robots
tammielis
247
25k
Thoughts on Productivity
jonyablonski
57
3.8k
jQuery: Nuts, Bolts and Bling
dougneiner
57
7.1k
We Have a Design System, Now What?
morganepeng
42
6.7k
Building Applications with DynamoDB
mza
88
5.6k
Designing the Hi-DPI Web
ddemaree
275
33k
The World Runs on Bad Software
bkeepers
PRO
60
6.6k
Transcript
Finagle
Hello!
Finagle Extensible RPC Implement a feature once => get the
feature in every service => get the feature in every protocol
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] }
Twitter Futures Interrupts Maintain context Scheduler
Finagle Abstractions Service Server Client
Service trait Service[-Req, +Rep] extends (Req => Future[Rep])
Server trait Server[Req, Rep] { def serve( addr: SocketAddress, underlying:
Service[Req, Rep] ): ListeningServer }
Client trait Client[Req, Rep] { def newService( dest: Name, label:
String ): Service[Req, Rep] }
None
Load Balancing Load balances to the least loaded Internally organized
as a heap Implicitly sends more requests to faster servers
Liveness
Failure Accrual After X failures in a row, backoff for
duration Y
Rolling Restart Support If we can’t establish a connection to
a host, blackhole it and try to reestablish in the background “Fail Fast”
Connection Pooling Tunable parameters: Low Watermark High Watermark Idle Timeout
Max Waiters
Stats Collection We collect stats on every request, including histograms
of request latency, success rate etc. See: Metrics, Metrics Everywhere (codahale)
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
None
Pipelining Redis Memcached
Service Discovery trait ListeningServer { def announce(addr: String): Future[Announcement] }
Service Discovery ZK internally Other schemes Adding finagle-serversets to your
classpath enables ZK
Next?!
finagle 6 apis ClientBuilder => Protocol.new Cargo Culting :( Finagle
notoriously hard to configure Zero configuration! Works out of the box.
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()
finagle 6 style Http.newService(name, label)
mux A new protocol, layered on other protocols cf. thrift-mux
mux discard leasing multiplexing error encoding ping drain initialization
error encoding Means you can handle errors separately by just
reading the first byte Easy to imagine dropping errors, or minimizing copies etc
init + ping True liveness No more failfast or failure
accrual
draining Signals that a server will start draining Client knows
to stop sending new requests
multiplexing Pipelining for everyone! Connection pooling mostly disappears
discard No longer care about response Current world: close connection
Biggest cause of connection churn New world: send a discard request
leasing First target: GC avoidance Useful elsewhere too
Finagle Resources twitter.github.io/finagle finaglers@google groups
Work on Finagle github.com/twitter/finagle Docs! Github Issues!
Thanks! twitter: @mnnakamura github: mosesn email:
[email protected]
Work for Twitter! https://twitter.com/jobs We’re hiring! t.co/nymeetup
Questions? https://twitter.com/jobs/engineering t.co/nymeetup email:
[email protected]