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

Heroku と EC Booster と私 & Heroku ちょこっと Deep Dive

Heroku と EC Booster と私 & Heroku ちょこっと Deep Dive

2018-11-09 フィードフォース社内技術勉強会のプレゼン資料です。
https://developer.feedforce.jp/entry/2018/11/14/140000

Takashi Masuda

November 09, 2018
Tweet

More Decks by Takashi Masuda

Other Decks in Technology

Transcript

  1. ࢲ w ૿ాو࢜ʢ!NBTVUBLBʣ w ੩Ԭݝ඿দࢢग़਎ w ೥݄)FSPLVσϏϡʔ  w ೥݄&$#PPTUFSʹδϣΠ

    ϯɻຊ൪؀ڥ͕)FSPLVͩͬͨ w ೥݄&$#PPTUFSͷ)FSPLV पลΛΠΠײ͡ʹ࢝͠ΊΔ  IUUQTNBTVUBLBOFUDIBMPXIUNM
  2. %ZOPͷมભ XFC  XPSLFS  BE@XPSLFS  4UBOEBSE9  

    4UBOEBSE9 4UBOEBSE9 1FSGPSNBODF. 4UBOEBSE9  ͢΂ͯ̍୆ 4UBOEBSE9
  3. &$#PPTUFSͷ1SPDpMF release: bin/rails db:migrate db:seed # Web app web: bin/rails

    s -p $PORT -e $RAILS_ENV worker: PROCESS_TYPE=worker bundle exec sidekiq -C config/sidekiq.yml # Ad app ad_worker: PROCESS_TYPE=ad_worker bundle exec sidekiq -C config/sidekiq.yml
  4. "EEPOͷมભ )FSPLV 1PTUHSFT   )FSPLV 3FEJT -PHHJOH  .POJUPSJOH

    )PCCZ%FW 1SFNJVN 4UBOEBSE /FX3FMJD )BXLF 1BQFSUSBJM -PH%/"  ϓϥϯ͸ঢ়گʹԠ্ͯ͛͡Լ͛ͨ͠
  5. )FSPLVͷྑ͘ͳ͍ͱ͜Ζ w %ZOPͷछྨ͕গͳ͍ w ྫ4UBOEBSE9 NP ͷͻͱ্͕ͭ1FSGPSNBODF.  NP 

    w গ͠ͷมߋͰྉ͕ۚάοͱ্͕Δ͜ͱ͕͋Δɻ΋͏গ͠બ୒ࢶ͕ ཉ͍͠ w "EEPOͷྉۚઃఆ͕ಠಛ w %ZOPͷॏΈ͕Ճຯ͞ΕΔ͜ͱ͕͋Δʢྫ1SPDFTT4DIFEVMFS "EEPOʣ
  6. ͕࣌ؒ͋Ε͹࣮ԋ $ APP_NAME={app-name} $ LATEST_SLUG_ID=$(heroku releases --json -a $APP_NAME |

    jq -r '.[0].slug.id') $ SLUG_URL=$(curl -n https://api.heroku.com/apps/${APP_NAME}/slugs/${LATEST_SLUG_ID} \ -H "Accept: application/vnd.heroku+json; version=3" | jq -r '.blob.url') $ curl -Lo ${LATEST_SLUG_ID}.tar.gz $SLUG_URL IUUQTEFWDFOUFSIFSPLVDPNBSUJDMFTQMBUGPSNBQJSFGFSFODFTMVHJOGP ˞࠷৽ͷϦϦʔεʹඥ෇͍ͨ4MVHΛμ΢ϯϩʔυ
  7. 4MVHUBSCBMMͷ த਎ app ├── .bundle ├── ʢϦϙδτϦ಺ͷϑΝΠϧʣ └── vendor ├──

    bundle │ └ʢলུʣ └── ruby-2.4.4 └── bin ├── erb ├── gem ├── irb ├── rake ├── rdoc ├── ri ├── ruby └── ruby.exe -> ruby IFSPLVSVCZCVJMEQBDL Λ࢖͍ͬͯΔ৔߹ɺ SVCZͦͷ΋ͷ΍WFOEPS CVOEMFͳͲ΋ؚ·Εͯ ͍Δɻ
  8. ੍ݶ͸͍Ζ͍Ζ͋Δ w 4MVHαΠζ͸$PNQJMFͯ͠.J#·ͰʢѹॖαΠζʣ w ʹ.J#͔Β.J#ʹ্͕ͬͨ w ʹ.J#͔Β.J#ʹ্͕ͬͨ w 4MVH$PNQJMF࣌ؒ͸෼·Ͱ w

    ϢʔβʹΑΔΞϓϦ΁ͷHJUૢ࡞͸࣌ؒʹճ·Ͱ w ϦϙδτϦαΠζ͸ඇѹॖͰ(#·Ͱ w ͦͷଞ IUUQTEFWDFOUFSIFSPLVDPNBSUJDMFTMJNJUT
  9. IFSPLVSFQPQMVHJOΛ࢖͏ $ heroku plugins:install heroku-repo $ heroku repo:gc -a {app-name}

    $ heroku repo:purge_cache -a {app-name} $ git commit --allow-empty -m 'Decrease slug size' $ git push heroku master IUUQTHJUIVCDPNIFSPLVIFSPLVSFQP
  10. ࢀߟWFOEPSIFSPLVͷத਎ vendor └── heroku ├── buildpack_ruby_version (ruby-2.4.4) ├── buildpack_version (v196)

    ├── bundler_version (1.15.2) ├── ruby_version (ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux]) ├── rubygems_version (2.6.14.1) ├── secret_key_base ([SECRET]) └── stack (heroku-16) ˞IFSPLVSVCZCVJMEQBDLΛ࢖͍ͬͯΔ৔߹ɻ ׅހ಺͸ϑΝΠϧͷத਎
  11. ࢀߟCVJMENFUBEBUB"1*ͷ ϨεϙϯεʢQSJWBUF"1* ʣ $ curl -n https://api.heroku.com/apps/github-organization-watcher/build-metadata \ -H "Accept:

    application/vnd.heroku+json; version=3.build-metadata" { "app":{ "id":"<UUID>", "name":"github-organization-watcher" }, "cache_delete_url":"<CACHE_URL>", "cache_get_url":"<CACHE_URL>", "cache_put_url":"<CACHE_URL>", "repo_delete_url":"<REPO_URL>", "repo_get_url":"<REPO_URL>", "repo_put_url":"<REPO_URL>" } # <CACHE_URL> # https://s3-external-1.amazonaws.com/heroku_repos/heroku.com/cache/<NUMBERS>.tgz? AWSAccessKeyId=<SECRET>&Signature=<SECRET>&Expires=<NUMBERS> # <REPO_URL> # https://s3-external-1.amazonaws.com/heroku_repos/heroku.com/<NUMBERS>.tgz? AWSAccessKeyId=<SECRET>&Signature=<SECRET>&Expires=<NUMBERS>
  12. ৘ใऩू w IUUQTEFWDFOUFSIFSPLVDPNDBUFHPSJFTIFSPLVBSDIJUFDUVSF w Ұ࣍৘ใɻॆ࣮͓ͯ͠ΓಡΈ΍͍͢ w IUUQTCMPHIFSPLVDPN IUUQTEFWDFOUFSIFSPLVDPNDIBOHFMPH w )FSPLVͷ࠷৽৘ใ

    w IUUQCIBUFOBOFKQTFBSDIUBH R)FSPLVTBGFPOTPSUSFDFOUVTFST w ΧδϡΞϧͳ৘ใ w )FSPLV+14MBDL6TFS(SPVQ w ࠷ۙ4JHO6Qͨ͠