Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions _data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ t:
url: /docs/quick-start/
- title: "Develop microservice application in minutes"
url: /docs/quick-start-bmi/
- title: "Advance microservice development"
url: /docs/quick-start-advance/
children:
- title: Load balance
url: /docs/quick-start-advance/load-balance/
- title: Service Management
url: /docs/quick-start-advance/service-management/
- title: Distributed tracing
url: /docs/quick-start-advance/distributed-tracing/

users:
- title: "User Guide"
Expand Down Expand Up @@ -118,6 +127,15 @@ t:
url: /cn/docs/quick-start/
- title: "微服务应用快速开发"
url: /cn/docs/quick-start-bmi/
- title: "微服务开发进阶"
url: /cn/docs/quick-start-advance/
children:
- title: "负载均衡"
url: /cn/docs/quick-start-advance/load-balance/
- title: "服务治理"
url: /cn/docs/quick-start-advance/service-management/
- title: "分布式调用链追踪"
url: /cn/docs/quick-start-advance/distributed-tracing/

users:
- title: "用户手册"
Expand Down
80 changes: 80 additions & 0 deletions _docs/cn/distributed-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: "分布式调用链追踪"
lang: cn
ref: quick-start-distributed-tracing
permalink: /cn/docs/quick-start-advance/distributed-tracing/
excerpt: "介绍如何在体质指数应用中使用ServiceComb提供的分布式追踪能力"
last_modified_at: 2017-09-03T10:01:43-04:00
---

{% include toc %}
分布式调用链追踪用于有效地监控微服务的网络延时并可视化微服务中的数据流转。本指南将展示如何在 *体质指数* 应用中使用 **ServiceComb** 提供的分布式调用链追踪能力。

## 前言

在您进一步阅读之前,请确保您已阅读了[微服务应用快速开发指南](/cn/docs/quick-start-bmi/),并已成功运行体质指数微服务。

## 启用

1. 在 *体质指数计算器* 的 `pom.xml` 文件中添加依赖项:

```xml
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>handler-tracing-zipkin</artifactId>
</dependency>
```

2. 在 *体质指数计算器* 的 `microservice.yaml` 文件中添加分布式追踪的处理链:

```yaml
handler:
chain:
Consumer:
default: tracing-consumer
```

3. 在 *体质指数界面* 的 `pom.xml` 文件中添加依赖项:

```xml
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>handler-tracing-zipkin</artifactId>
</dependency>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>spring-cloud-zuul-zipkin</artifactId>
</dependency>
```

4. 在 *体质指数界面* 的`microservice.yaml` 文件中添加分布式追踪的处理链:

```yaml
handler:
chain:
Consumer:
default: tracing-consumer
Provider:
default: tracing-provider
```

5. 使用 Docker 运行 *Zipkin* 分布式追踪服务:

```bash
docker run -d -p 9411:9411 openzipkin:zipkin
```

修改后需要重启 *体质指数计算器* 和 *体质指数界面* 。

## 验证

1. 访问 <a>http://localhost:8888</a> ,在身高和体重栏处输入正数,并点击 *Submit* 按钮。
2. 访问 <a>http://localhost:9411</a> ,查看分布式调用追踪情况,可得下方界面。

![分布式追踪效果](/assets/images/distributed-tracing-result.png){: .align-center}

## 下一步

* 阅读[基于 ServiceComb 和 Zipkin 的分布式调用链追踪](/cn/docs/tracing-with-servicecomb/)来进一步了解分布式追踪
* 认识 [**ServiceComb** 微服务开发框架](http://servicecomb.io/cn/users/user-guide/)
* 通过 [Company应用](http://servicecomb.io/cn/docs/linuxcon-workshop-demo/) 更深入地了解微服务开发
53 changes: 53 additions & 0 deletions _docs/cn/load-balance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "负载均衡"
lang: cn
ref: quick-start-load-balance
permalink: /cn/docs/quick-start-advance/load-balance/
excerpt: "介绍如何在体质指数应用中使用ServiceComb框架提供的负载均衡能力"
last_modified_at: 2017-09-03T10:01:43-04:00
---

{% include toc %}
当对体质指数计算器进行水平扩展时,需要将请求均衡地分发到多个体质指数计算器上。本指南将展示如何在 *体质指数* 应用中使用 **ServiceComb** 提供的负载均衡能力。

## 前言

在您进一步阅读之前,请确保您已阅读了[微服务应用快速开发指南](/cn/docs/quick-start-bmi/),并已成功运行体质指数微服务。

## 开启

在 *体质指数界面* 的 `microservice.yaml` 文件中添加以下内容即可开启负载均衡的能力:

```yaml
handler:
chain:
Consumer:
default: loadbalance
```

修改后需要重启体质指数界面微服务。

## 验证

对 *体质指数计算器* 微服务进行水平扩展,使其运行实例数为2,即新增一个运行实例。在体质指数计算器的源代码作出如下修改:

1. 修改服务运行端口,避免端口冲突

修改 `microservice.yaml` 文件,将 `cse.rest.address` 由原来的 `0.0.0.0:7777` 修改为 `0.0.0.0:7778` 。

2. 修改 `CalculatorServiceImpl.java` 文件,使体质指数计算结果减半(方便观察效果)

在 `calculate` 方法中,将返回的体质指数值减半:

```java
double bmi = weight / (heightInMeter * heightInMeter) / 2;
```

启动服务,此时点击 *Submit* 按钮就可以看到如下两个界面交替出现。

![负载均衡效果](/assets/images/load-balance-result.png){: .align-center}

## 下一步

* 阅读[服务治理快速入门](/cn/docs/quick-start-advance/service-management/)
* 了解更多[负载均衡](/cn/users/load-balance/)的使用方式
19 changes: 19 additions & 0 deletions _docs/cn/quick-start-advance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "微服务开发进阶"
lang: cn
ref: quick-start-advance
permalink: /cn/docs/quick-start-advance/
excerpt: "介绍如何在体质指数应用中使用ServiceComb的处理链能力"
last_modified_at: 2017-09-03T10:01:43-04:00
---

本指南将带您进入**体质指数**微服务应用开发的进阶之旅。在此旅程,您将能学到 **ServiceComb** 框架如何通过处理链保证微服务的可靠性:
* [负载均衡](/cn/docs/quick-start-advance/load-balance/)。均衡地将请求分发至多个服务实例中处理。
* [服务治理](/cn/docs/quick-start-advance/service-management/)。在微服务应用中隔离异常服务并阻止异常传递。
* [分布式追踪](/cn/docs/quick-start-advance/distributed-tracing)。可视化微服务间的数据流转。


## 下一步

* 认识 [**ServiceComb** 微服务开发框架](http://servicecomb.io/cn/users/user-guide/)
* 通过 [Company应用](http://servicecomb.io/cn/docs/linuxcon-workshop-demo/) 更深入地了解微服务开发
3 changes: 1 addition & 2 deletions _docs/cn/quick-start-bmi.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,4 @@ public class GatewayApplication {
至此,**体质指数**应用已开发完毕,您可以通过[快速入门指南](/cn/docs/quick-start/#运行微服务应用)中的步骤对其进行验证。

## 下一步
* 认识 [**ServiceComb** 微服务开发框架](/cn/users/user-guide/)
* 通过[Company应用](/cn/docs/linuxcon-workshop-demo/)更深入地了解微服务开发
* 阅读 [微服务开发进阶](/cn/docs/quick-start-advance/)
2 changes: 1 addition & 1 deletion _docs/cn/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ cd webapp; mvn spring-boot:run
![体质指数应用运行界面](/assets/images/bmi-interface.png){: .align-center}

## 下一步
接下来推荐您阅读[**体质指数**微服务应用快速开发](/cn/docs/quick-start-bmi/)。
阅读[**体质指数**微服务应用快速开发](/cn/docs/quick-start-bmi/)。
58 changes: 58 additions & 0 deletions _docs/cn/service-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: "服务治理"
lang: cn
ref: quick-start-service-management
permalink: /cn/docs/quick-start-advance/service-management/
excerpt: "介绍如何在体质指数应用中使用ServiceComb提供的服务治理能力"
last_modified_at: 2017-09-03T10:01:43-04:00
---

{% include toc %}
服务治理主要用于解决或缓解服务雪崩的情况,即个别微服务表现异常时,系统能对其进行容错处理,从而避免资源的耗尽。本指南将会展示如何在 *体质指数* 应用中使用 **ServiceComb** 提供的服务治理能力。

## 前言

在您进一步阅读之前,请确保您已阅读了[微服务应用快速开发指南](/cn/docs/quick-start-bmi/),并已成功运行体质指数微服务。

## 启用

1. 在 *体质指数计算器* 的 `pom.xml` 文件中添加依赖项:

```xml
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>handler-bizkeeper</artifactId>
</dependency>
```

2. 在 *体质指数计算器* 的 `microservice.yaml` 文件中指明使用服务治理的处理链及指定熔断和容错策略:

```yaml
handler:
chain:
Provider:
default: bizkeeper-provider
circuitBreaker:
Provider:
calculator:
requestVolumeThreshold: 3
fallbackpolicy:
Provider:
policy: returnnull
```

修改后需要先关闭之前运行的 *体质指数计算器* 微服务,并再次启动一个 *体质指数计算器* 微服务。

## 验证

1. 使服务进入熔断状态。访问 <a>http://localhost:8888</a>,在身高或体重的输入框中输入一个负数,连续点击三次或以上 *Submit* 按钮,此时在网页下方能看到类似左图的界面。
2. 验证服务处于熔断状态。在身高和体重的输入框中输入正数,再次点击 *Submit* 按钮,此时看到的界面依然是类似左图的界面。同时在 *体质指数计算器* 运行日志也能看到调用不再抛出异常,而是出现类似 `fallback called` 的日志。
3. 验证服务恢复正常。约15秒后,在身高和体重的输入框中输入正数,点击 *Submit* 按钮,此时界面显示正常。


![服务治理效果](/assets/images/service-management-result.png){: .align-center}

## 下一步

* 阅读[分布式追踪快速入门指南](/cn/docs/quick-start-advance/distributed-tracing/)
* 了解更多[服务治理](/cn/users/service-management/)的使用方式
81 changes: 81 additions & 0 deletions _docs/distributed-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: "Distributed Tracing"
lang: en
ref: quick-start-distributed-tracing
permalink: /docs/quick-start-advance/distributed-tracing/
excerpt: "Introduce how to use distributed tracing with ServiceComb in the BMI application"
last_modified_at: 2017-09-03T10:01:43-04:00
---

{% include toc %}
Distributed handler chain tracing is used to monitor the network latencies and visualize the flow of requests through microservices. This guide shows how to use distributed tracing with **ServiceComb** in the BMI application.

## Before you start

Walk through [Develop microservice application in minutes](/docs/quick-start-bmi/) and have **BMI application** running.

## Enable

1. Add distributed tracing dependency in `pom.xml` of *BMI calculator service*:

```xml
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>handler-tracing-zipkin</artifactId>
</dependency>
```

2. Add handler chain of distributed tracing in `microservice.yaml` of *BMI calculator service*:

```yaml
handler:
chain:
Consumer:
default: tracing-consumer
```

3. Add distributed tracing dependency in `pom.xml` of *BMI web service*:

```xml
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>handler-tracing-zipkin</artifactId>
</dependency>
<dependency>
<groupId>io.servicecomb</groupId>
<artifactId>spring-cloud-zuul-zipkin</artifactId>
</dependency>
```


4. Add handler chain of distributed tracing in `microservice.yaml` of *BMI web service*:

```yaml
handler:
chain:
Consumer:
default: tracing-consumer
Provider:
default: tracing-provider
```

5. Run *Zipkin* distributed service inside Docker.

```bash
docker run -d -p 9411:9411 openzipkin:zipkin
```

Restart *BMI calculator service* and *BMI web service*.

## Verification

1. Visit <a>http://localhost:8888</a> . Input positive integers in height and weight columns and then click *Submit* button.
2. Visit <a>http://localhost:9411</a> to checkout the status of distributed tracing and get the following figure.

![Distributed tracing result](/assets/images/distributed-tracing-result.png){: .align-center}

## What's next

* Read [Distributed Tracing with ServiceComb and Zipkin](/docs/tracing-with-servicecomb/)
* See [ServiceComb User Guide](/users/user-guide/)
* Learn more from [the Company application](/docs/linuxcon-workshop-demo/) for a more complete example of microservice applications integrated with ServiceComb
52 changes: 52 additions & 0 deletions _docs/load-balance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: "Load Balance"
lang: en
ref: quick-start-load-balance
permalink: /docs/quick-start-advance/load-balance/
excerpt: "Introduce how to use load balance with ServiceComb in the BMI application"
last_modified_at: 2017-09-03T10:01:43-04:00
---

{% include toc %}
When we scale up *BMI calculator service*, requests from *BMI web service* need to distribute equally to each *BMI calculator service*. This guide shows how to use load balance with **ServiceComb** in the BMI application.

## Before you start

Walk through [Develop microservice application in minutes](/docs/quick-start-bmi/) and have **BMI application** running.

## Enable

To enable load balance, add the following configurtations in *BMI web service*\'s `microservice.yaml` file:

```yaml
handler:
chain:
Consumer:
default: loadbalance
```

Restart *BMI web service* .

## Verification

Run one more *BMI calculator service*. Before that, do some changes in *BMI calculator service*\'s source code.

1. Change the service port to avoid port conflict.

Change `cse.rest.address` from `0.0.0.0:7777` to `0.0.0.0:7778` in `microservice.yaml`.

2. Divide the result of BMI calculation by 2 in `CalculatorServiceImpl.java` for a more obvious result.

```java
double bmi = weight / (heightInMeter * heightInMeter) / 2;
```


Run the new *BMI calculator service* . Now you can see the following figures shows up alternately by clicking the *Submit* button.

![Load balance result](/assets/images/load-balance-result.png){: .align-center}

## What's next

* See quick start for [Servie Management](/docs/quick-start-advance/service-management/)
* Learn more about [Load Balance](/users/load-balance/)
Loading