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

Ugoku Backend

Harukasan
August 02, 2014

Ugoku Backend

Ugoku "It's working" Backend
pixiv Ugoira Tech Talks / 2014-08-01

Harukasan

August 02, 2014
Tweet

More Decks by Harukasan

Other Decks in Technology

Transcript

  1. • Infrastructure Team in pixiv since 2012 • nginx /

    Apache Traffic Server • Fluentd / Kibana / BigQuery • Kosenconf Harukasan / Shunsuke MICHII !  ൃച @harukasan shunsuke.michii
  2. Statistics 7K peak req/s (dynamic) 30K peak req/s (image) 12Gbps

    peak Traffic (image) 3 x 10Gbps backbone 40TB image files 400 servers
  3. Ugoira Data Flow PHP nginx nginx Apache HTTPd nginx pixiv

    Contents Delivery Clusters uploading small light load balancing Store Images generating thumbnails Ý Creator Viewers PHP Redis queing
  4. Ugoira Data Flow PHP nginx nginx Apache HTTPd nginx pixiv

    Contents Delivery Clusters uploading small light load balancing Store Images generating thumbnails Ý Creator Viewers PHP Redis queing
  5. Asynchronous Uploading Upload View Information form View Complete View 1.

    ը૾ϑΝΠϧΛ
 Ξοϓϩʔυ 2. ৘ใೖྗ ◦ ׬ྃΛ଴ͭ Redis Uplaod Worker upload αϜωΠϧϚελը૾ੜ੒ Ý upload Ý GIFը૾෼ׂ active standby 3. Ξοϓϩʔυ׬ྃ
  6. Upload System • Ϣʔβʔ͕৘ใΛೖྗ͍ͯ͠Δؒʹ
 ը૾ϑΝΠϧΛ४උ • GIFը૾Λ෼ׂ Github: pixiv/gifsplit •

    ͏͝ΠϥͰ͸3छྨͷը૾Λ༻ҙ • WebDAVͰΞοϓϩʔυ͢Δ PHP nginx Redis php-resque nginx ϩʔυόϥϯα ΞϓϦέʔγϣϯ Ωϡʔ ϫʔΧʔ DAVετϨʔδ
  7. Ugoira Data Flow PHP nginx nginx Apache HTTPd nginx pixiv

    Contents Delivery Clusters uploading small light load balancing Store Images generating thumbnails Ý Creator Viewers PHP Redis queing
  8. Thumbnail Master • ΞεϖΫτݻఆͱਖ਼ํܗΫϩοϓͷ2छྨ • JPEGը૾ʹม׵(PNG→JPEGͷม׵͸ॏ͍) 1200px 1200px 1200px 1200px

    1200px 1200px ඪ४αΠζ(1200x1200ʹऩ·ΔαΠζ) ਖ਼ํܗΫϩοϓ(ԣ௕ͱॎ௕ͰΫϩοϓํ๏͕ҟͳΔ) ԣ௕͸தԝ߹Θͤ ॎ௕͸্߹Θͤ
  9. Ugoira Data Flow PHP nginx nginx Apache HTTPd nginx pixiv

    Contents Delivery Cluster uploading small light load balancing Store Images generating thumbnails Ý Creator Viewers PHP Redis queing
  10. • εέʔϥϒϧ • ௿஗Ԇ (< 100ms) • ߴ͍ώοτ཰ (> 95%)

    • ઃఆ͕มߋ͠΍͍͢ Storage pixiv Contents Delivery Clusters Contents Delivery Cluster
  11. Inside of pixiv CDC 10Gbps 10Gbps nginx nginx nginx ATS

    ATS ATS nginx nginx nginx Hashing 64GB Memory Caching (60%) 3x 256GB SSD Caching (90%) 1Gbps
  12. CORS Non-Simple Request someone.example.com www.pixiv.net/api var req = new XMLHTTPRequest();

    req.open(“GET”, “//www.pixiv.net/api”); req.setRequestHeader(“Range”, “0-10000”); req.send(); GET /api HTTP/1.1 Origin:someone.example.com Range: 0-10000 ϒϥ΢βͰϒϩοΫ͞ΕΔ
  13. someone.example.com www.pixiv.net/api OPTIONS /api HTTP/1.1 Origin:someone.example.com Access-Control-Request-Headers: range Access-Control-Request-Method: GET

    Preflight request HTTP/1.1 200 OK Access-Control-Allow-Headers: Range Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Origin:* Access-Control-Expose-Headers: Content-Length Access-Control-Max-Age: 2592000 ڐՄ͢ΔϦΫΤετϔομ ڐՄ͢ΔϦΫΤετϝιου ڐՄ͢ΔϦΫΤετݩΦϦδϯ Script͔Βར༻Ͱ͖ΔϨεϙϯεϔομ ΩϟογϡՄೳ࣌ؒ ڐՄΛٻΊΔϦΫΤετϔομ ڐՄΛٻΊΔϦΫΤετϝιου GET /api HTTP/1.1 Origin:someone.example.com Range: 0-10000
  14. Ugoira Data Flow PHP nginx nginx Apache HTTPd nginx pixiv

    Contents Delivery Cluster uploading small light load balancing Store Images generating thumbnails Ý Creator Viewers PHP Redis queing