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
fastifyはいいぞ
Search
ykmikan
February 27, 2018
2.1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
fastifyはいいぞ
ykmikan
February 27, 2018
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Documentation Writing (for coders)
carmenintech
77
5.4k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
650
My Coaching Mixtape
mlcsv
0
170
For a Future-Friendly Web
brad_frost
183
10k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Ethics towards AI in product and experience design
skipperchong
2
330
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Chasing Engaging Ingredients in Design
codingconduct
0
230
Transcript
Fastify ͍͍ͧ
ࣗݾհ ❖ ykmikan ❖ airClosetॴଐ ❖ angularͱ͔nodeΛͬͯࣾγεςϜ࡞ͬͯ·͢
Fastifyͬͯ·͔͢ʁ
fastify ❖ pinoͷ࡞ऀ͕࡞ͬͨ web framework ❖ Φʔόʔϔου͕খ͍͞ ❖ inspired by
hapi, express ❖ expressRestifyޓͷϛυ ϧΣΞΛαϙʔτ ❖ validationͱserialize͕͋Δ ❖ ࠷ۙ v1.0ͷrc൛͕ग़ͨ
fastify
ɹॻ͖ํ expressͬΆ͍ router ॲཧ෦
validation & serialization ❖ ajv The fastest JSON Schema
validator for Node.js and browser. Supports draft-04/06/07. jsͰ͔͚Δ!! swaggerΑΓॻ͖͍͢!!
for swagger ui ❖ fastify-swagger ❖ doc generator ❖ swagger-tools
❖ swagger ui ग़ͭ͢
None
ॻ͖͍͢ʂʂ طଘͷϓϥάΠϯͱ͔͑Δ͠!! ྑ͛͞!!
ଌͬͯΈΑ͏ʂʂ
Express vs Koa vs Fastify ❖ ࡞ͨ͠API ❖ apiͷpath /api/sample/hello
❖ Query string ❖ userName, greeting ❖ Response ❖ Message: `${userName}, ${greeting}`
Express vs Koa vs Fastify ❖ ࣮ߦڥ ❖ node: v8.3.0
❖ mac book pro i7, 16GB ❖ ࣮ߦίϚϯυ autocannon -c 100 -d 40 -p 10 “http://localhost:3011/api/sample/hello?userName=test&greeting=hello" Framework Version Router Version Express v4.16.2 Default - Koa v2.5.0 Koa-router v7.4.0 Fastify v1.0.0-rc2 Default (find-my-way) v1.10.1
ଌఆ݁Ռ express koa fastify Latency 8.38 ms 8.26 ms 5.18
ms Req/Sec 11758.25 11978.85 18954.41 Bytes/Sec 2.8 MB 2.8 MB 2.96 MB ❖ autocannon -c 100 -d 40 -p 10 “http://localhost:3011/api/sample/hello? userName=test&greeting=hello"
Ͳ͏ͬͯૣͨ͘͠Μʁ
fast-json-stringify ❖ validationserializeͰ༻͍ͯ͠ΔajvͰ༻ ❖ طଘͷͷͱൺͯ2 ~ 4ഒૣ͍ ❖ ಛʹϖΠϩʔυ͕খ͚͞Εখ͍͞΄Ͳ͕ࠩେ͖͍
find-my-way ❖ طଘͷϧʔςΟϯάͱൺͯ10ഒૣ͍ ❖ radix tree(ύτϦγΞ)ΛͬͯߴԽ
·ͱΊ ❖ طଘͷwebϑϨʔϜϫʔΫͱൺͯૣ͍ ❖ validationserialize͕jsͰॻ͚͍͍ͯ ❖ json-stringify͏ͳΒɺfast-json-stringifyͬͨ΄͏͕ૣͦ͏