x-technology

XTechnology - Technology is beautiful, let's discover it together!

How to Decompose Monolith API into GRPC Microservices

The workshop focuses on concepts, algorithms, and practices to decompose a monolithic application into GRPC microservices. It overviews architecture principles, design patterns and technologies used to build microservices. It covers the theory of the GRPC framework and protocol buffers mechanism, as well as techniques and specifics of building isolated TypeScript services in the Node.js stack. The workshop includes a live use case demo of decomposing an API application into set of microservices. It fits the best architects, tech leads, and developers who want to learn microservices patterns.

General

Prerequisites

Instructors

Alex Korzhikov & Andrew Reddikh

Materials

repository-open-graph-template 1

Workshop Begins!

Agenda

Introduction

Who are we?

Alex Korzhikov

alex korzhikov

Software Engineer, Netherlands

My primary interest is self development and craftsmanship. I enjoy exploring technologies, coding open source and enterprise projects, teaching, speaking and writing about programming - JavaScript, Node.js, TypeScript, Go, Java, Docker, Kubernetes, JSON Schema, DevOps, Web Components, Algorithms 👋 ⚽️ 🧑‍💻 🎧

Andrew Reddikh

andrew reddikh

Software Engineer, United Kingdom

Passionate software engineer with expertise in software development, microservice architecture, and cloud infrastructure. On daily basis, I use Node.js, TypeScript, Golang, and DevOps best practices to build a better tech world by contributing to open source projects.

What are we going to do today?

⬆️ About

Project Ecosystem

Github Project Unknown

Bank Application by Adrian Pietrzak

Nest Icon

Nest Framework

A progressive Node.js framework for building efficient, reliable and scalable server-side applications

// modules
import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';

@Module({
  imports: [CatsModule],
})
export class AppModule {}

// controllers
import { Controller, Get, Req } from '@nestjs/common';
import { Request } from 'express';

@Controller('cats')
export class CatsController {
  @Get()
  findAll(@Req() request: Request): string {
    return 'This action returns all cats';
  }
}

GRPC

grpc logo aka pancakes

gRPC Remote Procedure Calls, of course!

gRPC is a modern, open source remote procedure call (RPC) framework that can run anywhere. It enables client and server applications to communicate transparently, and makes it easier to build connected systems

microservices graph

Architecture

// http://protobuf-compiler.herokuapp.com/
syntax = "proto3";

package hello;

service HelloService {
  rpc JustHello (HelloRequest) returns (HelloResponse);

  rpc ServerStream(HelloRequest) returns (stream HelloResponse);

  rpc ClientStream(stream HelloRequest) returns (HelloResponse);

  rpc BothStreams(stream HelloRequest) returns (stream HelloResponse);
}

message HelloRequest {
  string greeting = 1;
}

message HelloResponse {
  string reply = 1;
}

client server communication

Protocol Buffers

An efficient technology to serialize structured data

message Person {
  string name = 1;
  int32 id = 2;
  bool has_ponycopter = 3;
  // rule type name tag
  repeated uint64 vals = 4;
}
syntax = "proto3";

package hello;

service HelloService {
  rpc SayHello (HelloRequest) returns (HelloResponse);
}

message HelloRequest {
  string greeting = 1;
}

message HelloResponse {
  string reply = 1;
}

Other

A way to decompose

Melvin E. Conway’s law, 1967

Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.

Application

Monolith

Application developed and deployed as a single unit which can sustain consistent state

Simple to develop, test, deploy, and scale linearly all together!

Slow & difficult to

Microservices

An architectural pattern, affects an organization, process, and result!

Microservice org benefits

Application as a set of services that are

Fast & easy to

Goals, Principles, Requirements

Architecture Patterns

event sourcing

Strangler Application

fig strangler concept

how microservices ecosystem growths with strangler application

Thanks to Chris Richardson and Martin Fowler again!

DDD

A domain-way application’s decomposition by clean architecture

clean architecture

Domain is a core!

Good for mid-size or big systems with complex business logic

Anti Patterns

Algorithm

Make the most of the monolith

Mind new features as separate services

Success is improved velocity and reliability

Return on Investment (ROI)

Begin with the end in mind

Summary

Feedback

Please share your feedback on our workshop. Thank you and have a great coding!

If you like the workshop, you can become our patron, yay! 🙏

Technologies

microservices node.js javascript architecture ddd protobuf grpc typescript turborepo npm yarn docker git banking