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

High Performance Backend For Mercari

High Performance Backend For Mercari

Tatsuhiko Kubo

March 21, 2015
Tweet

More Decks by Tatsuhiko Kubo

Other Decks in Technology

Transcript

  1. Agenda • High performance API server with PHP!!! • High

    performance networking with nginx • High performance Application with Go
  2. Agenda • High performance API server with PHP!!! • High

    performance networking with nginx • High performance Application with Go
  3. Why API server very fast? • ܰྔͰߴ଎ͳPHPϑϨʔϜϫʔΫ(DietCake) • Ωϟογϡ •

    ඇಉظॲཧ • ۚͷ஄ؙMySQL on ioDrive • ͦ΋ͦ΋Ϩεϙϯε͕JSON onlyͳͷͰ͍ܰ
  4. Ωϟογϡͷ΢ΥʔϜΞοϓ • ΞΫηε͕ଟ͍ & ߋ৽ස౓͕ߴ͍ & Ωϟογϡͷύλʔϯ͕ଟ͍ & ݁ߏॏ͍API •

    Ϣʔβ͔ΒͷΞΫηεͷࡍʹΩϟογϡΛੜ੒ͯ͠ ΋ޮՌ͕ബ͍ • ཪͰͻͨ͢ΒΩϟογϡΛੜ੒͢ΔσʔϞϯΛಈ͔͢ • ޙड़
  5. Agenda • High performance API server with PHP!!! • High

    performance networking with nginx • High performance Application with Go
  6. Agenda • High performance API server with PHP!!! • High

    performance networking with nginx • High performance Application with Go
  7. Gaurun HTTP API "1* ղઆ 1045QVTI ϓογϡ௨஌ϦΫΤετड෇ (&5TUBUHP (PϥϯλΠϜͷ׆ಈঢ়گΛऔಘ (&5TUBUBQQ

    ಺෦Ωϡʔ νϟωϧ ͷ࢖༻ྔ΍ ϓογϡͷ੒ޭࣦഊ਺ͷऔಘ (&5DPOpHBQQ αʔόઃఆ 50.- Λऔಘ
  8. GET /stat/go $ curl -s http://127.0.0.1:1056/stat/go { "time": 1423270089195474419, "go_version":

    "go1.4", "go_os": "linux", "go_arch": "amd64", "cpu_num": 24, "goroutine_num": 55, "gomaxprocs": 24, "cgo_call_num": 124016, "memory_alloc": 10309424, "memory_total_alloc": 295474683712, "memory_sys": 25557240, "memory_lookups": 214058, "memory_mallocs": 2118264299, "memory_frees": 2118230111, ɾ ɾ
  9. GET /stat/app $ curl -s http://127.0.0.1:1056/stat/app { "queue_max": 40960, //

    ಺෦ΩϡʔͷαΠζ "queue_usage": 0, // ಺෦Ωϡʔͷ࢖༻ྔ(͙͢ࡹ͚ΔͷͰେମ0) "ios": { "push_success": 31804, // iOSϓογϡ௨஌ͷ੒ޭ਺ "push_error": 17 // iOSϓογϡ௨஌ͷࣦഊ਺ }, "android": { "push_success": 18683, // Androidϓογϡ௨஌ͷ੒ޭ਺ "push_error": 233 // Androidϓογϡ௨஌ͷࣦഊ਺ } $
  10. ݩͷRubyίʔυ Parallel.map(params_list, :in_processes => in_processes) do |params| (தུ) res =

    http_request('GET', url, params) (தུ) end.compact params_listͷαΠζ͕େ͖͍ ↓ େྔʹfork͢ΔͷͰॏ͍
  11. GoͰॻ͖௚ͨ͠ done := make(chan error) size := len(paramCombs.Params) var errors

    []error for i := 0; i < size; i++ { go makeCache(URL, paramCombs.Params[i], done) } for i := 0; i < size; i++ { err := <-done if err != nil { errors = append(errors, err) } }