Slide 1

Slide 1 text

Building a modern SaaS in 2020 Nikolay Stoitsev, Engineering Manager @ Halo DX

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 6

Slide 6 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 7

Slide 7 text

Language evaluation Python JavaScript/Node.js Java C#/.NET Core

Slide 8

Slide 8 text

Domain Specifics FIPS 140-2

Slide 9

Slide 9 text

Node.js Can build with special OpenSSL

Slide 10

Slide 10 text

Java Package with verified implementation of cryptographic algorithms

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

DICOM

Slide 14

Slide 14 text

Imaging Center

Slide 15

Slide 15 text

Imaging Center Hospital

Slide 16

Slide 16 text

HL7 Imaging Center Hospital

Slide 17

Slide 17 text

HL7 DICOM

Slide 18

Slide 18 text

Java and Spring Boot

Slide 19

Slide 19 text

Angular

Slide 20

Slide 20 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 21

Slide 21 text

Microservices Discovery

Slide 22

Slide 22 text

Microservices Discovery Load Balancing

Slide 23

Slide 23 text

Microservices Discovery Load Balancing Circuit Breaking

Slide 24

Slide 24 text

Microservices Discovery Load Balancing Circuit Breaking Testing

Slide 25

Slide 25 text

Microservices Discovery Load Balancing Circuit Breaking Testing Debugging

Slide 26

Slide 26 text

Monolith

Slide 27

Slide 27 text

Failure Isolation

Slide 28

Slide 28 text

6 services

Slide 29

Slide 29 text

Hexagonal Architecture Web Adapter Messaging Adapter Input Port Input Port Biz Logic Output Port Output Port Persistence Adapter Messaging

Slide 30

Slide 30 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 31

Slide 31 text

Multi Repo vs Mono Repo

Slide 32

Slide 32 text

Mono Repo Easily introduce and refactor global features Ease code sharing and reuse Simple dependency management Flexible team boundaries and code ownership Collaboration across teams Atomic commits across services

Slide 33

Slide 33 text

Build System Bazel ● Fast and incremental builds ● One tool to build multiple languages ● Extensible ● Google, Pinterest, Uber, Stripe Buck ● Fast and incremental builds ● One tool to build multiple languages ● Helps you better understand your dependencies ● Facebook, Airbnb

Slide 34

Slide 34 text

Multi-Project Builds in Gradle

Slide 35

Slide 35 text

Multi-Project Builds in Gradle ● One root project ● One subproject for each service ● One subproject for shared libs ● https://docs.gradle.org/current/userguide/multi_project_builds.html

Slide 36

Slide 36 text

Multi-Project Builds in Gradle

Slide 37

Slide 37 text

Nx for front-end monorepo https://github.com/nrwl/nx

Slide 38

Slide 38 text

Gradle wrapper for front-end builds and running tests

Slide 39

Slide 39 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 40

Slide 40 text

Separate Dockerfile for each service

Slide 41

Slide 41 text

Can have one Docker Compose for everything

Slide 42

Slide 42 text

Nexus https://www.sonatype.com/nexus/repository-oss

Slide 43

Slide 43 text

Why Nexus? Can store and distribute Maven/Java, npm, Helm, Docker Widely adopted Single source of truth for every component Easy to work with

Slide 44

Slide 44 text

Build Process CI Code

Slide 45

Slide 45 text

Build Process CI CD Code

Slide 46

Slide 46 text

Build Process CI CD Build Docker Image Code

Slide 47

Slide 47 text

Build Process CI CD Nexus Build Docker Image Code Docker Image

Slide 48

Slide 48 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 49

Slide 49 text

Kubernetes https://kubernetes.io

Slide 50

Slide 50 text

Why Kubernetes? Deployment Scaling Self-healing Inter-service communication Storage orchestration Scalable and battle tested

Slide 51

Slide 51 text

Great for engineers ● Each service is accessed via a single domain ● Logs are easy to read ● A lot of materials on how to learn it

Slide 52

Slide 52 text

https://github.com/rancher/rancher

Slide 53

Slide 53 text

Monitoring and Grafana out of the box

Slide 54

Slide 54 text

Configuring a service in Kubernetes ● Deployment ● Service ● Config Map ● Service Account ● RBAC ● Pod disruption budget ● ....

Slide 55

Slide 55 text

Helm https://github.com/helm/helm

Slide 56

Slide 56 text

Helm ● Abstraction over k8s that simplifies working with it ● The building block in helm is called a helm chart ● Help you define, install, and upgrade applications in k8s

Slide 57

Slide 57 text

