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
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Typedesign – Prime Four
hannesfritz
42
3.1k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Navigating Weather and Climate Data
rabernat
0
220
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
A Tale of Four Properties
chriscoyier
163
24k
Scaling GitHub
holman
464
140k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
610
The World Runs on Bad Software
bkeepers
PRO
72
12k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
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ͬͨ΄͏͕ૣͦ͏