CMSC389L
Week 12
Microservices + ECS
Friday, November 17, 2017
Microservices
"Any organization that designs a system will inevitably produce a design whose structure is a copy of the organization's communication structure."
- Melvin Conway
Microservices vs. Monolith
Data Isolation
Microservices vs. Monolithic
Microservices Cons
- Avoid microservices until you need them
- Just adds complexity
- Distributed logging, distributed tracing, deployment automation, monitoring, learning curve, ...
[https://martinfowler.com/bliki/MicroservicePremium.html]
Microservices in Prod
etc.
Docker
What is Docker?
- Container creation tool
- Containers = isolated processes
- Problems it solves:
- Conflicting configurations, runtimes, dependencies...
- "It works for me"
- Unified development + production environments
Docker vs. VMs
Docker Concepts
Example Dockerfile
FROM ubuntu:12.10
MAINTAINER Ken Cochrane "kencochrane@gmail.com"
RUN apt-get -qq update
RUN apt-get install -y python-dev python-setuptools supervisor git-core
RUN easy_install pip
RUN pip install virtualenv
RUN pip install uwsgi
RUN virtualenv --no-site-packages /opt/ve/djdocker
ADD . /opt/apps/djdocker
ADD .docker/supervisor.conf /opt/supervisor.conf
ADD .docker/run.sh /usr/local/bin/run
RUN (cd /opt/apps/djdocker && git remote rm origin)
RUN (cd /opt/apps/djdocker && git remote add origin https://github.com/kencochrane/django-docker.git)
RUN /opt/ve/djdocker/bin/pip install -r /opt/apps/djdocker/requirements.txt
RUN (cd /opt/apps/djdocker && /opt/ve/djdocker/bin/python manage.py syncdb --noinput)
RUN (cd /opt/apps/djdocker && /opt/ve/djdocker/bin/python manage.py collectstatic --noinput)
EXPOSE 8000
CMD ["/bin/sh", "-e", "/usr/local/bin/run"]
Docker Registry
- "Github" for Docker images
- K:V store
-
image_name:tag -> image
-
example:web:latest
-
- K:V store
- Run your own or use managed registry:
- Docker Registry
- AWS EC2 Container Registry (ECR)
-
800593953112.dkr.ecr.us-east-1.amazonaws.com
-
Docker Concepts
Docker Demo
ECS
ECS at a High Level
-
Cluster of EC2 instances
- Often 1 for dev, 1 for staging, 1 for production...
- Can mix-and-match EC2 instances
-
Task Definition: Container Configuration
- Specifies memory, CPU, image,
-
Services: Container Manager Configuration
- Specifies desired count, auto-scaling, etc.
ECS at a High Level
Advanced ECS
-
Transition Deployments:
- New task definitions will incrementally swap out with the old task definitions
-
Auto Scaling
- via CloudWatch events
ECS Demo
Week 12 Feedback
Closing Notes
- Project Checkpoint due 11/27
- + 1 day (for Thanksgiving)
CMSC389L Week 12
By Colin King
CMSC389L Week 12
- 740