MCPcopy Index your code
hub / github.com/apache/shenyu

github.com/apache/shenyu @v2.7.0.3

repository ↗ · DeepWiki ↗ · release v2.7.0.3 ↗ · Ask this repo → · + Follow
24,746 symbols 110,240 edges 3,158 files 14,409 documented · 58% updated todayv2.7.0.3 · 2025-11-26★ 8,802171 open issues
README

Light Logo Dark Logo

Scalable, High Performance, Responsive API Gateway Solution for all MicroServices

https://shenyu.apache.org/

EN docs 简体中文文档

<a target="_blank" href="https://search.maven.org/search?q=g:org.apache.shenyu%20AND%20a:shenyu">
    <img src="https://img.shields.io/maven-central/v/org.apache.shenyu/shenyu.svg?label=maven%20central" />
</a>
<a target="_blank" href="https://github.com/apache/shenyu/blob/master/LICENSE">
    <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?label=license" />
</a>
<a target="_blank" href="https://www.oracle.com/technetwork/java/javase/downloads/index.html">
    <img src="https://img.shields.io/badge/JDK-17+-green.svg" />
</a>
<a target="_blank" href="https://github.com/apache/shenyu/actions">
    <img src="https://github.com/apache/shenyu/workflows/ci/badge.svg" />
</a>

github forks github stars github contributors Docker Pulls Ask DeepWiki


Architecture


Why named Apache ShenYu

ShenYu (神禹) is the honorific name of Chinese ancient monarch Xia Yu (also known in later times as Da Yu), who left behind the touching story of the three times he crossed the Yellow River for the benefit of the people and successfully managed the flooding of the river. He is known as one of the three greatest kings of ancient China, along with Yao and Shun.

  • Firstly, the name ShenYu is to promote the traditional virtues of our Chinese civilisation.

  • Secondly, the most important thing about the gateway is the governance of the traffic.

  • Finally, the community will do things in a fair, just, open and meritocratic way, paying tribute to ShenYu while also conforming to the Apache Way.


Features

  • Proxy: Support for Apache® Dubbo™, Spring Cloud, gRPC, Motan, SOFA, TARS, WebSocket, MQTT
  • Security: Sign, OAuth 2.0, JSON Web Tokens, WAF plugin
  • API governance: Request, response, parameter mapping, Hystrix, RateLimiter plugin
  • Observability: Tracing, metrics, logging plugin
  • Dashboard: Dynamic traffic control, visual backend for user menu permissions
  • Extensions: Plugin hot-swapping, dynamic loading
  • Cluster: NGINX, Docker, Kubernetes
  • Language: provides .NET, Python, Go, Java client for API register

Quick Start (docker)

Create network for Shenyu

> docker network create shenyu

Run Apache ShenYu Admin

> docker pull apache/shenyu-admin
> docker run -d --name shenyu-admin-quickstart -p 9095:9095 --net shenyu apache/shenyu-admin

Run Apache ShenYu Bootstrap

> docker pull apache/shenyu-bootstrap
> docker run -d --name shenyu-quickstart -p 9195:9195 -e "shenyu.local.enabled=true" -e SHENYU_SYNC_WEBSOCKET_URLS=ws://shenyu-admin-quickstart:9095/websocket --net shenyu apache/shenyu-bootstrap

Set router

  • Real request :http://127.0.0.1:8080/helloworld,
{
  "name" : "Shenyu",
  "data" : "hello world"
}
  • Set routing rules (Standalone)

Add localKey: 123456 to Headers. If you need to customize the localKey, you can use the sha512 tool to generate the key based on plaintext and update the shenyu.local.sha512Key property.

curl --location --request POST 'http://localhost:9195/shenyu/plugin/selectorAndRules' \
--header 'Content-Type: application/json' \
--header 'localKey: 123456' \
--data-raw '{
    "pluginName": "divide",
    "selectorHandler": "[{\"upstreamUrl\":\"127.0.0.1:8080\"}]",
    "conditionDataList": [{
        "paramType": "uri",
        "operator": "match",
        "paramValue": "/**"
    }],
    "ruleDataList": [{
        "ruleHandler": "{\"loadBalance\":\"random\"}",
        "conditionDataList": [{
            "paramType": "uri",
            "operator": "match",
            "paramValue": "/**"
        }]
    }]
}'

If the backend service handling the request is running on your host machine, please set upstreamUrl to host.docker.internal:8080 or specify IP address if reachable from the container in the above command.

Add --network host to docker run command instead of --net shenyu also works correctly. * Proxy request :http://localhost:9195/helloworld

{
  "name" : "Shenyu",
  "data" : "hello world"
}

Plugin

Whenever a request comes in, Apache ShenYu will execute it by all enabled plugins through the chain of responsibility.

As the heart of Apache ShenYu, plugins are extensible and hot-pluggable.

Different plugins do different things.

Of course, users can also customize plugins to meet their own needs.

If you want to customize, see custom-plugin .


Selector & Rule

According to your HTTP request headers, selectors and rules are used to route your requests.

Selector is your first route, It is coarser grained, for example, at the module level.

