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
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
950
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
600
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
480
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Speed Design
sergeychernyshev
33
1.9k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
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ͬͨ΄͏͕ૣͦ͏