2. About Me
7+ years as backend Software Engineer.
● Java/Scala
● SQL/NoSQL databases
● distributed caches, queuing
● Hadoop/Spark
● AWS,DevOps
● REST, microservices
3. An approach to developing a single application as
a suite of small services, each running in its
own process and communicating with
lightweight mechanisms
http://martinfowler.com/
Microservice architecture style
4. • Component decomposition
• Independant development lifecycle and
technology freedom
• Better extensibility
• Fault isolation
Microservice benefits
5. • Deployment of much greater number of
services and components
• Monitoring of many services for performance
or issues
• Looking into log files from many micro-services
• Versioning between services and environment
consistency
Microservice drawbacks
6. 1. Multiple Service instances per host
● conflicting resource requirements(CPU, memory, IO, etc.)
● conflicting dependency versions
1. Single Service instance per host
● potentially less efficient resource utilization
● hosts provisioning and maintenance
1. Service Instance per VM
● building a VM image is slow and time consuming
1. Service instance per container
● The infrastructure for deploying containers is not as rich as
the infrastructure for deploying virtual machines
Microservice deployment patterns
8. Containerization providers
Implementations:
● by vendors(Open Source,HP, IBM, Microsoft)
● by OS (Linux, FreeBSD, Solaris, Windows)
http://en.wikipedia.org/wiki/Operating-system-level_virtualization#Implementations.
Docker has become the most popular nowadays.
14. Basic docker usage scenario
1. create Dockerfile
2. build image with specific name in format
[registry_url/]repository:imageTag , e.g
myhost:5000/mycompany/myservice:version1
1. push image into registry (private or Docker Hub)
2. pull image by repository and tag (Optional)
3. run container from image
15. Dockerfile
• inherit existing images
• add/copy files to container
• set environment vars
• run shell command
• expose ports
• set working dir
• share host FS with container
• --no-cache option
• CMD and bootstrapping
• CMD vs ENTRYPOINT
FROM mycompany/app-base:latest
RUN mkdir -p /opt/app
ADD core.jar /opt/app/core.jar
RUN curl http://3rd-paty.repo.org/download/component.zip &&
unzip component.zip -d /opt/app/ && rm -f component.zip
COPY lib/ /opt/app/lib
ADD bootstrap.sh /etc/mysevice/
RUN chmod +x /etc/mysevice/bootstrap.sh
ADD workspace-manager-core.jar
ADD logback.xml /opt/app/logback.xml
ENV MODE="PRODUCTION"
VOLUME /log
WORKDIR /opt/app/
EXPOSE 80
CMD /etc/myservice/bootstrap.sh && /usr/lib/jvm/latest/bin/java
-cp /opt/app/core.jar:/opt/app/lib
-Xms256m
-Xmx2048m
-XX:+UseCompressedOops
-XX:+UseG1GC
-Dspark.kryoserializer.buffer.max.mb=128 -
Dlogback.configurationFile=/opt/app/logback.xml
org.mycompany.app.Runner
17. Container entrypoint
• Container must have long leaving process -
entrypoint
• Container will become stopped when process is
ended/crashed
• Two strategies: process per container vs
supervisord
21. • Container identification (--name)
• Network settings
o --net = [none, bridge (default), host, container:<name|id>]
o -P vs -p
o --link
• Useful options for debug/testing
o --rm=true, -it
o docker exec -it running_container_name bash
• Env variables
• Runtime constraints on CPU and memory
Run options