Scripts2026年4月15日·1 分钟阅读

Nacos — Dynamic Service Discovery & Config Management

Open source service discovery, configuration, and service management platform for cloud native and microservices applications.

Introduction

Nacos (Naming And Configuration Service) is an Alibaba-incubated, Apache 2.0 platform combining service registry, dynamic configuration, and service management. It targets the same problems as Eureka, Consul, and Spring Cloud Config, but bundles them into a single server with one console and one SDK.

What Nacos Does

  • Service registry with heartbeat-based health checks for REST/RPC services.
  • Dynamic configuration with hot-reload, namespaces, groups, and versioning.
  • DNS-based and RPC-based service discovery, pluggable load balancing.
  • Multi-datacenter replication and CP/AP consistency modes via Raft or Distro.
  • First-class support for Spring Cloud, Dubbo, gRPC, and Kubernetes.

Architecture Overview

Nacos runs one Java process that exposes an HTTP/gRPC API (port 8848 + 9848). It stores metadata in an embedded Derby or an external MySQL for HA. The naming subsystem uses the Distro protocol (AP) by default for ephemeral instances, and JRaft (CP) for persistent ones; the config subsystem snapshots data to disk and notifies subscribers over long-polling or gRPC streams.

Self-Hosting & Configuration

  • Standalone mode: one container, Derby storage, good for dev and small clusters.
  • Cluster mode: 3+ nodes behind a VIP with MySQL 8 as the shared datastore.
  • Authentication: set nacos.core.auth.enabled=true and configure JWT secret.
  • Namespaces isolate tenants; groups isolate applications within a namespace.
  • Helm chart nacos/nacos deploys a StatefulSet with readiness probes.

Key Features

  • One binary for both discovery and config — no two services to run.
  • Push-based config updates: clients see changes in under a second.
  • Listens for Kubernetes Service changes and mirrors them to the registry.
  • Weight and metadata driven traffic shaping without a service mesh.
  • MCP gateway plugin exposes services as Model Context Protocol tools.

Comparison with Similar Tools

  • Consul — comparable discovery, stronger KV and ACL model, but no built-in Spring Cloud story.
  • Eureka — simpler AP-only registry, no config component, now in maintenance.
  • etcd — lower-level KV, you build discovery yourself.
  • Spring Cloud Config — git-backed config only, no registry.
  • Zookeeper — classic coordination primitive, no HTTP console.

FAQ

Q: Is Nacos production-ready outside the JVM world? A: Yes — it ships SDKs for Go, Python, Node.js, C#, and Rust, all speaking the same gRPC API.

Q: CP or AP? A: Ephemeral instances default to AP (Distro); persistent ones use CP (JRaft). You pick per-service.

Q: How do I migrate from Eureka? A: Enable the Eureka protocol adapter on the Nacos server and point clients at the Nacos address.

Q: Does it replace a service mesh? A: No — Nacos handles discovery and config; mTLS, retries, and traffic splitting still need Istio or similar.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产