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

Microservices deployment patterns

Microservices deployment patterns

A balancing act between cost, complexity, elasticity and availability

Abhishek Tiwari

June 22, 2016
Tweet

More Decks by Abhishek Tiwari

Other Decks in Technology

Transcript

  1. THINGS TO CONSIDER !5GTXKEG&KUEQXGT[ "'ZVGTPCNXU+PVGTPCN "5GTXGTUKFGXUENKGPVUKFG !.QCF$CNCPEKPI "'ZVGTPCN '.$ XU+PVGTPCN

    +.$ "5GTXGTUKFGXUENKGPVUKFG !5ECNCDKNKV[ "5GTXKEGUECNCDKNKV[XUENWUVGTUECNCDKNKV[ "5VCVGNGUUXUUVCVGHWN !%QPVCKPGT%NWUVGTU
  2. EXAMPLE MICROSERVICES LANDSCAPE Web " Mobile # 2TQFWEV#2+UX %CTV#2+UX 1TFGT#2+UX

    (WNHKNOGPV#2+UX API Gateway .CVGUV8GTUKQP 2TQFWEV#2+UX %CTV#2+UX 1TFGT#2+UX (WNHKNOGPV#2+UX 2TQFWEV#2+UX 1TFGT#2+UX 1TFGT#2+UX (WNHKNOGPV#2+UX 1NFGT8GTUKQPU
  3. EXAMPLE MICROSERVICES LANDSCAPE Web " Mobile # 2TQFWEV#2+UX %CTV#2+UX 1TFGT#2+UX

    (WNHKNOGPV#2+UX API Gateway .CVGUV8GTUKQP 2TQFWEV#2+UX %CTV#2+UX 1TFGT#2+UX (WNHKNOGPV#2+UX 2TQFWEV#2+UX 1TFGT#2+UX 1TFGT#2+UX (WNHKNOGPV#2+UX /KETQUGTXKEGU 8GTUKQPU 'PXKTQPOGPVU &GX7#6.KXG 1NFGT8GTUKQPU
  4. ONE MICROSERVICE PER VM/SERVER OS Service Hypervisor OS OS Service

    Service VM VM Abhishek Tiwari http://abhishek-tiwari.com ! @abhishektiwari
  5. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) API Gateway '.$

    #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X '.$ '.$ '.$
  6. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) API Gateway '.$

    #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X #< X '.$ '.$ '.$ *KIJN[CXCKNCDNG/WNVK#<FGRNQ[OGPVYKVJNQCFDCNCPEGT '.$
  7. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) #95JQUVKPIEQUVRGTOKETQUGTXKEGłRGTOQPVJ 5GTXKEG .KXG

    łWVKNKUGF 5GTXKEG .KXG łWVKNKUGF 5GTXKEG .KXG łWVKNKUGF 5GTXKEG 7#6 łWVKNKUGF 5GTXKEG 7#6 łWVKNKUGF 5GTXKEG 7#6 łWVKNKUGF 5GTXKEG &GX łWVKNKUGF 5GTXKEG &GX łWVKNKUGF 5GTXKEG &GX łWVKNKUGF X  ZEZNCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$ X  ZENCTIG Z'.$   
  8. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) API Gateway '.$

    EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X '.$ '.$ '.$
  9. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) API Gateway '.$

    EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X '.$ '.$ '.$ RGTOQPVJHQTCNN UGTXKEGUKP.KXGGPXKTQPOGPV QP FGOCPFVQVCNXGTUKQPU 
  10. ONE MICROSERVICE PER VIRTUAL MACHINE (WITH ELB) API Gateway '.$

    EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X '.$ '.$ '.$ RGTOQPVJHQTCNN UGTXKEGUKP.KXGGPXKTQPOGPV QP FGOCPFVQVCNXGTUKQPU  /QUVKORQTVCPVN[QWTXKTVWCN OCEJKPGUCTGJGCXKN[WPFGT WVKNKUGF
  11. CONTINUOUS DELIVERY Using CI System Only 2WUJ%QOOKV 6GUV$WKNF 9GDJQQM $CMG#/+

    8/+OCIG 7RNQCFDWKNF CTVKHCEV #TVKHCEVTGRQUKVQT[ &GRNQ[ CEVKXCVG &GCEVKXCVGQT FGUVTQ[ 6GTTCHQTO %NQWF(QTOCVKQP 4GIKUVGT#/+ QT8/+OCIG 2CEMGT $QZHWUG
  12. CONTINUOUS DELIVERY Using CI System Only 2WUJ%QOOKV 6GUV$WKNF 9GDJQQM $CMG#/+

    8/+OCIG 7RNQCFDWKNF CTVKHCEV #TVKHCEVTGRQUKVQT[ &GRNQ[ CEVKXCVG &GCEVKXCVGQT FGUVTQ[ 6GTTCHQTO %NQWF(QTOCVKQP 4GIKUVGT#/+ QT8/+OCIG 2CEMGT $QZHWUG #EVKXCVKQPKPXQNXGU &05EJCPIGCPFQT .QCFDCNCPEGT EQPHKIWTCVKQPWRFCVG
  13. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR
  14. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR
  15. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR
  16. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X
  17. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X
  18. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X
  19. DEPLOYMENT STRATEGY Rolling Update – One Instance At A Time

    '.$ EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X
  20. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 100%
  21. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR 25% 75%
  22. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X 60% 40%
  23. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X 50% 50%
  24. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X 40% 60%
  25. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X 25% 75%
  26. DEPLOYMENT STRATEGY Canary Release – % Users At A Time

    '.$ EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X 0% 100%
  27. DEPLOYMENT STRATEGY A/B– Equal Split of % Users '.$ EZNCTIG

    #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 100%
  28. DEPLOYMENT STRATEGY A/B– Equal Split of % Users '.$ EZNCTIG

    #< X EZNCTIG #< X EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR 0GY#WVQUECNKPI)TQWR EZNCTIG #< X EZNCTIG #< X 50% 50%
  29. DEPLOYMENT STRATEGY Blue-Green '.$ EZNCTIG #< X EZNCTIG #< X

    EZNCTIG #< X 1NF#WVQUECNKPI)TQWR'.$ &05 UGTXKEGGZCORNGEQO
  30. DEPLOYMENT STRATEGY Blue-Green '.$ EZNCTIG #< X EZNCTIG #< X

    EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR'.$ 0GY#WVQUECNKPI)TQWR'.$ EZNCTIG #< X EZNCTIG #< X '.$ &05 UGTXKEGGZCORNGEQO
  31. DEPLOYMENT STRATEGY Blue-Green '.$ EZNCTIG #< X EZNCTIG #< X

    EZNCTIG #< X EZNCTIG #< X 1NF#WVQUECNKPI)TQWR'.$ 0GY#WVQUECNKPI)TQWR'.$ EZNCTIG #< X EZNCTIG #< X '.$ &05 UGTXKEGGZCORNGEQO
  32. CONTINUOUS DELIVERY Using CI System + Spinnaker 2WUJ%QOOKV 6GUV$WKNF 9GDJQQM

    $CMG#/+ 8/+OCIG 7RNQCFDWKNF CTVKHCEV #TVKHCEVTGRQUKVQT[ &GRNQ[ CEVKXCVG &GCEVKXCVGQT FGUVTQ[ 6TKIIGTU 4GIKUVGT#95 #/+ 0GY#WVQUECNG ITQWR 1NF#WVQUECNG ITQWR 4GIKUVGT)%' 8/+OCIG 0GY/CPCIGF 1NF/CPCIGF
  33. ONE MICROSERVICE PER CONTAINER (WITH ELB) API Gateway '.$ X

    EZNCTIG #< X EZNCTIG #< X #< '.$ X '.$ X '.$ X EZNCTIG #< X EZNCTIG #< X #< EZNCTIG #< X EZNCTIG #< X #< X X X X X X X X X X X X X X X X X X X X X X X X X X X '.$ X '.$ X '.$ X '.$ X '.$ X
  34. ONE MICROSERVICE PER CONTAINER (WITH ELB) API Gateway '.$ X

    EZNCTIG #< X EZNCTIG #< X #< '.$ X '.$ X '.$ X EZNCTIG #< X EZNCTIG #< X #< EZNCTIG #< X EZNCTIG #< X #< X X X X X X X X X X X X X X X X X X X X X X X X X X X '.$ X '.$ X '.$ X '.$ X '.$ X RGTOQPVJHQTCNN UGTXKEGUKP.KXGGPXKTQPOGPV QP FGOCPFVQVCNXGTUKQPU 
  35. ONE MICROSERVICE PER CONTAINER (WITH ELB) API Gateway '.$ X

    EZNCTIG #< X EZNCTIG #< X #< '.$ X '.$ X '.$ X EZNCTIG #< X EZNCTIG #< X #< EZNCTIG #< X EZNCTIG #< X #< X X X X X X X X X X X X X X X X X X X X X X X X X X X '.$ X '.$ X '.$ X '.$ X '.$ X RGTOQPVJHQTCNN UGTXKEGUKP.KXGGPXKTQPOGPV QP FGOCPFVQVCNXGTUKQPU  0QYQWTXKTVWCNOCEJKPGUCTG QRVKOKUGFHQTTGUQWTEGU WVKNKUCVKQP
  36. ONE MICROSERVICE PER CONTAINER (WITH ELB) #NN5GTXKEGU .KXG łWVKNKUGF #NN5GTXKEGU

    .KXG łWVKNKUGF #NN5GTXKEGU 7#6 łWVKNKUGF #NN5GTXKEGU 7#6 łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF  ZEZNCTIG Z'.$  ZENCTIG Z'.$  ZENCTIG Z'.$ #VNGCUVNQYGT#95JQUVKPIEQUV YJGPEQORCTGFVQQPGOKETQUGTXKEGRGT KPUVCPEGOQFGNRNWUDGVVGTUGTXKEG RGTHQTOCPEGCPFKPUVCPEGWVKNKUCVKQP
  37. ONE MICROSERVICE PER CONTAINER (WITH HA/AUTO-SCALING) '.$ X #< X

    API Gateway Port Instance 8003 Port Container 8003 Port ELB 80 X '.$ X Port ELB 80 Port Instance 6003 Port Container 6003 /CRRKPIDGVYGGP +PUVCPEGRQTVUCPFEQPVCKPGTRQTVU
  38. ONE MICROSERVICE PER CONTAINER (SINGLE MULTI-AZ CONTAINER CLUSTER) API Gateway

    '.$ X EZNCTIG #< X EZNCTIG #< X #< '.$ X '.$ X '.$ X EZNCTIG #< X EZNCTIG #< X #< EZNCTIG #< X EZNCTIG #< X #< X X X X X X X X X X X X X X X X X X X X X X X X X X X '.$ X '.$ X '.$ X '.$ X '.$ X
  39. ONE MICROSERVICE PER CONTAINER (MULTIPLE SINGLE-AZ CONTAINER CLUSTER) API Gateway

    '.$ X EZNCTIG #< X EZNCTIG #< X #< '.$ X '.$ X '.$ X EZNCTIG #< X EZNCTIG #< X #< EZNCTIG #< X EZNCTIG #< X #< X X X X X X X X X X X X X X X X X X X X X X X X X X X '.$ X '.$ X '.$ X '.$ X '.$ X
  40. ONE MICROSERVICE PER CONTAINER With ELB & ILB API Gateway

    '.$ X #< X X X X X X +.$ X #< X X X X X X +.$ X #< X X X X X X +.$ X %QODKPCVKQPQHGZVGTPCNCPFKPVGTPCNNQCFDCNCPEKPI HQTF[PCOKEEQPVCKPGTRNCEGOGPV
  41. ONE MICROSERVICE PER CONTAINER More On ELB, ILB & Cluster

    1TEJGUVTCVKQP (TCOGYQTM '.$ +.$ 5KPING/WNVK#<%NWUVGT /WNVKRNG5KPING#< %NWUVGT /CTCVJQP&%15 .QCF$CNCPEGT OCTCVJQPND OCTCVJQPND *#2TQZ[ ;GU ;GU )QQING%QPVCKPGT'PIKPG )NQDCN.QCF$CNCPEGT *#2TQZ[ ;GU ;GU -WDGTPGVGU .QCF$CNCPEGT 0QFG2QTV 'ZVGTPCN+2U 5GTXKEG.QCF$CNCPEGT +PITGU -WDG2TQZ[ ;GU8GTUKQP ;GU #OC\QP'%5 'NCUVKE.QCF$CNCPEGT *#2TQZ[ ;GU 0Q
  42. ONE MICROSERVICE PER CONTAINER More On Service Discovery & Networking

    1TEJGUVTCVKQP(TCOGYQTM +PVGTPCN5GTXKEG&KUEQXGT[ 'ZVGTPCN5GTXKEG&KUEQXGT[ 0GVYQTMKPI /CTCVJQP&%15 /GUQU&05 OCTCVJQPND 'ZVGTPCN&05 %QPUWN +2RGTVCUM  8KTVWCN+2#FFTGUUGU )QQING%QPVCKPGT'PIKPG )NQDCN.QCF$CNCPEGT )QQING&05 2TKXCVGENWUVGT+2RGT2QF -WDGTPGVGU 'PXKTQPOGPVXCTKCDNGU &055GTXGT 'ZVGTPCN&05 2TKXCVGENWUVGT+2RGT2QF #OC\QP'%5 4QWVG 'NCUVKE.QCF$CNCPEGT 4QWVG %QPUWN '.$ 2TKXCVGENWUVGT+2RGTVCUM
  43. ONE MICROSERVICE PER CONTAINER Rolling Updates, Blue-Green and Canary 1TEJGUVTCVKQP(TCOGYQTM

    4QNNKPI7RITCFGU $NWG)TGGP %CPCT[ #$ /CTCVJQP&%15 1WVQHDQZ /KPKOWO*GCNVJ%CRCEKV[ 2QUUKDNGDWVEWUVQO UETKRVKPITGSWKTGF )QQING%QPVCKPGT'PIKPG 1WVQHDQZ 1PGRQFCVCVKOG 2QUUKDNGDWVEWUVQO UETKRVKPITGSWKTGF 1WVQHDQZ -WDGTPGVGU 1WVQHDQZ 1PGRQFCVCVKOG 2QUUKDNGDWVEWUVQO UETKRVKPITGSWKTGF 1WVQHDQZ #OC\QP'%5 2QUUKDNGDWVXGT[ETWFG 2QUUKDNGDWVEWUVQO UETKRVKPITGSWKTGF
  44. CONTINUOUS DELIVERY Using CI System Only 2WUJ%QOOKV 6GUV$WKNF 9GDJQQM %TGCVG

    %QPVCKPGT 7RNQCFDWKNF CTVKHCEV #TVKHCEVTGRQUKVQT[ &GRNQ[ CEVKXCVG &GCEVKXCVGQT FGUVTQ[ 7RNQCFEQPVCKPGT KOCIG
  45. /GUQU/CUVGT <- /GUQU/CUVGT <- MARATHON DC/OS /GUQU5NCXG /GUQU5NCXG /GUQU5NCXG /GUQU/CUVGT

    <- *#RTQZ[ %QPHKI 6TKIIGT&GRNQ[OGPVXKC4'56#2+ +OCIG 7RNQCF #WVQUECNG%QPVTQNNGT '.$
  46. 0QFG &QEMGT 0QFG &QEMGT KUBERNETES 0QFG /CUVGT 6TKIIGT&GRNQ[OGPVXKC4'56#2+QTMWDGEVN +OCIG 7RNQCF

    '.$ -WDGNGV -WDG7+ 4'56#2+U -WDGNGV -WDGNGV &QEMGT 2QF 2QF 2QF 2QF 2QF 2QF 6[RG.QCF$CNCPEGT %QPVTQNNGTU -WDG2TQZ[ -WDG2TQZ[ -WDG2TQZ[ GVEF GVEF GVEF
  47. ONE MICROSERVICE PER PaaS SERVICE (GOOGLE APP ENGINE) )QQING%NQWF2TQLGEV &CVCUVQTG

    /GOECEJG 6CUM3WGWG 2TQFWEV5GTXKEG %CTV5GTXKEG 1TFGT5GTXKEG (WNHKNOGPV5GTXKEG X X X X X X X X X  X X https://version-dot-service-dot-app-id.appspot.com
  48. GOOGLE APP ENGINE #NN5GTXKEGU .KXG łWVKNKUGF #NN5GTXKEGU .KXG łWVKNKUGF #NN5GTXKEGU

    7#6 łWVKNKUGF #NN5GTXKEGU 7#6 łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF  5GTXKEGU #XI+PUVCPEGUUGTXKEG +PUVCPEGV[RG$$ 6QVCN+PUVCPEG*TU OQPVJ  5GTXKEGU #XI+PUVCPEGUGTXKEG +PUVCPEGV[RG$ 6QVCN+PUVCPEG*TU /QPVJ  5GTXKEGU #XI+PUVCPEGUGTXKEG +PUVCPEGV[RG$ 6QVCN+PUVCPEG*TU /QPVJ
  49. GOOGLE APP ENGINE #NN5GTXKEGU .KXG łWVKNKUGF #NN5GTXKEGU .KXG łWVKNKUGF #NN5GTXKEGU

    7#6 łWVKNKUGF #NN5GTXKEGU 7#6 łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF #NN5GTXKEGU &GX łWVKNKUGF  5GTXKEGU #XI+PUVCPEGUUGTXKEG +PUVCPEGV[RG$$ 6QVCN+PUVCPEG*TU OQPVJ  5GTXKEGU #XI+PUVCPEGUGTXKEG +PUVCPEGV[RG$ 6QVCN+PUVCPEG*TU /QPVJ  5GTXKEGU #XI+PUVCPEGUGTXKEG +PUVCPEGV[RG$ 6QVCN+PUVCPEG*TU /QPVJ 6JTQWIJRWVQHCIKXGPKPUVCPEGFGRGPFUQPVJGNCVGPE[QHTGSWGUVRTQEGUUKPI 5QYKVJOKNNKUGEQPFNCVGPE[C$KPUVCPEGECPRTQEGUUTGSWGUVUUGEQPF
  50. ONE MICROSERVICE AS A SET OF COMPUTE FUNCTIONS Abhishek Tiwari

    http://abhishek-tiwari.com ! @abhishektiwari
  51. AWS Lambda Function Amazon API Gateway RTQFWEVU RTQFWEVU]KF_ ƛNKUVRTQFWEVU ƛIGVRTQFWEV

    ƛWRFCVGRTQFWEV ƛETGCVGRTQFWEV ƛFGNGVGRTQFWEV ƛIGVNKUVKOCIGU )'6 276 2156 &'.'6' RTQFWEVU]KF_KOCIGU ƛIGVKOCIG RTQFWEVU]KF_KOCIGU]KF_ ƛWRFCVGKOCIG ƛETGCVGKOCIG ƛFGNGVGKOCIG