This week’s system design refresher:
The 9 Algorithms That Dominate Our World
What does API gateway do?
How does gRPC work?
Docker vs. Kubernetes. Which one should we use?
How many API architecture styles do you know?
CI/CD Pipeline Explained
MVC, MVP, MVVM, VIPER Patterns
SPONSOR US
The 9 Algorithms That Dominate Our World
The diagram below shows the most commonly used algorithms in our daily lives. They are used in internet search engines, social networks, WiFi, cell phones, and even satellites.
Sorting
Dijkstra’s Algorithm
Transformers
Link Analysis
RSA Algorithm
Integer Factorization
Convolutional Neural Networks
Huffman Coding
Secure Hash Algorithm
Over to you: Are there any other commonly used algorithms we missed?
What does API gateway do?
The diagram below shows the detail.
Step 1 - The client sends an HTTP request to the API gateway.
Step 2 - The API gateway parses and validates the attributes in the HTTP request.
Step 3 - The API gateway performs allow-list/deny-list checks.
Step 4 - The API gateway talks to an identity provider for authentication and authorization.
Step 5 - The rate limiting rules are applied to the request. If it is over the limit, the request is rejected.
Steps 6 and 7 - Now that the request has passed basic checks, the API gateway finds the relevant service to route to by path matching.
Step 8 - The API gateway transforms the request into the appropriate protocol and sends it to backend microservices.
Steps 9-12: The API gateway can handle errors properly, and deals with faults if the error takes a longer time to recover (circuit break). It can also leverage ELK (Elastic-Logstash-Kibana) stack for logging and monitoring. We sometimes cache data in the API gateway.
Over to you:
What’s the difference between a load balancer and an API gateway?
Do we need to use different API gateways for PC, mobile and browser separately?
How does gRPC work?
RPC (Remote Procedure Call) is called “remote” because it enables communications between remote services when services are deployed to different servers under microservice architecture. From the user’s point of view, it acts like a local function call.
The diagram below illustrates the overall data flow for gRPC.
Step 1: A REST call is made from the client. The request body is usually in JSON format.
Steps 2 - 4: The order service (gRPC client) receives the REST call, transforms it, and makes an RPC call to the payment service. gPRC encodes the client stub into a binary format and sends it to the low-level transport layer.
Step 5: gRPC sends the packets over the network via HTTP2. Because of binary encoding and network optimizations, gRPC is said to be 5X faster than JSON.
Steps 6 - 8: The payment service (gRPC server) receives the packets from the network, decodes them, and invokes the server application.
Steps 9 - 11: The result is returned from the server application, and gets encoded and sent to the transport layer.
Steps 12 - 14: The order service receives the packets, decodes them, and sends the result to the client application.
Over to you: Have you used gPRC in your project? What are some of its limitations?
Docker vs. Kubernetes. Which one should we use?
What is Docker ?
Docker is an open-source platform that allows you to package, distribute, and run applications in isolated containers. It focuses on containerization, providing lightweight environments that encapsulate applications and their dependencies.
What is Kubernetes ?
Kubernetes, often referred to as K8s, is an open-source container orchestration platform. It provides a framework for automating the deployment, scaling, and management of containerized applications across a cluster of nodes.
How are both different from each other ?
Docker: Docker operates at the individual container level on a single operating system host.
You must manually manage each host and setting up networks, security policies, and storage for multiple related containers can be complex.
Kubernetes: Kubernetes operates at the cluster level. It manages multiple containerized applications across multiple hosts, providing automation for tasks like load balancing, scaling, and ensuring the desired state of applications.
In short, Docker focuses on containerization and running containers on individual hosts, while Kubernetes specializes in managing and orchestrating containers at scale across a cluster of hosts.
Over to you: What challenges prompted you to switch from Docker to Kubernetes for managing containerized applications?
How many API architecture styles do you know?
Architecture styles define how different components of an application programming interface (API) interact with one another. As a result, they ensure efficiency, reliability, and ease of integration with other systems by providing a standard approach to designing and building APIs. Here are the most used styles:
SOAP:
Mature, comprehensive, XML-based
Best for enterprise applicationsRESTful:
Popular, easy-to-implement, HTTP methods
Ideal for web servicesGraphQL:
Query language, request specific data
Reduces network overhead, faster responsesgRPC:
Modern, high-performance, Protocol Buffers
Suitable for microservices architecturesWebSocket:
Real-time, bidirectional, persistent connections
Perfect for low-latency data exchangeWebhook:
Event-driven, HTTP callbacks, asynchronous
Notifies systems when events occur
Over to you: Are there any other famous styles we missed?
CI/CD Pipeline Explained
A CI/CD pipeline is a tool that automates the process of building, testing, and deploying software.
It integrates the different stages of the software development lifecycle, including code creation and revision, testing, and deployment, into a single, cohesive workflow.
The diagram below illustrates some of the tools that are commonly used.
Over to you: which one have you used?
MVC, MVP, MVVM, VIPER Patterns
What distinguishes MVC, MVP, MVVM, MVVM-C, and VIPER architecture patterns from each other?
These architecture patterns are among the most commonly used in app development, whether on iOS or Android platforms. Developers have introduced them to overcome the limitations of earlier patterns. So, how do they differ?
MVC, the oldest pattern, dates back almost 50 years
Every pattern has a "view" (V) responsible for displaying content and receiving user input
Most patterns include a "model" (M) to manage business data
"Controller," "presenter," and "view-model" are translators that mediate between the view and the model ("entity" in the VIPER pattern)
These translators can be quite complex to write, so various patterns have been proposed to make them more maintainable
SPONSOR US
Get your product in front of more than 1,000,000 tech professionals.
Our newsletter puts your products and services directly in front of an audience that matters - hundreds of thousands of engineering leaders and senior engineers - who have influence over significant tech decisions and big purchases.
Space Fills Up Fast - Reserve Today
Ad spots typically sell out about 4 weeks in advance. To ensure your ad reaches this influential audience, reserve your space now by emailing sponsorship@bytebytego.com.
Comparing docker and kubernetes makes no sense. You don't switch from one to the other, they do entirely different things... You run docker containers in a cluster managed with kubernetes.
B+ Trees for Databases is definitely one.