Definition of Microservices 8 ● Small in size✔ ● Autnomously developed✔ ● Independently deployable✔ ● Built and released with automated processes✔ ● Decentralized O’Reilly: Microservice Architecture
API Gateway Architecture 9 Cache/router (Fastly) UI service UI service Internet API gateway Search Content Auth DNS (Internal / Route53) API service API service Image API gateway is not decentralized?
Gateway pattern 10 ● Authentication and Authorization ○ Front-end layer sometime does authorization ● Some services like image delivery are directly served ● Wrapper for old APIs
Small in size✔ 11 ● Django based python application ○ Each application has a few folders ○ But API gateway has many folders ● NodeJS application adopts express as framework ○ 200 - 300 lines of JavaScript
Autonomously developed✔ 12 ● Do not share resources like DB ○ Use S3 to share data ● Use web APIs to exchange data between services ● statelss ● generate a service from template
Follow template updates 16 pip install git+https://github.com/hirokiky/cookiepatcher cookiepatcher ● Do not make service legacy ● KY made cookiepatcher ● cookiepatcher.json manages diffs
Local development environment 21 ● It is easy for API development ○ python manage.py runserver ○ Not need to use Docker ● Front-end development is not easy ○ Routing some services to local computer
Batch 29 Docker Container Docker Container Batch process by Rundeck. Use same Docker Image both for Rundeck and ElasticBeanstalk Spot instance Docker Container
Monitoring, logging 31 ● Fluentd in another container aggregate logs ○ github.com/bungoume/log-sender ● Send error logs to Sentry ● Send metrics data to New Relic ● CloudWatch
Current issues 36 ● Scaling out is not so ideal ○ If spike more than expectation happens, scaling out is not fast enough ○ It is better to use scheduled scaling out ● Continuas update of libraries ○ Django version 1.7 -> 1.10 ○ Periodically check and update of requirements.txt is needed ● AWS is not perfect, shipped with bugs sometime.