Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spring-cloud-learn
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
spring-cloud-learn
Commits
9aee62c7
Commit
9aee62c7
authored
Sep 04, 2019
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hystric
parent
6763b5ac
Pipeline
#114
failed
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
110 additions
and
6 deletions
+110
-6
README.md
README.md
+49
-0
spring-cloud-hello-world/order-service/pom.xml
spring-cloud-hello-world/order-service/pom.xml
+4
-0
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/SpringOrderServiceApplication.java
...ian/spring/cloud/order/SpringOrderServiceApplication.java
+4
-2
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/api/HelloRemoteHystrix.java
...anledexian/spring/cloud/order/api/HelloRemoteHystrix.java
+16
-0
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/api/IHelloApi.java
...va/com/duanledexian/spring/cloud/order/api/IHelloApi.java
+24
-0
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/controller/HomeController.java
...edexian/spring/cloud/order/controller/HomeController.java
+5
-1
spring-cloud-hello-world/order-service/src/main/resources/bootstrap.yml
...ello-world/order-service/src/main/resources/bootstrap.yml
+3
-0
spring-cloud-hello-world/user-service/src/main/java/com/duanledexian/spring/cloud/user/controller/HomeController.java
...ledexian/spring/cloud/user/controller/HomeController.java
+3
-3
spring-cloud-hello-world/user-service/src/main/resources/bootstrap.yml
...hello-world/user-service/src/main/resources/bootstrap.yml
+2
-0
No files found.
README.md
View file @
9aee62c7
...
...
@@ -14,7 +14,18 @@ springboot与spring cloud兼容版本
| Edgware | 1.5.x |
| Dalston | 1.5.x |
### 核心组件
-
Eureka:服务治理组件,包含服务注册与发现
-
Hystrix(豪猪):容错管理组件,实现了熔断器
-
Ribbon:客户端负载均衡的服务调用组件
-
Feign:基于Ribbon和Hystrix的声明式服务调用组件
-
Zuul:网关组件,提供智能路由、访问过滤等功能
-
Spring Cloud Config:配置管理工具,实现应用配置的外部化存储,支持客户端配置信息刷新、加密/解密配置内容等。
-
Spring Cloud Bus:事件、消息总线,用于传播集群中的状态变化或事件,以及触发后续的处理
-
Spring Cloud Security:基于spring security的安全工具包,为我们的应用程序添加安全控制
-
Spring Cloud Consul : 封装了Consul操作,Consul是一个服务发现与配置工具(与Eureka作用类似),与Docker容器可以无缝集成
### 应用端口配置
...
...
@@ -30,6 +41,43 @@ springboot与spring cloud兼容版本
user-service:9204
order-service:9203
### 性能指标
**PV**
即 page view,页面浏览量 用户每一次对网站中的每个页面访问均被记录1次。用户对同一页面的多次刷新,访问量累计。
**UV**
即 Unique visitor,独立访客 通过客户端的cookies实现。即同一页面,客户端多次点击只计算一次,访问量不累计。
**IP**
即 Internet Protocol,本意本是指网络协议,在数据统计这块指通过ip的访问量。 即同一页面,客户端使用同一个IP访问多次只计算一次,访问量不累计。
UV、IP的区别
1. 比如你是ADSL拨号上网,拨一次号自动分配一个IP,进入了网站,就算一个IP;断线了而没清理Cookies,又拨号一次自动分配一个IP,又进入了同一个网站,又统计到一个IP,这时统计数据里IP就显示统计了2次。UV没有变,是1次。
2. 同一个局域网内2个人,在2台电脑上访问同一个网站,他们的公网IP是相同的。IP就是1,但UV是2。
**TPS**
即Transactions Per Second的缩写,每秒处理的事务数目。一个事务是指一个客户机向服务器发送请求然后服务器做出反应的过程。客户机在发送请求时开始计时,收到服务器响应后结束计时,以此来计算使用的时间和完成的事务个数,最终利用这些信息作出的评估分。
**QPS**
即Queries Per Second的缩写,每秒能处理查询数目。是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准。
**RPS**
即Requests Per Second的缩写,每秒能处理的请求数目。等效于QPS
### 概念
1.
**服务雪崩效应**
分布式系统中经常会出现某个基础服务不可用造成整个系统不可用的情况,这种现象被称为服务雪崩效应
2.
### 服务网关
服务网关的作用:
**网关作为对外的门户,实现动态路由、监控、授权、安全、调度等功能。**
...
...
@@ -108,4 +156,5 @@ Spring Cloud Gateway VS Zuul
4.
https://natapp.cn/article/natapp_newbie
5.
https://my.oschina.net/u/3266761/blog/2245498
6.
https://segmentfault.com/a/1190000019137876?utm_source=tag-newest
7.
https://blog.csdn.net/lvqingyao520/article/details/78756959
spring-cloud-hello-world/order-service/pom.xml
View file @
9aee62c7
...
...
@@ -36,5 +36,9 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-bus-amqp
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
</dependencies>
</project>
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/SpringOrderServiceApplication.java
View file @
9aee62c7
...
...
@@ -2,7 +2,8 @@ package com.duanledexian.spring.cloud.order;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
/**
* 服务提供方
...
...
@@ -10,7 +11,8 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
* @author Administrator
*/
@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
public
class
SpringOrderServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/api/HelloRemoteHystrix.java
0 → 100644
View file @
9aee62c7
package
com.duanledexian.spring.cloud.order.api
;
import
org.springframework.stereotype.Component
;
/**
* @author duanledexianxianxian
* @date 2019/9/4 3:46
* @since 1.0.0
*/
@Component
public
class
HelloRemoteHystrix
implements
IHelloApi
{
@Override
public
String
sayHello
(
String
name
)
{
return
"曹操"
;
}
}
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/api/IHelloApi.java
0 → 100644
View file @
9aee62c7
package
com.duanledexian.spring.cloud.order.api
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* The interface Hello api.
*
* @author Administrator
*/
@FeignClient
(
name
=
"user-service"
,
fallback
=
HelloRemoteHystrix
.
class
)
public
interface
IHelloApi
{
/**
* Say hello string.
*
* @param name the name
* @return the string
*/
@GetMapping
(
"/api/v1/sayHello"
)
String
sayHello
(
@RequestParam
(
"name"
)
String
name
);
}
spring-cloud-hello-world/order-service/src/main/java/com/duanledexian/spring/cloud/order/controller/HomeController.java
View file @
9aee62c7
package
com.duanledexian.spring.cloud.order.controller
;
import
com.duanledexian.spring.cloud.order.api.IHelloApi
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -16,13 +18,15 @@ import org.springframework.web.bind.annotation.RestController;
@RefreshScope
@Slf4j
public
class
HomeController
{
@Autowired
private
IHelloApi
helloApi
;
@Value
(
"${hello.name:world}"
)
private
String
name
;
@GetMapping
(
"/sayHello"
)
public
String
sayHello
()
{
return
"order-service hello "
+
name
;
return
helloApi
.
sayHello
(
"order service"
)
;
}
}
spring-cloud-hello-world/order-service/src/main/resources/bootstrap.yml
View file @
9aee62c7
...
...
@@ -22,3 +22,6 @@ eureka:
client
:
service-url
:
defaultZone
:
http://localhost:9000/eureka/
feign
:
hystrix
:
enabled
:
true
spring-cloud-hello-world/user-service/src/main/java/com/duanledexian/spring/cloud/user/controller/HomeController.java
View file @
9aee62c7
...
...
@@ -18,11 +18,11 @@ import org.springframework.web.bind.annotation.RestController;
public
class
HomeController
{
@Value
(
"${hello.name:world}"
)
private
String
n
ame
;
private
String
applicationN
ame
;
@GetMapping
(
"/sayHello"
)
public
String
sayHello
()
{
return
"hello "
+
name
;
public
String
sayHello
(
String
name
)
{
return
"hello "
+
name
+
" "
+
applicationName
;
}
}
spring-cloud-hello-world/user-service/src/main/resources/bootstrap.yml
View file @
9aee62c7
...
...
@@ -22,3 +22,5 @@ eureka:
client
:
service-url
:
defaultZone
:
http://localhost:9000/eureka/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment