ByteByteGo 01月05日
EP144: The 9 Algorithms That Dominate Our World
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文深入探讨了现代软件开发中至关重要的九大算法,如排序、Dijkstra算法、Transformer等,它们广泛应用于互联网搜索、社交网络和移动通信等领域。同时,文章还详细解析了API网关的作用,包括请求验证、身份验证、限流、路由和服务转换等关键步骤。此外,文章还介绍了gRPC的工作原理,强调其在微服务架构中的高性能优势。文章还对比了Docker和Kubernetes的区别,阐述了各自在容器化和容器编排方面的侧重点。最后,文章还概述了常见的API架构风格、CI/CD流程以及MVC等设计模式,为读者提供了全面的技术视角。

🧮 **九大核心算法**: 文章列举了排序、Dijkstra算法、Transformer等九种在日常生活中广泛应用的算法,它们是互联网、通信等领域的基础。

🚪 **API网关详解**: API网关负责接收客户端请求,进行验证、授权、限流,并将请求路由到后端微服务,同时处理错误和监控,是微服务架构的关键组件。

🚀 **gRPC高效通信**: gRPC使用二进制编码和HTTP2协议,实现了比JSON更高效的远程服务调用,适用于微服务架构。

🐳 **Docker与Kubernetes**: Docker专注于容器化,提供轻量级隔离环境;Kubernetes则专注于跨集群的容器编排、自动化部署和管理。

🏗️ **多种架构模式**: 文章介绍了SOAP、RESTful、GraphQL等多种API架构风格,以及MVC、MVP等软件设计模式,为开发者提供了丰富的选择。

This week’s system design refresher:


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:

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?


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.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

算法 API网关 gRPC Docker Kubernetes
相关文章