Skip to content

Commit

Permalink
Merge 11236db into a617999
Browse files Browse the repository at this point in the history
  • Loading branch information
Miss-you committed Jul 21, 2020
2 parents a617999 + 11236db commit f8ad192
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 44 deletions.
38 changes: 29 additions & 9 deletions FAQ_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

微服务领域对 API 网关有新的需求:更高的灵活性、更高的性能要求,以及云原生的贴合。


## APISIX 和其他的 API 网关有什么不同之处?

APISIX 基于 etcd 来完成配置的保存和同步,而不是 postgres 或者 MySQL 这类关系型数据库。
Expand Down Expand Up @@ -57,7 +56,7 @@ APISIX 是当前性能最好的 API 网关,单核 QPS 达到 2.3 万,平均
4. 变化通知
5. 高性能

APISIX 需要一个配置中心,上面提到的很多功能是传统关系型数据库和KV数据库是无法提供的。与 etcd 同类软件还有 Consul、ZooKeeper等,更详细比较可以参考这里:[etcd why](https://github.com/etcd-io/etcd/blob/master/Documentation/learning/why.md#comparison-chart),在将来也许会支持其他配置存储方案。
APISIX 需要一个配置中心,上面提到的很多功能是传统关系型数据库和 KV 数据库是无法提供的。与 etcd 同类软件还有 Consul、ZooKeeper 等,更详细比较可以参考这里:[etcd why](https://github.com/etcd-io/etcd/blob/master/Documentation/learning/why.md#comparison-chart),在将来也许会支持其他配置存储方案。

## 为什么在用 Luarocks 安装 APISIX 依赖时会遇到超时,很慢或者不成功的情况?

Expand All @@ -77,8 +76,8 @@ luarocks 服务。 运行 `luarocks config rocks_servers` 命令(这个命令

比如,`foo.com/product/index.html?id=204&page=2`, 根据 uri 中 query string 中的 `id` 作为条件来灰度发布:

1. A组:id <= 1000
2. B组:id > 1000
1. A 组:id <= 1000
2. B 组:id > 1000

可以这么做:

Expand Down Expand Up @@ -110,7 +109,6 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: edd1c9f034335
}'
```


更多的 lua-resty-radixtree 匹配操作,可查看操作列表:
https://github.com/iresty/lua-resty-radixtree#operator-list

Expand Down Expand Up @@ -197,15 +195,15 @@ Server: APISIX web server

## 如何修改日志等级

默认的APISIX日志等级为`warn`,如果需要查看`core.log.info`的打印结果需要将日志等级调整为`info`
默认的 APISIX 日志等级为`warn`,如果需要查看`core.log.info`的打印结果需要将日志等级调整为`info`

具体步骤:

1、修改conf/config.yaml中的nginx log配置参数`error_log_level: "warn"``error_log_level: "info"`
1、修改 conf/config.yaml 中的 nginx log 配置参数`error_log_level: "warn"``error_log_level: "info"`

2、重启APISIX
2、重启 APISIX

之后便可以在logs/error.log中查看到info的日志了
之后便可以在 logs/error.log 中查看到 info 的日志了

## 如何加载自己编写的插件

Expand All @@ -220,3 +218,25 @@ curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034
```shell
apisix reload
```

## 如何格式化中文文档?

中文文档对于格式有很多要求,比如英文单词前后要有空格` `,但每次手动修改都非常繁琐,有没有省时省力的办法解决这个问题?

推荐使用 vscode 的 pangu 插件

**安装方式**

进入 vscode 插件列表,搜索`pangu`,安装`Pangu-Markdown`插件

![pangu](doc/images/pangu-plugin-1.png)

**使用方式**

进入 vscode 命令行模式,选择 `Pangu Format`

![pangu](doc/images/pangu-plugin-2.png)

**注意**

不建议选用 pangu 这个名字的插件,它对 `**` 这种加粗字符支持不友好
68 changes: 33 additions & 35 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/apache/incubator-apisix/blob/master/LICENSE)

- **QQ 交流群**: 552030619
- 邮件列表: 发邮件到 dev-subscribe@apisix.apache.org, 然后跟着回复邮件操作即可。
- 邮件列表发邮件到 dev-subscribe@apisix.apache.org, 然后跟着回复邮件操作即可。
- ![Twitter Follow](https://img.shields.io/twitter/follow/ApacheAPISIX?style=social)

## Apache APISIX 是什么?
Expand All @@ -38,14 +38,13 @@ Apache APISIX 的技术架构如下图所示:

![](doc/images/apisix.png)


## 功能
你可以把 Apache APISIX 当做流量入口,来处理所有的业务数据,包括动态路由、动态上游、动态证书、
A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵御恶意攻击、监控报警、服务可观测性、服务治理等。
A/B 测试、金丝雀发布灰度发布、蓝绿部署、限流限速、抵御恶意攻击、监控报警、服务可观测性、服务治理等。

- **全平台**
- 云原生: 平台无关,没有供应商锁定,无论裸机还是 Kubernetes,APISIX 都可以运行。
- 运行环境: OpenResty 和 Tengine 都支持。
- 云原生平台无关,没有供应商锁定,无论裸机还是 Kubernetes,APISIX 都可以运行。
- 运行环境OpenResty 和 Tengine 都支持。
- 支持 ARM64: 不用担心底层技术的锁定。

- **多协议**
Expand All @@ -67,37 +66,37 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
- 动态负载均衡:动态支持有权重的 round-robin 负载平衡。
- 支持一致性 hash 的负载均衡:动态支持一致性 hash 的负载均衡。
- [健康检查](doc/health-check.md):启用上游节点的健康检查,将在负载均衡期间自动过滤不健康的节点,以确保系统稳定性。
- 熔断器: 智能跟踪不健康上游服务。
- 熔断器智能跟踪不健康上游服务。
- [代理镜像](doc/zh-cn/plugins/proxy-mirror.md): 提供镜像客户端请求的能力。

- **精细化路由**
- [支持全路径匹配和前缀匹配](doc/router-radixtree.md#how-to-use-libradixtree-in-apisix)
- [支持使用 Nginx 所有内置变量做为路由的条件](/doc/router-radixtree.md#how-to-filter-route-by-nginx-builtin-variable),所以你可以使用 `cookie`, `args` 等做为路由的条件,来实现灰度发布、A/B 测试等功能
- 支持[各类操作符做为路由的判断条件](https://github.com/iresty/lua-resty-radixtree#operator-list),比如 `{"arg_age", ">", 24}`
- 支持[自定义路由匹配函数](https://github.com/iresty/lua-resty-radixtree/blob/master/t/filter-fun.t#L10)
- 支持 [各类操作符做为路由的判断条件](https://github.com/iresty/lua-resty-radixtree#operator-list),比如 `{"arg_age", ">", 24}`
- 支持 [自定义路由匹配函数](https://github.com/iresty/lua-resty-radixtree/blob/master/t/filter-fun.t#L10)
- IPv6:支持使用 IPv6 格式匹配路由
- 支持路由的[自动过期(TTL)](doc/zh-cn/admin-api.md#route)
- 支持路由的 [自动过期 (TTL)](doc/zh-cn/admin-api.md#route)
- [支持路由的优先级](doc/router-radixtree.md#3-match-priority)
- [支持批量 Http 请求](doc/zh-cn/plugins/batch-requests.md)

- **安全防护**
- 多种身份认证方式: [key-auth](doc/zh-cn/plugins/key-auth.md), [JWT](doc/zh-cn/plugins/jwt-auth.md), [basic-auth](doc/zh-cn/plugins/basic-auth.md), [wolf-rbac](doc/zh-cn/plugins/wolf-rbac.md)
- 多种身份认证方式[key-auth](doc/zh-cn/plugins/key-auth.md), [JWT](doc/zh-cn/plugins/jwt-auth.md), [basic-auth](doc/zh-cn/plugins/basic-auth.md), [wolf-rbac](doc/zh-cn/plugins/wolf-rbac.md)
- [IP 黑白名单](doc/zh-cn/plugins/ip-restriction.md)
- [IdP 支持](doc/plugins/oauth.md): 支持外部的身份认证服务,比如 Auth0,Okta,Authing 等,用户可以借此来对接 Oauth2.0 等认证方式。
- [限制速率](doc/zh-cn/plugins/limit-req.md)
- [限制请求数](doc/zh-cn/plugins/limit-count.md)
- [限制并发](doc/zh-cn/plugins/limit-conn.md)
- 防御 ReDoS(正则表达式拒绝服务):内置策略,无需配置即可抵御 ReDoS。
- [CORS](doc/zh-cn/plugins/cors.md)为你的API启用 CORS。
- 防御 ReDoS正则表达式拒绝服务:内置策略,无需配置即可抵御 ReDoS。
- [CORS](doc/zh-cn/plugins/cors.md)为你的 API 启用 CORS。
- [uri-blocker](plugins/uri-blocker.md):根据 URI 拦截用户请求。

- **运维友好**
- OpenTracing 可观测性: 支持 [Apache Skywalking](doc/zh-cn/plugins/skywalking.md)[Zipkin](doc/zh-cn/plugins/zipkin.md)
- OpenTracing 可观测性支持 [Apache Skywalking](doc/zh-cn/plugins/skywalking.md)[Zipkin](doc/zh-cn/plugins/zipkin.md)
- 对接外部服务发现:除了内置的 etcd 外,还支持 `Consul``Nacos`[DNS 发现模式](https://github.com/apache/incubator-apisix/issues/1731#issuecomment-646392129),以及 [Eureka](doc/zh-cn/discovery.md)
- 监控和指标: [Prometheus](doc/zh-cn/plugins/prometheus.md)
- 监控和指标[Prometheus](doc/zh-cn/plugins/prometheus.md)
- 集群:APISIX 节点是无状态的,创建配置中心集群请参考 [etcd Clustering Guide](https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/clustering.md)
- 高可用:支持配置同一个集群内的多个 etcd 地址。
- 控制台: 内置控制台来操作 APISIX 集群。
- 控制台内置控制台来操作 APISIX 集群。
- 版本控制:支持操作的多次回滚。
- CLI: 使用命令行来启动、关闭和重启 APISIX。
- [单机模式](doc/zh-cn/stand-alone.md): 支持从本地配置文件中加载路由规则,在 kubernetes(k8s) 等环境下更友好。
Expand All @@ -110,17 +109,17 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
- **高度可扩展**
- [自定义插件](doc/zh-cn/plugin-develop.md): 允许挂载常见阶段,例如`init`, `rewrite``access``balancer`,`header filer``body filter``log` 阶段。
- 自定义负载均衡算法:可以在 `balancer` 阶段使用自定义负载均衡算法。
- 自定义路由: 支持用户自己实现路由算法。
- 自定义路由支持用户自己实现路由算法。

## 编译和安装

APISIX 在以下操作系统中可顺利安装并做过测试:

CentOS 7, Ubuntu 16.04, Ubuntu 18.04, Debian 9, Debian 10, macOS, **ARM64** Ubuntu 18.04

有以下几种方式来安装 APISIX 的 Apache Release 版本:
有以下几种方式来安装 APISIX 的 Apache Release 版本
1. 源码编译(适用所有系统)
- 安装运行时依赖:OpenResty 和 etcd,以及编译的依赖:luarocks。参考[依赖安装文档](doc/zh-cn/install-dependencies.md)
- 安装运行时依赖:OpenResty 和 etcd,以及编译的依赖:luarocks。参考 [依赖安装文档](doc/zh-cn/install-dependencies.md)
- 下载最新的源码发布包:
```shell
wget http://www.apache.org/dist/incubator/apisix/1.4/apache-apisix-1.4-incubating-src.tar.gz
Expand All @@ -135,7 +134,7 @@ CentOS 7, Ubuntu 16.04, Ubuntu 18.04, Debian 9, Debian 10, macOS, **ARM64** Ubun
```shell
./bin/apisix version
```
- 启动 APISIX (请先确保已经启动了 etcd,并打开了 v2 协议):
- 启动 APISIX 请先确保已经启动了 etcd,并打开了 v2 协议:
```shell
./bin/apisix start
```
Expand All @@ -147,10 +146,10 @@ CentOS 7, Ubuntu 16.04, Ubuntu 18.04, Debian 9, Debian 10, macOS, **ARM64** Ubun
docker pull apache/apisix
```

Docker 镜像中并不包含 etcd,你可以参考 [docker compose 的示例](https://github.com/apache/incubator-apisix-docker/tree/master/example)来启动一个测试集群。
Docker 镜像中并不包含 etcd,你可以参考 [docker compose 的示例](https://github.com/apache/incubator-apisix-docker/tree/master/example) 来启动一个测试集群。

3. RPM 包(只适用于 CentOS 7)
- 安装依赖:OpenResty 和 etcd,参考[依赖安装文档](doc/zh-cn/install-dependencies.md#centos-7)
- 安装依赖:OpenResty 和 etcd,参考 [依赖安装文档](doc/zh-cn/install-dependencies.md#centos-7)
- 安装 APISIX:
```shell
sudo yum install -y https://github.com/apache/incubator-apisix/releases/download/1.4/apisix-1.4-0.el7.noarch.rpm
Expand All @@ -159,7 +158,7 @@ CentOS 7, Ubuntu 16.04, Ubuntu 18.04, Debian 9, Debian 10, macOS, **ARM64** Ubun
```shell
apisix version
```
- 启动 APISIX (请先确保已经启动了 etcd,并打开了 v2 协议):
- 启动 APISIX 请先确保已经启动了 etcd,并打开了 v2 协议:
```shell
apisix start
```
Expand Down Expand Up @@ -190,17 +189,17 @@ etcd --enable-v2=true &

2. 入门指南

入门指南是学习 APISIX 基础知识的好方法。按照 [入门指南](doc/zh-cn/getting-started.md)的步骤即可。
入门指南是学习 APISIX 基础知识的好方法。按照 [入门指南](doc/zh-cn/getting-started.md) 的步骤即可。

更进一步,你可以跟着文档来尝试更多的[插件](doc/zh-cn/README.md#插件)
更进一步,你可以跟着文档来尝试更多的 [插件](doc/zh-cn/README.md#插件)

3. Admin API

Apache APISIX 提供了 [REST Admin API](doc/zh-cn/admin-api.md),方便动态控制 Apache APISIX 集群。

4. 插件二次开发

可以参考[插件开发指南](doc/zh-cn/plugin-develop.md),以及[示例插件 echo](doc/zh-cn/plugins/echo.md) 的文档和代码实现。
可以参考 [插件开发指南](doc/zh-cn/plugin-develop.md),以及 [示例插件 echo](doc/zh-cn/plugins/echo.md) 的文档和代码实现。

请注意,Apache APISIX 的插件新增、更新、删除等都是热加载的,不用重启服务。

Expand All @@ -217,8 +216,7 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.

使用 AWS 的 8 核心服务器来压测 APISIX,QPS 可以达到 140000,同时延时只有 0.2 毫秒。

[性能测试脚本](benchmark/run.sh),以及[测试方法和过程](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)已经开源,欢迎补充。

[性能测试脚本](benchmark/run.sh),以及 [测试方法和过程](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01) 已经开源,欢迎补充。

## Apache APISIX 和 Kong 的比较

Expand All @@ -229,7 +227,7 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
| **动态上游** | 支持 | 支持 |
| **动态路由** | 支持 | 支持 |
| **健康检查和熔断器** | 支持 | 支持 |
| **动态SSL证书** | 支持 | 支持 |
| **动态 SSL 证书** | 支持 | 支持 |
| **七层和四层代理** | 支持 | 支持 |
| **分布式追踪** | 支持 | 支持 |
| **自定义插件** | 支持 | 支持 |
Expand All @@ -242,8 +240,8 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
|:----|:----|:----|
| 项目归属 | Apache 软件基金会 | Kong Inc. |
| 技术架构 | Nginx + etcd | Nginx + postgres |
| 交流渠道 | 微信群、QQ群、邮件列表、Github、meetup | Github、论坛、freenode |
| 单核 QPS (开启限流和prometheus插件) | 18000 | 1700 |
| 交流渠道 | 微信群、QQ 群、邮件列表、Github、meetup | Github、论坛、freenode |
| 单核 QPS (开启限流和 prometheus 插件) | 18000 | 1700 |
| 平均延迟 | 0.2 毫秒 | 2 毫秒 |
| 支持 Dubbo 代理 |||
| 配置回滚 |||
Expand All @@ -253,14 +251,14 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
| resty <--> gRPC 转码 |||
| 支持 Tengine 作为运行时 |||
| MQTT 协议支持 |||
| 配置生效时间 | 事件通知,低于1毫秒更新 | 定期轮询,5 秒 |
| 配置生效时间 | 事件通知,低于 1 毫秒更新 | 定期轮询,5 秒 |
| 自带控制台 |||
| 对接外部身份认证服务 |||
| 配置中心高可用(HA) |||
| 配置中心高可用 (HA) |||
| 指定时间窗口的限速 |||
| 支持任何 Nginx 变量做路由条件 |||

性能对比测试[详细内容如下](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)
性能对比测试 [详细内容如下](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)

## 视频和文章
- 2020.1.17 [API 网关 Apache APISIX 和 Kong 的选型对比](https://mp.weixin.qq.com/s/c51apneVj0O9yxiZAHF34Q)
Expand All @@ -269,7 +267,7 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
- 2019.10.30 [Apache APISIX 微服务架构极致性能架构解析](https://www.upyun.com/opentalk/440.html)
- 2019.9.27 [想把 APISIX 运行在 ARM64 平台上?只要三步](https://zhuanlan.zhihu.com/p/84467919)
- 2019.8.31 [APISIX 技术选型、测试和持续集成](https://www.upyun.com/opentalk/433.html)
- 2019.8.31 [APISIX 高性能实战2](https://www.upyun.com/opentalk/437.html)
- 2019.8.31 [APISIX 高性能实战 2](https://www.upyun.com/opentalk/437.html)
- 2019.7.6 [APISIX 高性能实战](https://www.upyun.com/opentalk/429.html)

## 用户实际使用案例
Expand All @@ -295,7 +293,7 @@ APISIX 被纳入 <a href="https://landscape.cncf.io/category=api-gateway&format=

## 参与社区

如果你对 APISIX 的开发和使用感兴趣,欢迎加入我们的 QQ 群来交流:
如果你对 APISIX 的开发和使用感兴趣,欢迎加入我们的 QQ 群来交流

<img src="doc/images/qq-group.png" width="302" height="302">

Expand Down
Binary file added doc/images/pangu-plugin-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/pangu-plugin-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f8ad192

Please sign in to comment.