SlideShare a Scribd company logo
@BastianHofmann
Running Microservices
Successfully
Bastian Hofmann
Microservices
Monolith
http://blog.philipphauer.de/microservices-nutshell-pros-cons/
Monolith Microservices
" Microservices are great for
turning method calls in to
distributed computing
problems
https://twitter.com/tenderlove/status/1027591532847816704
Challenges
Performance
Latency
Operational overhead
Monitoring
Learning Curves
Code Reuse
Maintenance
Benefits
Enforces stricter separation of
concerns
Diverse technology stacks
Independent scaling
Independent development
Independent deployments
There are good reasons to split off
functionality into independent
services
How to run Microservices without
shooting yourself in the foot
Let's talk about
• Deploying
• Running
• Configuring
• Discovering
• Monitoring
• Scaling
A lot of this is also useful for
monoliths
https://www.flickr.com/photos/npobre/2601582256/
Let's define our requirements
Deployment
How to get the services on our
servers?
Diverse technology stacks
The same approach for every service
Fast deployments
Automation
One Click Deployment
Fast rollbacks
Availability
Zero Downtime Deployments
Running the service
How do I stop and start a service and
ensure it keeps running?
Diverse technology stacks
Diverse system dependencies
The same approach for every service
Configuration Management
How do I synchronize configuration
over services?
Config file on disk
[	
		"db_user":	"user",	
		"db_pw":	"pw",	
		"serviceA":	"serviceA.local:8018"	
]
Duplication
Inconsistencies
Security
Cycling of credentials
Service Discovery
How does one service know where
another service is?
Load balancing?
Service/Server down?
Health checks
Monitoring
How do I know how my application is
behaving?
Distributed Systems
We want to measure
Latency
Availability
Throughput
We want all logs aggregated and
searchable
Scaling
How can I cope with growing traffic?
Reacting to changes in traffic?
You have to take care about a lot of
things when doing Microservices!
There are tools that can help us with
this
Running microservices successfully | Bastian Hofmann | CODEiD
Container orchestration platform
Deploy, run and scale your services
in isolated containers
Very Powerful
Large community
Lot’s of large company backers
Compared to other cloud
technoligies
No vendor lock in
Runs on
AWS
Azure
Google Cloud Platform
Bare metal
Your laptop
SysEleven
Learning curve
Why containers?
Services run in isolation
Everything needed to run a service in
one image
Decouple
Ops and Dev
Make things …
Easier to deploy
Easier to upgrade system
dependencies
Easier to scale
Easier to develop
Leaner than
Virtual Machines
Running microservices successfully | Bastian Hofmann | CODEiD
FROM	php:7.2-apache	
WORKDIR	/var/www/html	
RUN	apt-get	update	-y	&&		
		apt-get	install	-y	--no-install-recommends	curl		
		rm	-rf	/var/lib/apt/lists/*	
ENV	TMP_DIR	/tmp	
COPY	.	/var/www/html/	
EXPOSE	80	
ENTRYPOINT	[“apache2”,	“-DFOREGROUND”]
docker	build	-t	symfony-demo:2.0.0	.
docker	run	-p	8080:80	symfony-demo:2.0.0
Kubernetes helps you running
containers
Let’s define some core Kubernetes
concepts
Kubernetes Cluster
• A physical server
• Containers get distributed
automatically
Node
• A docker image built from
a Dockerfile that contains
everything a service needs
to run
Image
• A container runs a docker
image.
• Only 1 process can run
inside of a container
Container
• A group of 1 or more
containers
• Same port space
• Ports are not accessible
from outside of the pod
Pod
• Defines and manages how
many instances of a pod
should run
Replica Set
• Manages updates and
rollbacks of replica sets
Deployment
• Makes a port of a pod
accessible to other pods
Service
• Makes a service
accessible to the outside
of Kubernetes
Ingress
• Configuration that can be
mounted inside of a
container
ConfigMap
• Volumes can be mounted
into a container to access
a ConfigMap, Secret or a
folder on the host
Volumes
Example
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
ReplicaSet: 2 instances
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
ReplicaSet: 2 instances
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
CONFIG
WEB :80
PHP Application POD PHP Application POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
ReplicaSet: 2 instances
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
CONFIG
WEB :80
https://php-app.k8s.foo.com:443/
PHP Application POD PHP Application POD
Let’s deploy the symfony demo app
https://github.com/symfony/demo
First we need a Kubernetes cluster
Running microservices successfully | Bastian Hofmann | CODEiD
Running microservices successfully | Bastian Hofmann | CODEiD
Running microservices successfully | Bastian Hofmann | CODEiD
Running microservices successfully | Bastian Hofmann | CODEiD
kubectl
$	kubectl	get	pods
NAME																																													READY					
STATUS				RESTARTS			AGE	
kubernetes-dashboard-5b5bf59977-t9xb9												1/1							
Running			2										9d	
nginx-ingress-controller-5549f5597c-97kcw								0/1							
Running			2										9d	
nginx-ingress-default-backend-564d9d9477-tmnnr			1/1							
Running			4										9d	
mysql-556c9b5bcb-5jdrt																											1/1							
Running			1										8d	
symfony-demo-5b75f5fc6-c7wr9																					1/1							
Running			0										8d	
symfony-demo-5b75f5fc6-jg8n4																					1/1							
Running			23									8d
Demo
Creating a Docker image
PHP
Copy our code
Build the project
Composer install
yarn install
yarn run build
Building the image
docker	build	-t	symfony-demo:2.0.0	.
Now we have to tell Kubernetes
what to do with the image
Resources are defined in YAML or
JSON
Deployment
kind:	Deployment	
apiVersion:	extensions/v1beta1	
metadata:	
		name:	symfony-demo	
spec:	
	template:	
				metadata:	
							labels:	
										app:	symfony-demo	
				spec:	
						containers:	
								-	name:	symfony-demo	
										image:	symfony-demo:1.0.0	
									ports:
containers:	
								-	name:	symfony-demo	
										image:	symfony-demo:1.0.0	
									ports:	
												-	containerPort:	80	
										livenessProbe:	
												httpGet:	
														path:	/	
														port:	80	
												timeoutSeconds:	1	
												initialDelaySeconds:	10	
										readinessProbe:	
												httpGet:	
														path:	/
Many more options configurable
Many more options
• Setting environment variables
• Mounting volumes
• Requesting resources
• Defining upgrade strategies
• Defining command
• Configure networking
• Configure the scheduler
• Listen on lifecycle events
• Configure system capabilities for the container
• …
Service
kind:	Service	
apiVersion:	v1	
metadata:	
		name:	symfony-demo	
spec:	
		ports:	
		-	
				name:	http	
				port:	80	
				targetPort:	80	
				protocol:	TCP	
		selector:	
				app:	symfony-demo
Ingress
kind:	Ingress	
apiVersion:	extensions/v1beta1	
metadata:	
		name:	symfony-demo	
spec:	
		rules:	
		-	host:	symfony-demo.local.k8s	
				http:	
						paths:	
						-	path:	/	
								backend:	
										serviceName:	symfony-demo	
										servicePort:	80
Creating everything
kubectl	apply	-f	deployment/webapp.yaml
Running microservices successfully | Bastian Hofmann | CODEiD
Rolling Deployments
kind:	Deployment	
apiVersion:	extensions/v1beta1	
metadata:	
		name:	symfony-demo	
spec:	
	template:	
				spec:	
						containers:	
								-	name:	symfony-demo	
										image:	symfony-demo:1.1.0	
									ports:	
												-	containerPort:	80
kubectl	apply	-f	deployment/webapp.yaml
Rollback
$	kubectl	rollout	undo	deployments	symfony-deom	--to-
revision=1
Configuration
Should not be included in the docker
image
ConfigMap
Key/Value Store
kind:	ConfigMap	
apiVersion:	v1	
metadata:	
		name:	special-config	
data:	
		special-key:	value	
		bool-value:	true
Can be accessed in a pod through
environment variables
spec:	
		containers:	
				-	name:	test-container	
						image:	k8s.gcr.io/busybox	
						command:	[	"/bin/sh",	"-c",	"env"	]	
						env:	
		-	name:	SPECIAL_KEY	
				valueFrom:	
						configMapKeyRef:	
								name:	special-config	
								key:	special-key
spec:	
		containers:	
				-	name:	test-container	
						image:	k8s.gcr.io/busybox	
						command:	[	"/bin/sh",	"-c",	"env"	]	
						envFrom:	
						-	configMapRef:	
										name:	special-config
Can be accessed through volumes
spec:	
		containers:	
				-	name:	test-container	
						image:	k8s.gcr.io/busybox	
						command:	[	"/bin/sh",	"-c",	"ls	/etc/config/"	]	
						volumeMounts:	
						-	name:	config-volume	
								mountPath:	/etc/config	
		volumes:	
				-	name:	config-volume	
						configMap:	
								name:	special-config
Service Discovery
Within a pod
Shared port namespace
Separate file systems
Separate process spaces
Network wise everything behaves
like localhost
Between pods
You have to expose ports with
services
kind:	Service	
apiVersion:	v1	
metadata:	
		name:	symfony-demo	
spec:	
		ports:	
		-	
				name:	http	
				port:	80	
				targetPort:	80	
				protocol:	TCP	
		selector:	
				app:	symfony-demo
Every service has a virtual IP address
$	kubectl	get	service	symfony-demo	
NAME											TYPE								CLUSTER-IP				PORT(S)			AGE	
symfony-demo			ClusterIP			10.106.119.24	80/TCP				6d
Discoverable in other containers by
Environment Variables
SYMFONY_DEMO_SERVICE_HOST=10.106.119.24	
SYMFONY_DEMO_SERVICE_PORT=80
DNS
$	nslookup	symfony-demo	
Server:				10.0.0.10	
Address	1:	10.0.0.10	
Name:						symfony-demo	
Address	1:	10.106.119.24
$	curl	http://symfony-demo
Service Mesh
Istio
https://istio.io/
LinkerD
https://linkerd.io/
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
NodeJS ISTIO
NodeJS Service POD
NodeJS ISTIO
NodeJS Service POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
NodeJS ISTIO
NodeJS Service POD
NodeJS ISTIO
NodeJS Service POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
NodeJS ISTIO
NodeJS Service POD
NodeJS ISTIO
NodeJS Service POD
PHP-FPM
NGINX
ISTIO
STATSD
MEM

CACHED
MONGO

ROUTER
PHP Application POD
NodeJS ISTIO
NodeJS Service POD
NodeJS ISTIO
NodeJS Service POD
Benefits
Advanced routing
Prefer service in current namespace,
fall back to default namespace
A/B Testing
https://medium.com/vamp-io/a-b-testing-on-kubernetes-with-istio-0-8-6323efa2b4e2
Canary deployments
https://istio.io/blog/2017/0.1-canary/
Circuit Breakers
https://istio.io/docs/tasks/traffic-management/circuit-breaking/
Security
https://istio.io/blog/2017/0.1-auth/
Advanced monitoring
Running microservices successfully | Bastian Hofmann | CODEiD
Profiling
Running microservices successfully | Bastian Hofmann | CODEiD
Monitoring
Metrics-Server
Takes metrics from Kubernetes and
stores them in a monitoring solution
e.g. Prometheus
Combine with metrics of other
components
Service Mesh
Your services
Grafana for displaying the data
Running microservices successfully | Bastian Hofmann | CODEiD
Running microservices successfully | Bastian Hofmann | CODEiD
Logging
kubectl logs
$	kubectl	logs	symfony-demo-5b75f5fc6-c7wr9
One interface
Easy to pipe into central log
management system
Scaling
Manual Scaling
kubectl	scale	--replicas=3	deployment/my-app
AutoScaling
https://kubernetes.io/docs/user-guide/
horizontal-pod-autoscaling/
Summary
Powerful
Helpful
Together with the whole Eco-System
And Docker
Kubernetes helps you to run
microservices successfully
By standardizing Deployment,
Scaling, Configuration, Monitoring,
Service Discovery, Health Checks, ...
http://speakerdeck.com/
u/bastianhofmann
Vielen Dank für Ihre Aufmerksamkeit!

More Related Content

PDF
FreeSWITCH Cluster by K8s
PDF
Deployment with Ruby on Rails
PPTX
Kubernetes and container security
PPTX
TYPO3 & Composer
PDF
IITCC15: The Bare-Metal Hypervisor as a Platform for Innovation
PDF
Secure your K8s cluster from multi-layers
PDF
A Summary about Hykes' Keynote on Dockercon 2015
PDF
FreeSWITCH on Docker
FreeSWITCH Cluster by K8s
Deployment with Ruby on Rails
Kubernetes and container security
TYPO3 & Composer
IITCC15: The Bare-Metal Hypervisor as a Platform for Innovation
Secure your K8s cluster from multi-layers
A Summary about Hykes' Keynote on Dockercon 2015
FreeSWITCH on Docker

What's hot (12)

PDF
KVM_security
PPTX
Why do I need Kubernetes?
PDF
Building Resilient Applications with Cloudflare DNS
PDF
Orchestrating Linux Containers
ODP
OpenShift Origin Internals
PDF
Janus & docker: friends or foe
PDF
Load Balancing Applications on Kubernetes with NGINX
PDF
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
PPTX
[ElastixWorld 2016] mediasoup: Powerful WebRTC SFU for Node.js
PPTX
Building Python Development Station
PPTX
voip2day 2016: mediasoup, powerful WebRTC SFU for Node.js
PDF
oVirt – open your virtual datacenter
KVM_security
Why do I need Kubernetes?
Building Resilient Applications with Cloudflare DNS
Orchestrating Linux Containers
OpenShift Origin Internals
Janus & docker: friends or foe
Load Balancing Applications on Kubernetes with NGINX
Docker Meetup - Melbourne 2015 - Kubernetes Deep Dive
[ElastixWorld 2016] mediasoup: Powerful WebRTC SFU for Node.js
Building Python Development Station
voip2day 2016: mediasoup, powerful WebRTC SFU for Node.js
oVirt – open your virtual datacenter
Ad

Similar to Running microservices successfully | Bastian Hofmann | CODEiD (20)

PDF
Microservices: How loose is loosely coupled?
PPTX
Microservices and containers for the unitiated
PDF
Containers, Docker, and Microservices: the Terrific Trio
PPTX
Microservices pros and cons dark
PDF
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
PPTX
Microservices pros and cons
PDF
Introduction to Containers
PPTX
Kubernetes solutions
PDF
Microservices pros and cons - houston tech fest
PPT
Integration in the Cloud
PDF
Containers, microservices and serverless for realists
PDF
Managing containers at scale
PPTX
Kubernetes 101
PDF
Devops - Microservice and Kubernetes
PPTX
A docker love story
PPTX
Microservices and Deployment Methodologies
PDF
Scalable Spark deployment using Kubernetes
PPTX
introduction to k8s
PDF
Azure meetup cloud native concepts - may 28th 2018
PDF
Digital Transformation with Kubernetes, Containers, and Microservices
Microservices: How loose is loosely coupled?
Microservices and containers for the unitiated
Containers, Docker, and Microservices: the Terrific Trio
Microservices pros and cons dark
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices pros and cons
Introduction to Containers
Kubernetes solutions
Microservices pros and cons - houston tech fest
Integration in the Cloud
Containers, microservices and serverless for realists
Managing containers at scale
Kubernetes 101
Devops - Microservice and Kubernetes
A docker love story
Microservices and Deployment Methodologies
Scalable Spark deployment using Kubernetes
introduction to k8s
Azure meetup cloud native concepts - may 28th 2018
Digital Transformation with Kubernetes, Containers, and Microservices
Ad

More from CODEiD PHP Community (11)

PDF
GRASP - General Responsibility Assignment Software Principles
PDF
The PHP developer stack for building chatbots | Christoph Rumpel | CODEiD
PDF
Ioc container | Hannes Van De Vreken | CODEiD
PDF
Effective codereview | Dave Liddament | CODEiD
PDF
Contract testing | Евгений Кузьмин | CODEiD
PPTX
Graphql + Symfony | Александр Демченко | CODEiD
PDF
Mastering message queues | Tobias Nyholm | CODEiD
PDF
Symfony4: A new way to develop applications | Antonio Peric | CODEiD
PPTX
Domain Driven Design | Артём Антоненко | CODEID |
PPTX
CodeID - PHP Odessa Conf: Сергей Тимошевский "Все пути ведут к микросервисам"
PPTX
CodeID - PHP Odessa Conf: Вячеслав Мозговой "Как сделать сайт быстрым и люб...
GRASP - General Responsibility Assignment Software Principles
The PHP developer stack for building chatbots | Christoph Rumpel | CODEiD
Ioc container | Hannes Van De Vreken | CODEiD
Effective codereview | Dave Liddament | CODEiD
Contract testing | Евгений Кузьмин | CODEiD
Graphql + Symfony | Александр Демченко | CODEiD
Mastering message queues | Tobias Nyholm | CODEiD
Symfony4: A new way to develop applications | Antonio Peric | CODEiD
Domain Driven Design | Артём Антоненко | CODEID |
CodeID - PHP Odessa Conf: Сергей Тимошевский "Все пути ведут к микросервисам"
CodeID - PHP Odessa Conf: Вячеслав Мозговой "Как сделать сайт быстрым и люб...

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administraation Chapter 3
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administration Chapter 2
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03
Upgrade and Innovation Strategies for SAP ERP Customers
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Softaken Excel to vCard Converter Software.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How Creative Agencies Leverage Project Management Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025

Running microservices successfully | Bastian Hofmann | CODEiD