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

最速のASGIサーバを探して

Junya Fukuda
October 17, 2020
150

 最速のASGIサーバを探して

はんなりPython LT
Unagi.py / Python 駿河 LT
の資料です。

Junya Fukuda

October 17, 2020
Tweet

More Decks by Junya Fukuda

Transcript

  1. ݱঢ়쎅1ZUIPO쎅ੑೳଌఆ Go΋ૣ͍͚Ͳɺnode΋Pythonͷjapronto΋ΉͬͪΌૣ͍ python(japronto) v.s. nodejs v.s. golang Ͱ ൺֱͨ࣌͠ ͜ͷ3ͭ͸

    ͔ͳΓ͍͍উෛΛ͍ͯ͠·͢Ͷɻ japronto͕͜Μ͚ͩૣ͍ཧ༝͸த਎͸ ΄΅C/C++Ͱ ༷ʑͳ ࠷దԽΛ͔͚͍ͯΔͨΊͰ͢ɻ https://qiita.com/tkngue/items/62101788c0f384a5b12e
  2. ݱঢ়쎅1ZUIPO쎅ੑೳଌఆ Go΋ૣ͍͚Ͳɺnode΋Pythonͷjapronto΋ΉͬͪΌૣ͍ python(japronto) v.s. nodejs v.s. golang Ͱ ൺֱͨ࣌͠ ͜ͷ3ͭ͸

    ͔ͳΓ͍͍উෛΛ͍ͯ͠·͢Ͷɻ japronto͕͜Μ͚ͩૣ͍ཧ༝͸த਎͸ ΄΅C/C++Ͱ ༷ʑͳ ࠷దԽΛ͔͚͍ͯΔͨΊͰ͢ɻ https://qiita.com/tkngue/items/62101788c0f384a5b12e
  3. ҎԼ3ͭ৚݅ •ΫϥΠΞϯτಉ࣌઀ଓ 10, ϦΫΤετ਺ 100 •ΫϥΠΞϯτಉ࣌઀ଓ 50, ϦΫΤετ਺ 5000 •ΫϥΠΞϯτಉ࣌઀ଓ

    100, ϦΫΤετ਺ 10000 ࢦඪ •ॲཧͷऴྃ·Ͱʹ͔͔ͬͨ࣌ؒ •1ඵ͋ͨΓͷॲཧͨ͠ϦΫΤετ਺ 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ
  4. ҎԼ3ͭ৚݅ •ΫϥΠΞϯτಉ࣌઀ଓ 10, ϦΫΤετ਺ 100 •ΫϥΠΞϯτಉ࣌઀ଓ 50, ϦΫΤετ਺ 5000 •ΫϥΠΞϯτಉ࣌઀ଓ

    100, ϦΫΤετ਺ 10000 ࢦඪ •ॲཧͷऴྃ·Ͱʹ͔͔ͬͨ࣌ؒ •1ඵ͋ͨΓͷॲཧͨ͠ϦΫΤετ਺ → ૣ͍ͱྑ͍ → ଟ͍ͱྑ͍ 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ
  5. ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌઀ଓ 10, ϦΫΤετ਺ 100    

     ϦΫΤετ [s] 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ     
  6.          

    ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌઀ଓ 10, ϦΫΤετ਺ 100 ϦΫΤετ [s] Uvicorn Hypercorn 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ Uvicorn Hypercorn
  7.      •ΫϥΠΞϯτಉ࣌઀ଓ 50, ϦΫΤετ਺ 5000 

        ऴྃ࣌ؒ [s] ϦΫΤετ [s] 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ Uvicorn Hypercorn Uvicorn Hypercorn
  8. 6WJDPSO썿)ZQFSDPSO썾ੑೳൺֱ      •ΫϥΠΞϯτಉ࣌઀ଓ 100, ϦΫΤετ਺ 10000

         ऴྃ࣌ؒ [s] ϦΫΤετ [s] Uvicorn Hypercorn Uvicorn Hypercorn
  9. 6WDPSO쎅ಛ௃ •Uvicorn ͸ ܰྔ •Uvicorn ͸ uvloop ͱ͍͏ asyncio ͷߴ଎Խπʔϧ͕ೖ͍ͬͯΔ

    •Hypercorn Ͱ΋ uvloop Λ࢖͏͜ͱ͕Ͱ͖Δʂʂʂ IUUQTQHKPOFTHJUMBCJPIZQFSDPSO
  10. )ZQFSDPSO썾VWMPPQ쎩࢖썝쎂쎆 import asyncio import uvloop from hypercorn.asyncio import serve from

    hypercorn.config import Config import main_fastapi as faster config = Config() config.bind = ["localhost:8080"] asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(serve(faster.app, config)) IUUQTQHKPOFTHJUMBCJPIZQFSDPSOIPX@UP@HVJEFTBQJ@VTBHFIUNM
  11. )ZQFSDPSO썾VWMPPQ쎩࢖썝쎂쎆 import asyncio import uvloop from hypercorn.asyncio import serve from

    hypercorn.config import Config import main_fastapi as faster config = Config() config.bind = ["localhost:8080"] asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(serve(faster.app, config)) IUUQTQHKPOFTHJUMBCJPIZQFSDPSOIPX@UP@HVJEFTBQJ@VTBHFIUNM
  12.          

    ऴྃ࣌ؒ [s] •ΫϥΠΞϯτಉ࣌઀ଓ 10, ϦΫΤετ਺ 100 ϦΫΤετ [s] Uvicorn Hypercorn Uvicorn Hypercorn 6WJDPSO썿)ZQFSDPSO VWMPPQ썙쎡 썾ੑೳൺֱ
  13.          

    •ΫϥΠΞϯτಉ࣌઀ଓ 50, ϦΫΤετ਺ 5000 ऴྃ࣌ؒ [s] ϦΫΤετ [s] Uvicorn Hypercorn Uvicorn Hypercorn 6WJDPSO썿)ZQFSDPSO VWMPPQ썙쎡 썾ੑೳൺֱ
  14.          

    •ΫϥΠΞϯτಉ࣌઀ଓ 100, ϦΫΤετ਺ 10000 ऴྃ࣌ؒ [s] ϦΫΤετ [s] Uvicorn Hypercorn Uvicorn Hypercorn 6WJDPSO썿)ZQFSDPSO VWMPPQ썙쎡 썾ੑೳൺֱ
  15.          

    •ΫϥΠΞϯτಉ࣌઀ଓ 100, ϦΫΤετ਺ 10000 ऴྃ࣌ؒ [s] ϦΫΤετ [s] 6WJDPSO썿)ZQFSDPSO VWMPPQ썙쎡 썾ੑೳൺֱ Uvicorn Hypercorn Uvicorn Hypercorn Hypercorn - uvloop Hypercorn - uvloop