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

DenoでもBunでもいいから 最速を目指す

Yusuke Wada
September 05, 2022

DenoでもBunでもいいから 最速を目指す

Yusuke Wada a.k.a yusukebe
2022/09/05 Node学園 40時限目

Yusuke Wada

September 05, 2022
Tweet

More Decks by Yusuke Wada

Other Decks in Programming

Transcript

  1. %FOPͰ΋#VOͰ΋͍͍͔Β
    ࠷଎Λ໨ࢦ͢
    :VTVLF8BEBBLBZVTVLFCF
    /PEFֶԂ࣌ݶ໨

    View full-size slide

  2. ࣗݾ঺հ
    w :VTVLF8BEBBLBZVTVLFCF
    w ϘέͯDPGPVOEFS
    w :"1$"TJBϕεττʔΫ৆ड৆
    w גࣜձࣾτϥϕϧϒοΫ

    εʔύʔόΠβʔ
    w UXJUUFSDPNZVTVLFCF
    w HJUIVCDPNZVTVLFCF

    /PEFֶԂॳࢀՃͰ͢

    View full-size slide

  3. )POPͱ͍͏ϑϨʔϜϫʔΫΛ͍ͭͬͯ͘·͢
    w 8FCϑϨʔϜϫʔΫɾϧʔλʔ
    w 8FC4UBOEBSE'FUDIͷ"1*ͷΈΛ࢖༻
    w ϚϧνϓϥοτϑΥʔϜ
    w $MPVE
    fl
    BSF8PSLFSTɺ'BTUMZ$PNQVUF!&EHFɺ%FOPɺ#VO
    w ϛυϧ΢ΣΞͰػೳ௥Ճ
    w 5SJF3PVUFS EFGBVMU
    ͱ3FH&YQ3PVUFSͷͭͷϧʔλʔ͕͋Δ
    IUUQTIPOPKTEFW

    View full-size slide

  4. )POPͷͭͷϧʔλʔ
    w 5SJF3PVUFS
    w 3FH&YQ3PVUFSCZ!VTVBMPNB
    w +4ͷ΢ΣϒϑϨʔϜϫʔΫͰߴ଎ͳϧʔλʔΛ࣮૷͢Δํ๏
    4QFBLFS%FDL
    w IUUQTTQFBLFSEFDLDPNVTVBMPNBVMUSBGBTUKTSPVUFS

    View full-size slide

  5. 6MUSBGBTU
    ͱʹ͔͘଎͍ϑϨʔϜϫʔΫΛ໨ࢦ͍ͯ͠Δ

    View full-size slide

  6. %FOPɺ#VO
    w #VO
    w #VOJTBGBTUBMMJOPOF+BWB4DSJQUSVOUJNF

    IUUQTCVOTI
    w %FOP
    w 0VSHPBMJTUPNBLF%FOPUIFGBTUFTU+BWB4DSJQUSVOUJNF

    IUUQTEFOPDPNCMPHDIBOHFT
    )POP͸ͲͪΒͰ΋ಈ͘ͷͰ
    %FOPͰ΋#VOͰ΋Ͳ͜Ͱಈ͔ͯ͠΋͍͍͔Β
    Ұ൪଎͍ϑϨʔϜϫʔΫΛ໨ࢦͯ͠ΈΑ͏

    View full-size slide

  7. 8FCϑϨʔϜϫʔΫ͕଎͍ͱ͸ʁ

    View full-size slide

  8. ͍͍ͩͨ͜ͷͭΛଌΔ
    w )FMMP8PSME
    w ϧʔςΟϯά
    w 3FRVFTU3FTQPOTFͷॲཧ
    EFMWFEPSSPVUFSCFODINBSL
    4BMUZ"PNCVOIUUQGSBNFXPSLCFODINBSL

    View full-size slide

  9. طଘϕϯνϚʔΫPSΦϦδφϧ
    ͰଌͬͯΈΑ͏
    .BD#PPL1SP.DPSF(#

    View full-size slide

  10. %FOPɺ#VOͷલʹ/PEF΋

    View full-size slide

  11. /PEFϧʔλʔฤ
    w EFMWFEPSSPVUFSCFODINBSL#FODINBSLPGUIFNPTUDPNNPOMZ
    VTFEIUUQSPVUFST

    IUUQTHJUIVCDPNEFMWFEPSSPVUFSCFODINBSL
    w /PEFͷओཁʮϧʔλʔʯͷϕϯνϚʔΫ
    w &YQSFTT
    w LPBSPVUFS
    w LPBUSFFSPVUFS
    w
    fi
    OENZXBZ'BTUJGZͰ࢖ΘΕ͍ͯΔ
    w USFLSPVUFS
    w FUD
    )POPͷݸΛ͋Θͤͯݸͷϧʔλʔ

    View full-size slide

  12. ΍Γํ
    ϧʔςΟϯάఆٛ
    ୟ͖ํ
    ͋͘·ͰϧʔςΟϯά

    3FR3FTͷϋϯυϦϯά͸͠ͳ͍

    View full-size slide

  13. ݁Ռͦͷ
    Ґ
    Ґ

    View full-size slide

  14. ݁Ռ্Ґ
    Ґ
    Ґ
    Ґ

    View full-size slide

  15. )POP
    Ґ
    Ґ
    ˎͪͳΈʹ)POPͷϧʔλʔ͸ෳ਺ͷϋϯυϥʹରԠͤͨ͞Γ
    ϓϥΠΦϦςΟ͕ෳࡶͩͬͨΓ͢Δ

    View full-size slide

  16. ͪͳΈʹ#VOͩͱ

    View full-size slide

  17. )POP3FH&YQ3PVUFS͕উͭ
    #VOͷਖ਼نදݱ͕଎͍
    /PEFΑΓ஗͘ͳͬͯΔͷ͸
    ͳʹ͔ཧ༝͕͋Δͷ͔ͳ͍ͷ͔

    View full-size slide

  18. ͍Α͍Α%FOP

    View full-size slide

  19. %FOP)FMMP8PSMEฤ
    w EFOPTBVSTCFODI📊$PNQBSJOHEFOPOPEF)551
    GSBNFXPSLT

    IUUQTHJUIVCDPNEFOPTBVSTCFODI
    w %FOPɺ/PEFͷϑϨʔϜϫʔΫΛܭଌૉͷ#VO
    w )FMMP8PSMEΛBVUPDBOOPOͰଌΔ
    w (JU)VC"DUJPOTͰ೔ճɺ݁Ռ͕3&"%.&ʹͳΔ

    View full-size slide

  20. ݁Ռ
    ϑϨʔϜϫʔΫͷதͰҰ൪଎͍
    #VOׂ͕ͱ஗͍ʁ

    View full-size slide

  21. +BSSFEొ৔
    IUUQTHJUIVCDPNEFOPTBVSTCFODIJTTVFT

    View full-size slide

  22. BVUPDBOOPO஗͍͔ΒPIB࢖͑
    ࠷ۙ͸#PNCBEJFS͕͓ؾʹೖΓΒ͍͠

    View full-size slide

  23. %FOPϕϯνϚʔΫ
    w ࣮͸)POP͸%FOPެࣜϕϯνϚʔΫͰ࢖ΘΕ͍ͯΔ
    w IUUQTEFOPMBOECFODINBSLT

    View full-size slide

  24. %FOP
    fl
    BTI
    w %FOPΑΓ࣮ݧతʹಋೖ͞Εͨ)551TFSWFS"1*
    YJNQSPWFNFOUDPNQBSFEUPPVSFYJTUJOHXFCTFSWFS

    View full-size slide

  25. w ͔֬ʹ%FOP
    fl
    BTI͸#VOΑΓ଎͍
    w ͨͩ͠ɺ͜͜Ͱ࢖ΘΕ͍ͯΔ#VOͷ
    όʔδϣϯ͸ݹ͍ʢ͸ͣʣ

    View full-size slide

  26. %JWZ͘Μ͕%FOP
    fl
    BTIͷϕϯνʹ)POPΛ࢖ͬͯ͘Εͨ
    HJUIVCDPNEFOPMBOEEFOPQVMM

    View full-size slide

  27. +BSSFEݱΔ
    IUUQTHJUIVCDPNEFOPMBOEEFOPQVMMJTTVFDPNNFOU

    View full-size slide

  28. Ͱ͸#VOฤ΁

    View full-size slide

  29. #VO)551ϑϨʔϜϫʔΫϕϯν
    w 4BMUZ"PNCVOIUUQGSBNFXPSLCFODINBSL$PNQBSFUISPVHIQVU
    CFODINBSLGSPNWBSJPVT#VO)551GSBNFXPSL

    IUUQTHJUIVCDPN4BMUZ"PNCVOIUUQGSBNFXPSLCFODINBSL

    View full-size slide

  30. (FU
    1BSBNT RVFSZIFBEFS 1PTU+40/

    View full-size slide

  31. #VO
    ,JOH8PSME͸΍ͬ
    Ͱ΋1PTU+40/͸ͦΜͳͰ΋ͳ͍ʁ

    View full-size slide

  32. 1PTU+40/
    w BXBJUBTZODΛ࢖͏ͱ,JOH8PSMEͷύϑΥʔϚϯε΋མͪΔ
    w (&5
    ͳͲ͸ಉظత
    w )POP͸ ౰࣌
    શͯͷϋϯυϥͰBXBJU͢Δॲཧ͕ೖ͍ͬͯͨ
    BTZODϋϯυϥͷαϙʔτ
    BXBJU͢Δॲཧ͕શϋϯυϥʹରͯ͠ߦΘΕ͍ͯͨ
    1PTU+40/

    View full-size slide

  33. BXBJUΛ࢖͏ͱ஗͍໰୊
    IUUQTHJUIVCDPNPWFOTICVOJTTVFT

    View full-size slide

  34. +BSSFEొ৔
    IUUQTHJUIVCDPNPWFOTICVOJTTVFTJTTVFDPNNFOU
    5IFSFJTTUJMMNPSFXPSLUPCFEPOF
    UPSFEVDF#VOTQSPNJTFBXBJUPWFSIFBE

    View full-size slide

  35. WͰվળ
    ͨͩ͠
    ˎ5IFNPSFHFOFSBMDBTFPGBTZODBXBJUQFSGPSNBODFCFJOHXPSTFJO+4$UIBO7JTTUJMMBOJTTVF

    View full-size slide

  36. #VODBOBSZ
    ݈ಆͯ͠Δ

    View full-size slide

  37. +BSSFEͷΞυόΠε
    ˎW͕ग़ΔલͰ͕͢ʜ

    View full-size slide

  38. ϋϯυϥ͕Ұͭͷ৔߹͸DPNQPTF͠ͳ͍Α͏ʹͨ͠
    IUUQTHJUIVCDPNIPOPKTIPOPQVMM

    View full-size slide

  39. ABXBJUAΛগͳͨ͘͠
    IUUQTHJUIVCDPNIPOPKTIPOPQVMM

    View full-size slide

  40. #VOWDBOBSZ

    )POP
    "dependencies": {
    "@kapson
    fi
    re/bun-bakery": "^0.3.2",
    "@nbit/bun": "^0.7.0",
    "baojs": "^0.1.3",
    "bunrest": "^1.1.0",
    "colstonjs": "latest",
    "express": "^4.18.1",
    "hyperbun": "^0.4.6",
    "kingworld": "^0.0.0-experimental.24"
    }
    )POP଎͍ͧ

    View full-size slide

  41. ࠷৽൛
    #VOWDBOBSZ
    )POPIUUQTHJUIVCDPNIPOPKTIPOPUSFF
    FCFCDDGEDGCC
    "dependencies": {
    "@kapson
    fi
    re/bun-bakery": "^0.3.2",
    "express": "^4.18.1",
    "fastify": "^4.5.3",
    "hyperbun": "^0.4.6",
    "kingworld": "^0.0.0-experimental.24"
    },

    View full-size slide

  42. ࠷৽ͷ݁Ռ
    IUUQTHJUIVCDPNZVTVLFCFXFCGSBNFXPSLCFODI

    View full-size slide

  43. ͱ͍͏͜ͱͰ%FOPͰ΋#VOͰ΋
    ϑϨʔϜϫʔΫͷதͰ
    ˚Ұ൪଎͍
    ⦿ҰೋΛ૪͏

    View full-size slide

  44. ͍ͬͨΜײ૝
    w ύϑΥʔϚϯεΛͱΔ͔ϝϯςφϏϦςΟΛͱΔ͔ʁ
    w 6MUSBGBTUΛΞΠσϯςΟςΟʹͯ͠ΔͷͰͳΔ΂͘଎͘
    w ػೳ΋͋ΔͷͰ࠷଎͸େม
    w ϕϯνϚʔΫ͸ʮͳ·΋ͷʯ
    w ϕϯνϚʔΫ͸೉͍͠
    w ؀ڥɺϥϯλΠϜͷ࣮૷
    w #VOͷϨεϙϯεϔομʹ͸A%BUFAϔομ͕ͳ͍FUD
    w ఢΛ࡞ΔՄೳੑ͕͋Δ

    View full-size slide

  45. %FOP্ͱ#VO্ͳΒͲͪΒ͕଎͍ͷ͔ʁ
    %FOP
    fl
    BTI଎͍
    #VO΋৽͍͠)POPͩͱ଎͍

    View full-size slide

  46. ࡢ೔ڭ͑ͯ΋ΒͬͨϕϯνϚʔΫαΠτ
    IUUQTEFOPWTCVO
    fl
    ZEFW
    %FOP
    fl
    BTI࢖ͬͯͳ͍

    View full-size slide

  47. #VOͰ͸੩తϑΝΠϧͷαʔϒΛ࠷దԽ͠Α
    ͏ͱ͍ͯ͠Δ

    View full-size slide

  48. #VO͸΋ͬͱ଎͘ͳΔ

    View full-size slide

  49. ͪͳΈʹ%&-&5&͚ͩ3FRVFTUͷத਎
    ͕ۭʹͳΔόά͕͋Δ
    IUUQTHJUIVCDPNPWFOTICVOJTTVFT
    IUUQTHJUIVCDPNIPOPKTIPOPJTTVFT

    View full-size slide

  50. ·ͩ଎͘ͳΔ

    View full-size slide

  51. 63-͕஗͍໰୊

    View full-size slide

  52. ΋͏*TTVFʹͳͬͯͨ
    IUUQTHJUIVCDPNEFOPMBOEEFOPJTTVFT

    View full-size slide

  53. 63-͡Όͳͯ͘
    63-4FBSDI1BSBNT͚ͩͰΑ͘ͳ͍ʁ

    View full-size slide

  54. DSFRRVFSZͷߴ଎Խ
    IUUQTHJUIVCDPNIPOPKTIPOPQVMM

    View full-size slide

  55. Ҏ্ύϑΥʔϚϯε্͕ͬͨ
    IUUQTHJTUHJUIVCDPNZVTVLFCFGFEGEFFDEGE

    View full-size slide

  56. ߴ଎ԽͱϕϯνϚʔΫ͸
    ଓ͍͍ͯ͘ʜ

    View full-size slide