惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
美团技术团队
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
L
LangChain Blog
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
腾讯CDC
Recent Announcements
Recent Announcements
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
博客园 - Franky
博客园 - 司徒正美
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
C
Check Point Blog
小众软件
小众软件
V
Visual Studio Blog
V
V2EX
F
Full Disclosure
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
罗磊的独立博客
人人都是产品经理
人人都是产品经理
量子位
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
博客园_首页
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
Recorded Future
Recorded Future
G
Google Developers Blog
Vercel News
Vercel News
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
爱范儿
爱范儿
Jina AI
Jina AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Service Mesh vs API Gateway: The Only Guide You’ll Ever Need
Preecha · 2026-06-16 · via DEV Community

Modern microservice systems usually need two traffic-control layers: an API gateway for external client traffic and a service mesh for internal service-to-service traffic. The key implementation decision is not always “service mesh vs API gateway,” but where each one belongs in your architecture.

Try Apidog today

In this guide, you’ll compare API gateways and service meshes by traffic scope, responsibilities, deployment model, and operational use cases. You’ll also see practical configuration examples and how API design/testing tools like Apidog fit into either approach.

What Is Service Mesh vs API Gateway?

Before choosing a tool, separate the two traffic paths in your system:

  • North-south traffic: external clients calling internal services
  • East-west traffic: internal services calling other internal services

API gateways primarily manage north-south traffic. Service meshes primarily manage east-west traffic.

What Is an API Gateway?

An API gateway is the single entry point for client requests into your microservices system.

Use it to control how external consumers access your APIs.

Common API gateway responsibilities include:

  • Authentication and authorization
  • Request routing
  • Request aggregation
  • Rate limiting and throttling
  • Protocol translation, such as REST to gRPC
  • API versioning
  • Monitoring, logging, and analytics
  • Developer portal support

Typical flow:

Client / Mobile App / Partner
        |
        v
   API Gateway
        |
        v
 Internal Services

An API gateway is usually placed at the edge of your system before requests reach internal services.

What Is a Service Mesh?

A service mesh is an infrastructure layer for managing communication between internal services.

Instead of making every service implement networking concerns directly, a service mesh usually uses lightweight sidecar proxies to intercept service-to-service traffic.

Common service mesh responsibilities include:

  • Service discovery
  • Internal load balancing
  • Mutual TLS between services
  • Traffic splitting
  • Canary releases
  • A/B testing
  • Retries and timeouts
  • Circuit breaking
  • Distributed tracing
  • Per-service observability

Typical flow:

Service A  <-->  Sidecar Proxy  <-->  Sidecar Proxy  <-->  Service B

A service mesh is most useful when internal service communication becomes difficult to secure, observe, or control manually.

Why the Difference Matters

Choosing the wrong layer creates operational complexity.

Use the distinction to decide where to implement each concern:

  • Put external API security at the gateway.
  • Put internal mTLS in the mesh.
  • Put client-facing rate limits at the gateway.
  • Put service-to-service retries and timeouts in the mesh.
  • Put developer onboarding and API documentation near the gateway.
  • Put distributed tracing and internal traffic policy in the mesh.

Service Mesh vs API Gateway: Key Differences

Dimension API Gateway Service Mesh
Traffic scope North-south East-west
Primary users External clients, partners, frontend apps Internal services
Placement Network edge Inside the cluster/service runtime
Authentication API keys, OAuth, JWT Service identity, mTLS
Rate limiting Common Sometimes available
Request transformation Common Not a primary use case
Protocol translation Common Not a primary use case
Service discovery Basic Advanced
Load balancing Basic to moderate Advanced
Traffic splitting Limited to edge traffic Fine-grained internal traffic
Observability API-level analytics Per-service metrics and tracing
Resilience patterns Limited Retries, timeouts, circuit breaking
Developer portal Common Not applicable

Where They Overlap

API gateways and service meshes can both support:

  • Authentication and authorization
  • Routing
  • Load balancing
  • Observability
  • Traffic policy

The difference is the target boundary.

For example:

  • An API gateway may validate an external client’s JWT.
  • A service mesh may enforce mTLS between orders-service and payments-service.

They solve related problems at different layers.

When to Use an API Gateway

Use an API gateway when you need to expose services to external consumers.

Common cases:

  • Public APIs
  • Partner APIs
  • Mobile or web app backends
  • API monetization
  • Centralized authentication
  • API key management
  • Rate limiting
  • API documentation and onboarding
  • Request transformation or aggregation

Example architecture:

Mobile App
   |
   v
API Gateway
   |
   +--> users-service
   +--> orders-service
   +--> payments-service

A SaaS product exposing REST APIs to web and mobile clients would typically use an API gateway for authentication, versioning, routing, and usage analytics.

When to Use a Service Mesh

Use a service mesh when internal service communication needs stronger control.

Common cases:

  • Many microservices communicating inside Kubernetes
  • Service-to-service encryption
  • mTLS enforcement
  • Canary releases
  • Blue-green deployments
  • Fine-grained traffic splitting
  • Distributed tracing
  • Internal retries and timeouts
  • Circuit breaking

Example architecture:

orders-service
   |
   v
payments-service
   |
   v
billing-service

With a service mesh, these calls can be encrypted, traced, retried, and controlled without each application implementing that logic manually.

When to Use Both

In many production microservice architectures, you use both:

External Client
      |
      v
 API Gateway
      |
      v
 Internal Service A
      |
      v
 Service Mesh
      |
      v
 Internal Service B