Rule is your second route and what do you think your request should do. For example a method level in a module.

The selector and the rule match only once, and the match is returned. So the coarsest granularity should be sorted last.


Data Caching & Data Sync

Since all data have been cached using ConcurrentHashMap in the JVM, it's very fast.

Apache ShenYu dynamically updates the cache by listening to the ZooKeeper node (or WebSocket push, HTTP long polling) when the user changes configuration information in the background management.


Prerequisite

  • JDK 17+

Stargazers over time

Stargazers over time


Contributor and Support


Known Users

In order of registration, More access companies are welcome to register at https://github.com/apache/shenyu/issues/68 (For open source users only) .

All Users : Known Users

Extension points exported contracts — how you extend this code

FallbackFactory (Interface)
Used to control the fallback given its cause. Ex. {@code // This instance will be invoked if there are errors of [39 implementers]
shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/FallbackFactory.java
ShenyuSdkRequestInterceptor (Interface)
ShenyuSdkRequestInterceptor. For example: public void apply(ShenyuRequest shenyuRequest){ shenyu [6 implementers]
shenyu-sdk/shenyu-sdk-core/src/main/java/org/apache/shenyu/sdk/core/interceptor/ShenyuSdkRequestInterceptor.java
DubboTestService (Interface)
DubboTestService. [10 implementers]
shenyu-examples/shenyu-examples-dubbo/shenyu-examples-dubbo-api/src/main/java/org/apache/shenyu/examples/dubbo/api/service/DubboTestService.java
SofaClientSingleParamService (Interface)
Sofa single parameter service. [11 implementers]
shenyu-examples/shenyu-examples-sofa/shenyu-examples-sofa-api/src/main/java/org/apache/shenyu/examples/sofa/api/service/SofaClientSingleParamService.java
DataTypeParent (Interface)
The interface Data type parent. [61 implementers]
shenyu-register-center/shenyu-register-common/src/main/java/org/apache/shenyu/register/common/type/DataTypeParent.java
SyncDataService (Interface)
The interface Sync data service. [7 implementers]
shenyu-sync-data-center/shenyu-sync-data-api/src/main/java/org/apache/shenyu/sync/data/api/SyncDataService.java
DataRefresh (Interface)
The interface Data refresh. [9 implementers]
shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/refresh/DataRefresh.java
DataHandler (Interface)
The interface Data handler. [30 implementers]
shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DataHandler.java

Core symbols most depended-on inside this repo

n
called by 8220
shenyu-admin/src/main/resources/static/index.a6d776d6.js
r
called by 3266
shenyu-admin/src/main/resources/static/index.a6d776d6.js
o
called by 2533
shenyu-admin/src/main/resources/static/index.a6d776d6.js
call
called by 1869
shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/controller/RestControllerAspect.java
i
called by 1721
shenyu-admin/src/main/resources/static/index.a6d776d6.js
build
called by 1707
shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/context/ShenyuContextBuilder.java
get
called by 1404
shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/cache/SelectorCache.java
a
called by 1296
shenyu-admin/src/main/resources/static/index.a6d776d6.js

Shape

Method 20,580
Class 3,174
Function 622
Interface 282
Enum 88

Languages

Java97%
TypeScript2%
Python1%

Modules by API surface

shenyu-admin/src/main/resources/static/index.a6d776d6.js615 symbols
shenyu-common/src/main/java/org/apache/shenyu/common/config/ShenyuConfig.java212 symbols
shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/config/HttpClientProperties.java95 symbols
shenyu-register-center/shenyu-register-common/src/main/java/org/apache/shenyu/register/common/dto/ApiDocRegisterDTO.java71 symbols
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/ApiVO.java68 symbols
shenyu-register-center/shenyu-register-common/src/main/java/org/apache/shenyu/register/common/dto/MetaDataRegisterDTO.java64 symbols
shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/RequestHandle.java64 symbols
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/PermissionMenuVO.java63 symbols
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-rabbitmq/src/main/java/org/apache/shenyu/plugin/logging/rabbitmq/config/RabbitmqLogCollectConfig.java62 symbols
shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java61 symbols
shenyu-alert/src/main/java/org/apache/shenyu/alert/model/AlertReceiverDTO.java57 symbols
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/ApiDO.java57 symbols

Dependencies from manifests, versioned

ch.qos.logback:logback-classic
co.elastic.clients:elasticsearch-java
com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery
com.alibaba.csp:sentinel-core
com.alibaba.csp:sentinel-reactor-adapter
com.alibaba.csp:sentinel-spring-webflux-adapter
com.alibaba.nacos:nacos-client2.0.4 · 1×
com.alipay.sofa.common:sofa-common-tools
com.alipay.sofa:actuator-sofa-boot-starter
com.alipay.sofa:rpc-sofa-boot-starter
com.alipay.sofa:runtime-sofa-boot-starter
com.alipay.sofa:sofa-rpc-all

Datastores touched

(mysql)Database · 1 repos
shenyuDatabase · 1 repos
shenyuDatabase · 1 repos

For agents

$ claude mcp add shenyu \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact