微服务模块架构图
Tags: microservices, springcloud, architecture
Published: 2017-11-03 09:06:32

---
title: å¾®æœåŠ¡æ¨¡å—æž¶æž„å›¾
published: true
description: å±•çŽ°å¾®æœåŠ¡ä¸­ï¼ˆä»¥ Spring Cloud ä¸ºä¸»ï¼‰å„ä¸ªæ¨¡å—çš„å†…éƒ¨æž¶æž„
tags: microservices, spring cloud, architecture
---

###Eureka åŽŸç†
[é…ç½®æ–‡æ¡£](https://github.com/Netflix/eureka/wiki/Configuring-Eureka)
![Eureka åŽŸç†](https://thepracticaldev.s3.amazonaws.com/i/gr9xz2aaqd875cvfiwje.png)

###Eureka æž¶æž„å›¾
![Eureka æž¶æž„å›¾](https://thepracticaldev.s3.amazonaws.com/i/dy8qb079qtcrw6joeaj0.png)

###ç½‘å…³
![gateway](https://thepracticaldev.s3.amazonaws.com/i/4eyyk8nh9en52fc85jd9.png)

###ZUUL
[è·¯ç”±é…ç½®](http://blog.didispace.com/spring-cloud-starter-dalston-6-2/)
Netflix ä½¿ç”¨ Zuul åšå¦‚ä¸‹äº‹æƒ…ï¼š
* è®¤è¯é‰´æƒ
* å®¡æŸ¥
* åŽ‹åŠ›æµ‹è¯•
* é‡‘ä¸é›€æµ‹è¯•
* [åŠ¨æ€è·¯ç”±](http://xujin.org/sc/docs/sc-zuul/)
* æœåŠ¡è¿ç§»
* è´Ÿè½½å‰ªè£
* å®‰å…¨
* é™æ€åº”ç­”å¤„ç†

###é…ç½®ä¸­å¿ƒ Config
* ä»‹ç»ï¼š[èŠèŠ Spring Cloud Config](https://blog.coding.net/blog/spring-cloud-config)
* Spring Cloud Config é¡¹ç›®
-æä¾› æœåŠ¡ç«¯ å’Œ å®¢æˆ·ç«¯ æ”¯æŒ
-é›†ä¸­å¼ ç®¡ç†åˆ†å¸ƒå¼çŽ¯å¢ƒä¸‹çš„åº”ç”¨é…ç½®
-åŸºäºŽ Spring çŽ¯å¢ƒï¼Œæ— ç¼ ä¸Ž Spring åº”ç”¨é›†æˆ
-å¯ç”¨äºŽ ä»»ä½• è¯­è¨€å¼€å‘çš„ç¨‹åº
-é»˜è®¤å®žçŽ°åŸºäºŽ git ä»“åº“ï¼Œå¯ä»¥è¿›è¡Œ ç‰ˆæœ¬ç®¡ç†
-å¯æ›¿æ¢ è‡ªå®šä¹‰å®žçŽ°

* Spring Cloud Config Server ä½œä¸ºé…ç½®ä¸­å¿ƒæœåŠ¡ç«¯
-æ‹‰å–é…ç½®æ—¶æ›´æ–° git ä»“åº“å‰¯æœ¬ï¼Œä¿è¯æ˜¯æœ€æ–°ç»“æžœ
-æ”¯æŒæ•°æ®ç»“æž„ä¸°å¯Œï¼Œyml, json, properties ç­‰
-é…åˆ eureke å¯å®žçŽ°æœåŠ¡å‘çŽ°ï¼Œé…åˆ cloud bus å¯å®žçŽ°é…ç½®æŽ¨é€æ›´æ–°
-é…ç½®å­˜å‚¨åŸºäºŽ git ä»“åº“ï¼Œå¯è¿›è¡Œç‰ˆæœ¬ç®¡ç†
-ç®€å•å¯é ï¼Œæœ‰ä¸°å¯Œçš„é…å¥—æ–¹æ¡ˆ

* è®¿é—®æ–¹å¼
```
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{profile}.properties
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
/{label}/{application}-{profile}.yml
/{label}/{application}
```

* å¦‚ä½•ç®¡ç†ä¸‹å›¾ä¸­çš„å„ç§é…ç½®ï¼Ÿ
![unconfiged staff](https://thepracticaldev.s3.amazonaws.com/i/9fco3jo69bcig0nh0u9f.png)
* è§£å†³æ–¹æ¡ˆ
![solution](https://thepracticaldev.s3.amazonaws.com/i/deamhulyb0guizyz7ej3.png)
* æž¶æž„å›¾
![Config Server](https://thepracticaldev.s3.amazonaws.com/i/9b8k4qvko13l4jyohifu.png)
![Config Server with Cloud Bus](https://thepracticaldev.s3.amazonaws.com/i/g8p9cs8q7odcz5p3iuzm.png)

###Ribbon
client side load balancerï¼Œ[é…ç½®æ–‡æ¡£](https://github.com/Netflix/ribbon/wiki/Programmers-Guide)
###Feign
declarative REST client

###Hystrix æ–­è·¯å™¨ / ç†”æ–­å™¨åŽŸç†
[é…ç½®æ–‡æ¡£](https://github.com/Netflix/Hystrix/wiki/Configuration) [Turbine](https://github.com/Netflix/Turbine/wiki) [Turbine é…ç½®1.x](https://github.com/Netflix/Turbine/wiki/Configuration-(1.x))
![Hystrix](https://thepracticaldev.s3.amazonaws.com/i/is5fof68f0n2311952hj.png)

###åˆ†å¸ƒå¼æœåŠ¡è·Ÿè¸ªç³»ç»Ÿç¤ºæ„å›¾
ï¼ˆæ¥æºï¼š[åˆ†å¸ƒå¼æœåŠ¡è·Ÿè¸ªåŠ Spring Cloud çš„å®žçŽ°](http://daixiaoyu.com/distributed-tracing.html)ï¼‰
![åˆ†å¸ƒå¼æœåŠ¡è·Ÿè¸ªç³»ç»Ÿç¤ºæ„å›¾](https://thepracticaldev.s3.amazonaws.com/i/nfxs9fsfqplhdo3k1hnk.png)

###æ•°æ®æ”¶é›† Zipkin
![æ•°æ®æ”¶é›†](https://thepracticaldev.s3.amazonaws.com/i/9khh3x2vcvp5cbzt0fyl.png)

###Sleuth
* Sleuth: distributed tracing via logsï¼Œ[ä½¿ç”¨ Sleuth è¿½è¸ªå¾®æœåŠ¡](https://dzone.com/articles/tracing-in-microservices-with-spring-cloud-sleuth)
* Zipkin: distributed tracing system with request visualization

###æ•°æ®æµè½¬
![æ•°æ®æµè½¬](https://thepracticaldev.s3.amazonaws.com/i/09u64s6jhqokq6ll8ood.png)
* Trace + Span
![trace span](https://thepracticaldev.s3.amazonaws.com/i/x0vsf984lrhan32q63v3.png)

###ELK æŠ€æœ¯æ ˆ
ELK stack interaction with different applications based on Log file
![ELK](https://thepracticaldev.s3.amazonaws.com/i/0nbsy3d84oo5hu617n7f.jpg)

###Stream æž¶æž„å›¾
[é…ç½®ä¸Žå¼€å‘æ–‡æ¡£](http://xujin.org/sc/docs/sc-stream/)
![Stream](https://thepracticaldev.s3.amazonaws.com/i/z40rpdfhv94k61obm5hz.png)