A practical split looks like this:

Concern Use API Gateway Use Service Mesh
External authentication
API keys
OAuth/JWT validation for clients
Developer portal
External rate limiting
Internal mTLS
Service-to-service authorization
Internal retries
Circuit breaking
Canary traffic between services
Distributed tracing

This layered approach gives you edge-level control plus internal service reliability.

Practical Examples

Example 1: E-Commerce Platform

Use an API gateway for customer-facing endpoints:

  • Login
  • Checkout
  • Product search
  • Partner API access

Use a service mesh for internal calls between:

  • Inventory service
  • Payment service
  • Recommendation service
  • Order service

Implementation split:

Customer
   |
   v
API Gateway
   |
   +--> checkout-service
            |
            v
       Service Mesh
            |
            +--> inventory-service
            +--> payment-service
            +--> recommendation-service

Example 2: API Monetization

Use an API gateway for:

  • Developer portal
  • API key management
  • Usage tracking
  • Billing integration
  • Client-level quotas

Use a service mesh for:

  • Secure billing-service communication
  • Internal analytics calls
  • Resilient core service communication

Example 3: Canary Deployments

Use an API gateway to route some external traffic to a new API version.

Use a service mesh to manage more granular internal rollout behavior.

Example:

API Gateway:
  90% traffic -> v1 API
  10% traffic -> v2 API

Service Mesh:
  checkout-service -> payment-service-v1: 95%
  checkout-service -> payment-service-v2: 5%

Example 4: Protocol Translation

Use an API gateway when external clients need one protocol but internal services use another.

Example:

External REST request
        |
        v
API Gateway
        |
        v
Internal gRPC service

The service mesh can still secure and observe internal gRPC traffic, but protocol translation is typically handled by the gateway.

API Gateway Configuration Example

Here is a simplified Kong-style configuration for rate limiting and API key authentication.

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: rate-limited-api
route:
  strip_path: true
  protocols:
    - https
plugin:
  - name: rate-limiting
    config:
      minute: 100
      policy: redis
  - name: key-auth
    config:
      key_names:
        - x-api-key

This type of policy belongs at the API gateway because it protects external-facing APIs from unauthorized or excessive client traffic.

Service Mesh Configuration Example

Here is a simplified Istio VirtualService for internal routing and retries.

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: reviews-routing
spec:
  hosts:
    - reviews
  http:
    - match:
        - sourceLabels:
            app: productpage
      route:
        - destination:
            host: reviews
            subset: v2
      retries:
        attempts: 3
        perTryTimeout: 2s
        retryOn: 5xx

This policy belongs in the service mesh because it controls internal service-to-service behavior.

Implementation Checklist

Use this checklist when deciding what to deploy.

Start With an API Gateway If You Need To

  • Expose APIs to public clients
  • Authenticate external consumers
  • Manage API keys
  • Enforce client quotas
  • Apply rate limits
  • Publish API documentation
  • Support API versioning
  • Transform requests or responses
  • Translate protocols

Add a Service Mesh If You Need To

  • Encrypt service-to-service traffic
  • Enforce internal service identity
  • Add retries and timeouts consistently
  • Use circuit breaking
  • Perform canary releases between services
  • Capture distributed traces
  • Improve internal traffic observability
  • Manage many microservices at scale

Use Both If You Need Layered Control

A common production setup:

Client
  -> API Gateway
  -> Kubernetes Service
  -> Service Mesh Sidecar
  -> Internal Microservice

In this model:

  • The gateway manages external API access.
  • The mesh manages internal service reliability and security.

Best Practices

Do Not Use a Service Mesh as a Full API Gateway

A service mesh is not designed for external API management features such as:

  • Developer portals
  • API key onboarding
  • Client-facing API documentation
  • Protocol mediation for external consumers
  • API monetization workflows

Do Not Overload the API Gateway

Some gateways provide mesh-like capabilities, but avoid using the gateway as the main control plane for all internal traffic at scale.

Internal service communication often needs:

  • Service identity
  • mTLS
  • Per-hop retries
  • Per-service metrics
  • Fine-grained traffic splitting

Those are service mesh concerns.

Apply Security at Both Layers

Use layered security:

External client security:
  API Gateway

Internal service security:
  Service Mesh

For example:

  • Validate external JWTs at the gateway.
  • Enforce mTLS between internal services with the mesh.

Design APIs Before Deploying Traffic Policies

Before configuring a gateway or mesh, define:

  • API contracts
  • Request/response schemas
  • Error formats
  • Versioning rules
  • Authentication requirements
  • Test cases

This keeps implementation consistent across gateway-managed APIs and mesh-managed service calls.

Where Apidog Fits

Whether you use an API gateway, service mesh, or both, Apidog can support the API lifecycle around that architecture.

Use Apidog for:

  • API design and documentation
  • Mocking client-to-service calls
  • Testing service-to-service APIs
  • Managing API versions
  • Collaborating across backend, frontend, and QA teams

For an API gateway workflow, you can design and document APIs before exposing them through the gateway.

For a service mesh workflow, you can model and test internal service contracts before deploying traffic policies such as retries, timeouts, and canary routing.

Conclusion

API gateways and service meshes solve different parts of the microservices networking problem.

Use an API gateway for external API access, authentication, rate limiting, documentation, and protocol handling.

Use a service mesh for internal service communication, mTLS, retries, traffic splitting, and deep observability.

In many modern systems, the best implementation is both: an API gateway at the edge and a service mesh inside the cluster.