マイクロサービスを利用する側のパフォーマンス向上策 (PyCon JP 2016)

Click here to load reader

  • date post

    06-Jan-2017
  • Category

    Software

  • view

    702
  • download

    0

Embed Size (px)

Transcript of マイクロサービスを利用する側のパフォーマンス向上策 (PyCon JP 2016)

  • https://www.monotaro.com/

  • https://www.monotaro.com/ 2

  • https://www.monotaro.com/ 3

  • https://www.monotaro.com/ 4

  • https://www.monotaro.com/ 5

  • https://www.monotaro.com/ 6

  • https://www.monotaro.com/

    7

  • https://www.monotaro.com/

    8

  • https://www.monotaro.com/ 9

    MonotaRO http://www.slideshare.net/monotaro-itd-pr/monotaro-20150320-devlove

    http://www.slideshare.net/monotaro-itd-pr/monotaro-20150320-devlove

  • https://www.monotaro.com/ 10

  • https://www.monotaro.com/ 11

  • https://www.monotaro.com/ 12

  • https://www.monotaro.com/ 13

  • https://www.monotaro.com/ 14

    12 API

  • https://www.monotaro.com/ 15

  • https://www.monotaro.com/ 16

    APIAPIAPI API

    AP Server

  • https://www.monotaro.com/ 17

    APIAPIAPI API

    AP Server

  • https://www.monotaro.com/ 18

  • https://www.monotaro.com/ 19

  • https://www.monotaro.com/ 20

  • https://www.monotaro.com/ 21

  • https://www.monotaro.com/ 22

    Ordered by: cumulative time

    ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 3.330 3.330 run_web.py:134(application) 1 0.000 0.000 3.330 3.330 () 1 0.000 0.000 3.249 3.249 () 1 0.000 0.000 3.180 3.180 () 1 0.000 0.000 3.180 3.180 () 19 0.000 0.000 2.991 0.157 () 19 0.000 0.000 2.920 0.154 () 10 0.000 0.000 2.865 0.286 () 7591 2.784 0.000 2.784 0.000 {method 'recv' of '_socket.socket' objects} 19 0.000 0.000 2.275 0.120 lib\urllib2.py:122(urlopen) 19 0.000 0.000 2.275 0.120 lib\urllib2.py:373(open) 19 0.000 0.000 2.274 0.120 lib\urllib2.py:401(_open) ()

  • https://www.monotaro.com/ 23

  • https://www.monotaro.com/ 24

    Boost application performance using asynchronous I/O http://www.ibm.com/developerworks/library/l-async/

  • https://www.monotaro.com/ 25

    Boost application performance using asynchronous I/O http://www.ibm.com/developerworks/library/l-async/

  • https://www.monotaro.com/ 26

    http://www.gevent.org/

  • https://www.monotaro.com/ 27

  • https://www.monotaro.com/ 28

    # # from gevent import monkeymonkey.patch_all()

    # urllib2IO import urllib2 import gevent

  • https://www.monotaro.com/ 29

    def get_json(self, url, params): response = urllib2.urlopen(url).read() return json.loads(response)

    # (urlopen) result = self.get_json(any_url, any_params)

  • https://www.monotaro.com/ 30

    def get_json(self, url, params): response = urllib2.urlopen(url).read() return json.loads(response)

    # get_json future = gevent.spawn(self.get_json, any_url, any_params) ()

    # future.get() result = future.get()

  • https://www.monotaro.com/ 31

    future1 = gevent.spawn(self.get_json, url1, param1) future2 = gevent.spawn(self.get_json, url2, param2) future3 = gevent.spawn(self.get_json, url3, param3) future4 = gevent.spawn(self.get_json, url4, param4) future5 = gevent.spawn(self.get_json, url5, param5)

  • https://www.monotaro.com/ 32

    from gevent.lock import Semaphore

    # 50 semaphore = Semaphore(50)

    def get_json(self, url, params): # 50 with semaphore: response = urllib2.urlopen(url).read() return json.loads(response)

  • https://www.monotaro.com/ 33

    from gevent.pywsgi import WSGIServer

    http_server = WSGIServer(('', 5000), app)http_server.serve_forever()

  • https://www.monotaro.com/ 34

    gevent.spawn

  • https://www.monotaro.com/ 35

    APIAPIAPI API

    AP Server

  • https://www.monotaro.com/

    API

    [ms]

  • https://www.monotaro.com/ 37

    APIAPIAPI API

    AP Server

  • https://www.monotaro.com/ 38

  • https://www.monotaro.com/

    APIAPIAPI API

    AP Server

    39

    https://pypi.python.org/pypi/python-memcached/1.58

  • https://www.monotaro.com/

    40

    APIAPIAPI API

    AP Server

  • https://www.monotaro.com/ 41

  • https://www.monotaro.com/ 42

  • https://www.monotaro.com/ 43

  • https://www.monotaro.com/ 44

  • https://www.monotaro.com/ 45

  • https://www.monotaro.com/ 46

  • https://www.monotaro.com/ 47