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

フリマアプリ「メルカリ」の急成長を支えるエンジニアリング

 フリマアプリ「メルカリ」の急成長を支えるエンジニアリング

Tatsuhiko Kubo

October 03, 2015
Tweet

More Decks by Tatsuhiko Kubo

Other Decks in Technology

Transcript

  1. @cubicdaiya / Tatsuhiko Kubo • Software Engineer @ Mercari, Inc.

    • Infrastructure Engineering • Skills • C, Go, Lua, nginx,… • OSS developer • ngx_small_light, ngx_dynamic_upstream, nginx-build, slackboard, cachectl, gaurun, …
  2. php-Parallel-Prefork • prefork server framework for PHP • https://github.com/travail/php-parallel-prefork •

    ඇಉظॲཧʹར༻ • Q4M͔ΒδϣϒΛσΩϡʔɺϚϧνϓϩηεͰฒྻʹॲཧ
  3. TLSλʔϛωʔγϣϯɺSPDYήʔτ΢ΣΠ ɾɾɾ ɾɾɾ "1* "QBDIF NPE@QIQ OHJOY OHJOY HTTPS or

    SPDY HTTP "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ ɾɾɾ ɾɾɾ OHJOY
  4. slackboard • A slack proxy server in Go • https://github.com/cubicdaiya/slackboard

    • ߏ੒ϓϩάϥϜ • slackboardʙSlackϓϩΩγαʔόʙ • slackboard-cliʙΫϥΠΞϯτ for slackboardʙ • slackboard-logʙΫϥΠΞϯτ like cronlogʙ
  5. slackboard-cliͰSlack΁௨஌ $ echo mercari | \ slackboard-cli \ -c tech-test

    \ -s slackboard-server:29800 TMBDLCPBSE POST /notify-directly Slack΁ϙετ
  6. slackboard-logͰSlack΁௨஌ $ ls $ slackboard-log \ -c tech-test \ -s

    slackboard-server:29800 -- ls hoge TMBDLCPBSE POST /notify-directly Slack΁ϙετ
  7. "1* "QBDIF NPE@QIQ ҎલͷσϓϩΠखॱ "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ

    ChatOps with Slack yes EFQMPZCPU rsync rsync rsync
  8. Pros / Cons • Pros • ؆୯Ͱͦͦ͜͜଎͍(appαʔό͸30୆͘Β͍) • Cons •

    ϊϯΤϥʔͰσϓϩΠͰ͖ͳ͍ • Too many 500 errors!!! • ࣌ʑΦϖίʔυΩϟογϡ͕յΕΔʢ࠶ىಈ͕ඞཁʣ
  9. ɾɾɾ ɾɾɾ "1* "QBDIF NPE@QIQ OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY 

    OHY@EZOBNJD@VQTUSFBN HTTPS or SPDY OHJOY  OHY@EZOBNJD@VQTUSFBN HTTP Mercari frontend "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ ɾɾɾ ɾɾɾ
  10. ɾɾɾ ɾɾɾ "1* "QBDIF NPE@QIQ OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY 

    OHY@EZOBNJD@VQTUSFBN HTTPS or SPDY OHJOY  OHY@EZOBNJD@VQTUSFBN HTTP Mercari frontend "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ ɾɾɾ ɾɾɾ
  11. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ
  12. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream
  13. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream
  14. θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack yes EFQMPZCPU OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream down "1* "QBDIF NPE@QIQ
  15. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream
  16. θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack yes EFQMPZCPU OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream up "1* "QBDIF NPE@QIQ
  17. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream
  18. θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack yes EFQMPZCPU OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream down "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ
  19. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream
  20. θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack yes EFQMPZCPU OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream up "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ
  21. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ ※rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream EFQMPZCPU
  22. θϩμ΢ϯλΠϜσϓϩΠ ChatOps with Slack yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream down "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ
  23. "1* "QBDIF NPE@QIQ θϩμ΢ϯλΠϜσϓϩΠ "1* "QBDIF NPE@QIQ ChatOps with Slack

    yes OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN "1* "QBDIF NPE@QIQ rsync ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream EFQMPZCPU
  24. θϩμ΢ϯλΠϜσϓϩΠ ChatOps with Slack yes EFQMPZCPU OHJOY  OHY@EZOBNJD@VQTUSFBN OHJOY

     OHY@EZOBNJD@VQTUSFBN OHJOY  OHY@EZOBNJD@VQTUSFBN ※ rsync ——rsync-path=mercari_app_rsync(↓) #!/bin/sh mercari_app_ctl down # deactivate server on nginx upstream rsync $* # deploy mercari_app_ctl up # activate server on nginx upstream up "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ "1* "QBDIF NPE@QIQ
  25. Gaurun • A general push notification server in Go •

    https://github.com/mercari/gaurun • APNS΍GCM΁ͷϓογϡ௨஌ϦΫΤετΛϓϩΩγ • Q4M+php-Parallel-Preforkͩͱੑೳग़ͳ͔ͬͨͷͰ ϑϧεΫϥονͰॻ͍ͨ • ଞͷδϣϒϫʔΧʔͷҰ෦΋GoͰϦϥΠτத
  26. Mercari\DataTrack • Various purpose logging framework for PHP • αʔόαΠυͰى͜ΔΠϕϯτΛॊೈʹϩΪϯά

    • ϝʔϧɺϓογϡͷૹ৴ • A/Bςετ • Πϕϯτͷܦա • Pascal(ޙड़)ͱૄʹ࿈ܞ
  27. /PSJLSB ϩάσʔλసૹ ఆظతͳΠϕϯτͷऔಘ 3ඵຖ <match access_log> type norikra norikra norikra-server:26571

    target_string access_log </match> <source> type norikra norikra localhost:26571 <fetch> method sweep target target_name tag query_name tag_prefix norikra.query interval 3s </fetch> </source> SQLΛొ࿥ /** * access.log͔ΒHTTPεςʔλείʔυͷׂ߹(1෼ؒ)Λूܭ */ SELECT COUNT(1, status like "5%")/COUNT(1)*100 AS rate_5xx, COUNT(1, status like "4%")/COUNT(1)*100 AS rate_4xx, COUNT(1, status like "3%")/COUNT(1)*100 AS rate_3xx, COUNT(1, status like "2%")/COUNT(1)*100 AS rate_2xx FROM access_log.win:time_batch(1 min) NorikraʹΑΔϩάετϦʔϛϯάॲཧ
  28. PascalʙMercari analysis baseʙ 0QFO3FTUZ 0QFO3FTUZ 0QFO3FTUZ (PPHMF#JH2VFSZ Developer Data Sientist

    Analyze by SQL send events send events send events Powered by cookpad/puree-(ios|android) utilize events transfer utilize events utilize events transfer