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

FASTER! FASTER!! FASTER!!! -accelerate pipeline-

Ryoma Kai
February 27, 2019

FASTER! FASTER!! FASTER!!! -accelerate pipeline-

20190227 - @Quoine Concourse CI/CD Meetup Tokyo #8 !

Ryoma Kai

February 27, 2019
Tweet

More Decks by Ryoma Kai

Other Decks in Programming

Transcript

  1. FOR EXAMPLE... ➤ npm test & audit & upload coverage

    file jobs: - name: gotcha plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json
  2. SIMPLE, BUT... ➤ 2m... (in my company's environment) jobs: -

    name: gotcha plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json
  3. #1: AGGREGATE ➤ task:unit-test-and-audit executes it in circuit jobs: -

    name: gotcha plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json
  4. DIVIDE, DIVIDE, DIVIDE.... ➤ example plan: - get: repo -

    task: prepare ... run: dir: repo path: /bin/sh args: - -c - | npm install - aggregate: - task: unit-test ... run: dir: repo path: /bin/sh args: - -c - | npm test - task: audit ... run: dir: repo path: /bin/sh args: - -c - | npm audit - do: - task: make-coverage ... run: dir: repo path: /bin/sh args: - -c - | npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json Parallel execution! circuit
  5. USE AGGREGATE IN 1ST ACTION! ➤ "aggregate" block is the

    best solution in acceleration! ➤ quite and quick effective ➤ customizable on your pipeline ⚒
  6. #4: USE CACHES: BLOCK ➤ npm install executes over the

    internet... jobs: - name: gotcha plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json install every time...
  7. #2: STORE CACHES! ➤ use 1st time's cache in 2nd~

    times! jobs: - name: gotcha plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo ɹɹɹɹɹɹcaches: - path: repo/node_modules outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json store caches in next time job
  8. #3: USE FAST PACKAGE MANAGER ➤ Node.js: ➤ npm →

    yarn ➤ PHP: ➤ use local composer repository (packagist.jp) ➤ prestissimo (parallel downloader) ➤ FYI: ޫ஗͍໰୊Λࠀ෰ͯ͠composerΛ10ഒ଎ͨ͘͠࿩ - Mercari Engineering Blog > time npm install npm WARN [email protected] No description ... npm install 2.51s user 0.35s system 116% cpu 2.449 total > time yarn install yarn install v1.13.0 ... ✨ Done in 0.21s. yarn install 0.49s user 0.10s system 122% cpu 0.476 total
  9. #4: CHANGE TO LIGHT DOCKER IMAGE jobs: - name: gotcha

    plan: - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10 inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json official tag : FROM buildpack-deps
 (debian) > docker images | grep node node 10 8fc2110c6978 3 weeks ago 897MB node 10-alpine fe6ff768f798 3 weeks ago 70.7MB
  10. #4: USE ALPINE! ➤ SIZE jobs: - name: gotcha plan:

    - get: repo - task: unit-test-and-audit config: platform: linux image_resource: type: docker-image source: repository: node tag: 10-alpine inputs: - name: repo outputs: - name: out run: dir: repo path: /bin/sh args: - -c - | npm install npm test npm run-script make-coverage npm audit cd .. mv repo/coverage/coverage-final.json out/`basename \`pwd\``.json - put: minio params: file: out/*.json change to -alpine image! > docker images | grep node node 10 8fc2110c6978 3 weeks ago 897MB node 10-alpine fe6ff768f798 3 weeks ago 70.7MB
  11. YOU MIGHT BE CAREFUL... ➤ If you run apps in

    CF(or another Image), 
 it's better to run CI in same env. ➤ node-gyp's build was often broken in another env... ➤ Java is not pb!? ➤ Trade-off between CI speed and CI reliability ➤ Image Caches is active in 2nd time!!
  12. IF YOUR PIPELINE IS SLOW... ➤ 1: use "aggregate:" ➤

    2: use "caches:" ➤ 3: use more faster package manager(plugin) ➤ 4: use light Docker Image
  13. PR