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

YAPC::Fukuoka lunch session

YAPC::Fukuoka lunch session

YAPC::Fukuoka ランチスポンサーセッション
2017-07-01

Harukasan

July 01, 2017
Tweet

More Decks by Harukasan

Other Decks in Technology

Transcript

  1. ଵଦͰ͋ΔΤϯδχΞͷͨΊͷΫϥ΢υը૾ม׵αʔϏε
    @harukasan / MICHII Shunsuke
    2017-07-01
    :"1$'VLVPLBϥϯνεϙϯαʔηογϣϯ

    View full-size slide

  2. )BSVLBTBOಓҪढ़հ

    ϐΫγϒ ג
    ϦʔυΤϯδχΞ *NBHF'MVYࣄۀ੹೚ऀ

    ෱ԬΦϑΟεͰ͸ͳ͘౦ژຊࣾۈ຿
    ೥෱Ԭݝٱཹถࢢੜ·Ε

    ٱཹถߴઐˠ۝޻େ ൧௩
    ˠஜ೾େӃˠϐΫγϒೖࣾ

    3VCZͱ(Pͱ͢͜͠4DBMBΛॻ͘ΠϯϑϥܥΤϯδχΞ

    ීஈ͸ࣇͷ෕

    View full-size slide

  3. ૑࡞׆ಈ͕΋ͬͱָ͘͠ͳΔ৔ॴΛͭ͘Δ

    View full-size slide

  4. ϥϯνηογϣϯ

    View full-size slide

  5. ϖ
    Image
    ϖ
    Image
    ϖ
    Image
    ϖ
    Image
    ϖ
    Image
    ϖ
    Image

    View full-size slide

  6. ϨΠΞ΢τΛม͍͑ͨ

    ৽͍͠αΠζͷαϜωΠϧ͕΄͍͠
    ৽͍͠σόΠεʹରԠ͍ͨ͠

    ͍··ͰͷαϜωΠϧͩͱখ͍͞
    ͖Ε͍ʹݟ͑ΔΑ͏ʹ͍ͨ͠

    ը࣭Λམͱͣ͞ʹॖখ͍ͨ͠
    දࣔ଎౓Λ͸΍͍ͨ͘͠

    WebPͰ഑৴͍ͨ͠

    View full-size slide

  7. զʑ͸ΤϯδχΞͰ͋ΔͷͰ
    ͜ΕΒͷ໰୊ʹରͯ͋͠Δఔ౓·Ͱ
    ಠྗͰର߅͢Δ͜ͱ͕Ͱ͖Δ

    View full-size slide

  8. ͨͱ͑͹Image::MagickΛ࢖͏
    use Image::Magick;
    $img = Image::Magick->new();
    $img->Read("input.jpg");
    $img->Resize(
    geometry => "400x400",
    );
    ...
    $img->Write("output.jpg");

    View full-size slide

  9. ͨͱ͑͹CSSͰ͏·͍͜ͱ߹ΘͤΔ
    .img {
    background-image: url("input.jpg"); /* style attributeͰࢦఆ͢Δͷ͕Ұൠత */

    background-size: cover;

    background-position: center center;

    width: 400px;

    height: 400px;
    }

    View full-size slide

  10. ͨͱ͑͹ngx_small_lightΛ࢖͏
    server {
    listen 8000;
    server_name localhost;
    small_light on;
    small_light_pattern_define square dw=400,dh=400,da=l,q=95,e=imagemagick,jpeghint=y;
    # http://localhost:8000/small_light(p=square)/input.jpg
    location ~ small_light[^/]*/(.+)$ {
    set $file $1;
    rewrite ^ /$file;
    }
    }

    View full-size slide

  11. දࣔͰ͖ͯΔ͔ΒͱΓ͍͍͚͋͑ͣͲ͜ΕͰਖ਼͍͠ͷʁ
    ImageMagickʹ͸resizeɺscaleͱthumbnail͕͋Δ͚Ͳ
    ͳΜ͔ಛఆͷϒϥ΢βͰݟΔͱ৭͕มΘͬͯݟ͑Δ͚Ͳ
    ࣗ෼͕΍Ίͨޙ୭͕ϝϯςͰ͖ΔΜͩΖ͏……

    View full-size slide

  12. ૿͑ଓ͚͍ͯ͘αʔϏε
    ͢΂ͯͷWebαʔϏε͕
    ը૾ॲཧΛ࣮૷/ӡ༻͢Δඞཁ͕͋Δͷ͔ʁ

    View full-size slide

  13. ੲ͸αʔό΋ύʔπΛങ͍͚ͬͯͭͬͯͨ͘Ͳ……

    View full-size slide

  14. ଵଦͰ͋ΔΤϯδχΞͷͨΊͷΫϥ΢υը૾ม׵αʔϏε

    View full-size slide

  15. HTTP/S3ετϨʔδ
    ը૾ม׵ॲཧ
    ΦϦδφϧը૾Λऔಘ
    ม׵ޙΩϟογϡΛ഑৴
    ΤϯυϢʔβ
    ίϯςϯπΩϟογϡ
    URLΛม͑Δ͚ͩͰը૾ม׵
    https://example.imageflux.jp/w=400,h=400/input.jpg
    ͍··Ͱ࢖͍ͬͯͨ

    ετϨʔδΛͦͷ··࢖͑Δ
    ͭ·Γɺ͍͍ͩͨ

    small light as a service

    View full-size slide

  16. ࣾ಺Ͱར༻͍ͯͨ͠ը૾ม׵γεςϜ͕ϕʔε
    ϐΫγϒ͕UGCը૾ϑΝΠϧͱઓ͖ͬͯͨྺ࢙
    ࣾ಺Ͱ͸௝͍͠B2BαʔϏε
    ͘͞ΒΠϯλʔωοτͱڞಉͰ։ൃɺӡ༻
    ImageMagickΛ࢖͍ͬͯͳ͍

    View full-size slide

  17. LVS

    LB / DSR
    nginx

    HTTP front server
    ഑৴Ϋϥελ
    ؅ཧαʔό
    GRPC
    HTTP API
    Traffic Server

    HTTP front server
    Golang

    Thumbnailing server
    Golang

    Fetching server
    Golang

    Master server
    Scala

    Console / API

    View full-size slide

  18. ͳͥGoͰॻ͍͍ͯΔͷ͔:
    - ܰྔεϨου(goroutine)
    - ඇಉظॲཧΛॎʹॻ͚Δʢωετ͠ͳ͍͍ͯ͘ʣ
    - γϯάϧόΠφϦ
    - CͷίʔυΛݺ΂Δ

    View full-size slide

  19. cgo
    package main
    //
    // int fortytwo()
    // {
    // return 42;
    // }
    //
    import "C"
    import "fmt"
    func main() {
    fmt.Println(int(C.fortytwo()))
    // Output: 42
    }
    ίϝϯτ෦ʹCͷίʔυΛهड़

    View full-size slide

  20. cgo
    ίϝϯτ෦ʹCͷίʔυΛهड़ʢͪΐͬͱ͖΋ͪΘΔ͍ʣ
    Go͔ΒCͷܕΛ࢖͑Δ
    - C.int
    - C.MyFunc

    View full-size slide

  21. net/http
    libjpeg-turbo
    scale
    libpng
    CͷϥΠϒϥϦ
    GoͷHTTPαʔό࣮૷
    GoͱCͷ͍͍ͱ͜ͲΓ

    View full-size slide

  22. ౦ژɺ෱Ԭͷ྆ํʹ։ൃऀ/Ϛωʔδϟ͕͍·͢
    appear.inͰ౦ژ-෱ԬΛ24࣌ؒ઀ଓ
    ͘͞Β౦ژɺϐΫγϒ౦ژɺ͘͞ΒେࡕɺϐΫγϒ෱Ԭ
    ͰςϨΧϯ͢Δָ͍͠৬৔Ͱ͢
    Tokyo
    Osaka
    Fukuoka

    View full-size slide

  23. ImageFluxͰ͸ΤϯδχΞΛืू͍ͯ͠·͢ʂ
    Wantedlyɺฐࣾ࠾༻αΠτɺ΋͘͠͸࠙਌ձͰ
    HTTPϓϩΩγΛॻ͍ͨΓը૾ม׵Λ࠷దԽͨ͠Γ

    ָ͍͠৬৔Ͱ͢
    ౦ژͰ΋෱ԬͰ΋ಇ͚·͢ ϐΫγϒ෱ԬΦϑΟε
    ϐΫγϒ౦ژຊࣾ

    View full-size slide