How to work with Helm ● Search for “{technology} helm chart” ● Download helm chart ● Update values.yaml ● $ helm install {release-name} {chart-name} --set {var}={val}

Slide 58

Slide 58 text

Deploy Process CI CD Nexus Build Docker Image Docker Image

Slide 59

Slide 59 text

Deploy Process CI CD Nexus Kubernetes Kubernetes Kubernetes

Slide 60

Slide 60 text

Deploy Process CI CD Nexus Helm Update Kubernetes Kubernetes Kubernetes

Slide 61

Slide 61 text

Deploy Process CI CD Nexus Helm Update Kubernetes Kubernetes Kubernetes Pull Image

Slide 62

Slide 62 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 63

Slide 63 text

SLF4J backed by Log4j2 https://github.com/qos-ch/slf4j

Slide 64

Slide 64 text

Backend logging EFK - Elasticsearch, Fluentd, Kibana Pod Pod Pod

Slide 65

Slide 65 text

Backend logging EFK - Elasticsearch, Fluentd, Kibana Pod Pod Pod Fluentd Fluentd Fluentd

Slide 66

Slide 66 text

Backend logging EFK - Elasticsearch, Fluentd, Kibana Pod Pod Pod Fluentd Fluentd Fluentd Elasticsearch

Slide 67

Slide 67 text

Backend logging EFK - Elasticsearch, Fluentd, Kibana Pod Pod Pod Fluentd Fluentd Fluentd Elasticsearch Kibana

Slide 68

Slide 68 text

Front-end logging

Slide 69

Slide 69 text

Front End Logging Library

Slide 70

Slide 70 text

Front End Logging Library

Slide 71

Slide 71 text

Front End Logging front end lib front end lib

Slide 72

Slide 72 text

Front End Logging Backend Service Backend Service front end lib front end lib

Slide 73

Slide 73 text

Front End Logging Backend Service Backend Service Fluentd Fluentd front end lib front end lib

Slide 74

Slide 74 text

Front End Logging Backend Service Backend Service Fluentd Fluentd Elasticsearch Kibana front end lib front end lib

Slide 75

Slide 75 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy

Slide 76

Slide 76 text

Subtenancy Org East West Sales Front Desk Sales Front Desk

Slide 77

Slide 77 text

Materialized path (1) Org (2) East (3) West (4) Sales (5) Front Desk (6) Sales (7) Front Desk ID Path Name 1 1/ Org 2 1/2/ East 3 1/3/ West 4 1/2/4 Sales East 5 1/2/5 Front Desk East 6 1/3/6 Sales West 7 1/3/7 Front Desk West

Slide 78

Slide 78 text

Closure table (1) Org (2) East (3) West (4) Sales (5) Front Desk (6) Sales (7) Front Desk ID Name 1 Org 2 East 3 West 4 Sales East 5 Front Desk East 6 Sales West 7 Front Desk West Ancestor Descendant 1 2 1 3 1 4 1 5 1 6 1 7 2 4 2 5 3 6 3 7 4 Null

Slide 79

Slide 79 text

Keeping hierarchy and data separated (1) Org (2) East (3) West (4) Sales (5) Front Desk (6) Sales (7) Front Desk ● Each records get a tag - 1, 2, 3, etc. ● Each tag points to a node in the tree ● Tag hierarchy is loaded separately ● Queries are decorated with OR statements to match by tag

Slide 80

Slide 80 text

Benchmark

Slide 81

Slide 81 text

Benchmark

Slide 82

Slide 82 text

Language Java and Spring Boot

Slide 83

Slide 83 text

Language Architecture Java and Spring Boot Microservices

Slide 84

Slide 84 text

Language Architecture Repo Structure Java and Spring Boot Microservices Monorepo

Slide 85

Slide 85 text

Language Architecture Repo Structure Builds Java and Spring Boot Microservices Monorepo Gradle and Docker

Slide 86

Slide 86 text

Language Architecture Repo Structure Builds Running in Production Java and Spring Boot Microservices Monorepo Gradle and Docker Kubernetes

Slide 87

Slide 87 text

Language Architecture Repo Structure Builds Running in Production Observability Java and Spring Boot Microservices Monorepo Gradle and Docker Kubernetes EFK stack

Slide 88

Slide 88 text

Language Architecture Repo Structure Builds Running in Production Observability Multitenancy Java and Spring Boot Microservices Monorepo Gradle and Docker Kubernetes EFK stack Separate hierarchy and data

Slide 89

Slide 89 text

Thank you! Q&A Nikolay Stoitsev Engineering Manager at Halo DX