2. Speaker
● Marius Meisenzahl
● Umsetzung von skalierbaren Software-Architekturen
● Software von eingebetteten Systemen bis zur Cloud
● Mitgründer von
2
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
/meisenzahl /msnzhl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
3. Inhaltsverzeichnis
● Motivation
● Technologien
● Hardwareauswahl
● Softwareentwicklung
● Deployment
● Erfahrungen aus der Praxis
3
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
5. Microservices
5
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● komplexe Lösung wird aus passenden Bausteinen zusammengesetzt
● Bausteine folgen der Unix-Philosophie: “Do One Thing and Do It Well”
● bessere Wart- und Testbarkeit der einzelnen Bausteine
● Bausteine können mit passender Programmiersprache umgesetzt werden
● Bausteine können einfacher ausgetauscht werden
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
6. Beispiel aus dem Web
6
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
[apiacademy]
8. Container
8
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● leichtgewichtige Alternative zu virtuellen Maschinen
● virtualisieren nur Applikationen (keine Hardware)
● lösen das Problem “It works on my machine”
● populär geworden mit Docker [docker]
○ basiert auf dem Open-Source Projekt Moby [moby]
○ nutzt Techniken des Linux-Kernels [check-config]
○ stellt Applikation als Images über Docker Hub bereit [dockerhub]
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
9. Docker
9
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
FROM ubuntu:18.04
RUN apt-get update -qq
-& apt-get install -qq -y
netcat-openbsd
-& rm -rf /var/lib/apt/lists-*
EXPOSE 8000
CMD ["/bin/nc", "-l", "-v", "8000"]
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
$ docker build -t simple-server .
10. Docker
10
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM ubuntu:18.04
---> ccc6e87d482b
Step 2/4 : RUN apt-get update -qq -& apt-get install -qq -y netcat-openbsd -&
rm -rf /var/lib/apt/lists-*
---> Running in cef6ce904744
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libbsd0:amd64.
--.
Processing triggers for libc-bin (2.27-3ubuntu1) --.
Removing intermediate container cef6ce904744
---> 4d6762650c16
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
Step 3/4 : EXPOSE 8000
---> Running in 08d892066bd8
Removing intermediate container 08d892066bd8
---> 1c31a71cd354
Step 4/4 : CMD ["/bin/nc", "-l", "-v", "8000"]
---> Running in cf6bd5d4824b
Removing intermediate container cf6bd5d4824b
---> e717000f7c0a
Successfully built e717000f7c0a
Successfully tagged simple-server:latest
11. Docker
11
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
$ docker run -ti --rm -p8000:8000 simple-server
Listening on [0.0.0.0] (family 0, port 8000)
Connection from 172.17.0.1 34486 received!
Hello, world!
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
$ telnet 127.0.0.1 8000
Trying 127.0.0.1--.
Connected to 127.0.0.1.
Escape character is '^]'.
Hello, world!
12. Function as a Service (FaaS)
12
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● Bereitstellung von Funktionen meist per HTTP/REST
● populär geworden mit Angeboten von Cloud-Anbietern
○ AWS, Azure, GCP, …
● Open-Source Lösungen vorhanden z. B. mit OpenFaas [openfaas]
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
13. gRPC
● Ausführung von Remote Procedure Calls
● Support für Load Balancing, Tracing, Health Checking und Authentifizierung
● Binäre Serialisierung und Deserialisierung von Datenstrukturen mit Protocol
Buffers
○ Nutzung von typisierten Datenstrukturen
● Code-Generierung für Client und Server für
○ C#, C++, Dart, Go, Java, Node.js, Objective-C, PHP, Python, Ruby
● Kommunikation erfolgt per HTTP/2 vom Backend bis ins Frontend
bidirektional
13
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
15. Kriterien
15
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● Architektur
○ x86 vs. ARM
○ in Zukunft interessant: RISC-V (aktuell zu schlechte Unterstützung)
● CPU
● RAM
● Konnektivität
● Hardwarebeschleunigung
○ Verschlüsselung
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
16. x86
16
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
17. ARM
17
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
25. Continuous Integration
25
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl 03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
26. Docker Buildx
26
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● Plugin für Docker
● baut Docker Images mithilfe von Qemu für andere Hardwarearchitekturen
$ docker buildx build --platform linux/amd64,linux/arm/v7
-t simple-server --push .
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
[buildx]
27. Continuous Deployment
27
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● GitLab bietet eine private Container Registry an [gl-registry]
○ es können Tokens für lesenden Zugriff per Docker erzeugt werden
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
28. systemd
[Unit]
Description=Living on the Edge
Requires=docker.service
After=docker.service
[Service]
Restart=always
TimeoutStartSec=60
WorkingDirectory=/opt/living-on-the-edge
# Remove old containers, images and volumes and update it
ExecStartPre=/usr/local/bin/docker-compose -f docker-compose.yml down -v
ExecStartPre=/usr/local/bin/docker-compose -f docker-compose.yml rm -fv
ExecStartPre=/usr/local/bin/docker-compose -f docker-compose.yml build --pull
28
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
29. systemd
# Compose up
ExecStart=/usr/local/bin/docker-compose -f docker-compose.yml up
# Compose down, remove containers and volumes
ExecStop=/usr/local/bin/docker-compose -f docker-compose.yml down -v
[Install]
WantedBy=multi-user.target
ExecStartPre=/usr/local/bin/docker-compose -f docker-compose.yml build --pull
# Compose up
ExecStart=/usr/local/bin/docker-compose -f docker-compose.yml up
# Compose down, remove containers and volumes
ExecStop=/usr/local/bin/docker-compose -f docker-compose.yml down -v
[Install]
WantedBy=multi-user.target
29
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
30. Erfahrungen aus der Praxis
30
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
31. Virtuelle Maschinen vermeiden
31
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● Wenn möglich sollten Programmiersprachen mit virtuellen Maschinen wie
Java oder C# vermieden werden
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
32. Virtuelle Maschinen vermeiden
32
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl 03.03.2020
[edgex]
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
33. Virtuelle Maschinen vermeiden
● Bei gewachsener Softwarebasis
○ für Java z. B. auf Kotlin migrieren → Kotlin Native nutzen [kotlin]
○ Mischung aus Monolith und Microservices
■ bestehende Software als Monolith
■ neue Funktionen als Microservices in passender Sprache umsetzen
33
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
34. Docker Images clever bauen
● RUN-Aufrufe zusammenziehen
● Multistage Builds nutzen
● Images aufeinander aufbauen
○ z. B. mit Basisbibliotheken
● Binaries statisch bauen
● FROM scratch
34
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
35. Docker Engine
● z. B. durch Balena Engine [begine] ersetzen
○ 3.5x smaller than Docker CE, packaged as a single binary
○ Bandwidth-efficient updates with binary diffs, 10-70x smaller than pulling layers
○ Extract layers as they arrive to prevent excessive writing to disk, protecting your storage from
eventual corruption
○ Atomic and durable image pulls defend against partial container pulls in the event of power
failure
○ Prevents page cache thrashing during image pull, so your application runs undisturbed in
low-memory situations
35
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
36. Learnings
1. API-Beschreibung als Single Source of Truth
2. Continuous Integration/Deployment
3. Programmiersprachen mit virtuellen Maschinen vermeiden
4. Möglichkeiten von Technologien schrittweise ausreizen
5. Tools an eigene Bedürfnisse anpassen
6. Technologie passend zur Problemstellung wählen
36
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
37. 37
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
38. Quellen
● [apiacademy] https://apiacademy.co/2016/06/api-design-304-api-design-for-microservices/
● [docker] https://www.docker.com/
● [moby] https://mobyproject.org/
● [check-config] https://github.com/moby/moby/blob/master/contrib/check-config.sh
● [dockerhub] https://hub.docker.com/
● [openfaas] https://www.openfaas.com/
● [proto3] https://developers.google.com/protocol-buffers/docs/proto3
● [buildx] https://github.com/docker/buildx
● [gl-registry] https://docs.gitlab.com/ee/user/packages/container_registry/
● [edgex] https://www.edgexfoundry.org/blog/2018/02/27/edgex-getting-skinny-fast-california-preview/
● [kotlin] https://kotlinlang.org/docs/reference/native-overview.html
● [bengine] https://github.com/balena-os/balena-engine
38
03.03.2020Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis
39. Bilder
39
Living on the Edge - Microservices in der Wildnis • Marius Meisenzahl
● https://unsplash.com/photos/gSUqHvJuUDU
● https://www.dell.com/de-de/work/shop/gateways-embedded-computing/sf/
edge-gateway
● https://revolution.kunbus.de/shop/de/revpi-connect-plus
03.03.2020
Motivation • Technologien • Hardwareauswahl • Softwareentwicklung • Deployment • Erfahrungen aus der Praxis