1.基于一個傳輸層 協(xié)議定位:面向連接的可靠的,基于字節(jié)流的傳輸層通信協(xié)議
2.mqtt是一基于應用層 協(xié)議定位:低寬帶,高延遲不可靠的網(wǎng)絡下進行數(shù)據(jù)相對 可靠的傳輸.傳輸?shù)亩ㄎ?消息
3. (1)在服務質量上比對的時候:tcp通過acr確認和重傳機制,發(fā)送和接收報文完全 一樣,并且進行保存
(2) mqtt 是提供了三種可選的消息服務等級,消息傳輸不保存
redis緩沖的定義: 首次存儲在計算機上的一個原始數(shù)據(jù)復制集以便去訪問 一般有幾種的情況: 分為cpu緩存->匹配cpu的頻率,客戶端緩存->減少網(wǎng)絡訪問 服務器本地緩存->減少磁盤io 分布式緩存 ->減少耗時的復雜運算->加快DB中 的熱點數(shù)據(jù)訪問。
緩存原理:將數(shù)據(jù)副本存入速度更快的存儲設備 將數(shù)據(jù)放到與使用更近的位置 緩存擊穿: 對于一些設置了過期時間的key,如果這些key可能會在某些時間點 被超高并發(fā)地去訪問是一種熱點數(shù)據(jù)。 原因:緩存在某時間點過期的時候恰好在這個時間點對這個key有大量并發(fā)請求 過來,該key沒有命中大量請求穿透到數(shù)據(jù)庫服務器。
解決方案: 1.首先對于熱點數(shù)據(jù)慎重考慮過期時間,確保熱點期間key不會過期,甚至 有些可以設置永不過期。 2.使用互斥鎖 第一線程訪問key的時候就會鎖住等查詢數(shù)據(jù)庫返回后 把值插入到緩存后再釋放鎖?
流程圖
?
?GateWay路由條件配置
1、時間點后匹配
yml方式配置
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- After=2022-02-20T17:42:47.789-07:00[America/Denver]
2、時間點前匹配
spring:
cloud:
gateway:
routes:
- id: before_route
uri: https://example.org
predicates:
- Before=2022-02-20T17:42:47.789-07:00[America/Denver]
3、時間區(qū)間匹配
spring:
cloud:
gateway:
routes:
- id: between_route
uri: https://example.org
predicates:
- Between=2022-01-20T17:42:47.789-07:00[America/Denver],
2022-01-21T17:42:47.789-07:00[America/Denver]
4、指定Cookie正則匹配指定值
spring:
cloud:
gateway:
routes:
- id: cookie_route
uri: https://example.org
predicates:
- Cookie=cookie,china
5、指定Header正則匹配指定值
spring:
cloud:
gateway:
routes:
- id: header_route
uri: https://example.org
predicates:
- Header=X-Request-Id
6、請求Host匹配指定值
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://example.org
predicates:
- Host=**.somehost.org,**.anotherhost.org
7、請求Method匹配指定請求方式
spring:
cloud:
gateway:
routes:
- id: method_route
uri: https://example.org
predicates:
- Method=GET,POST
8、請求路徑正則匹配
spring:
cloud:
gateway:
routes:
- id: path_route
uri: https://example.org
predicates:
- Path=/red/{segment},/blue/{segment}
9、請求包含某參數(shù)
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=green
10、請求包含某參數(shù)并且參數(shù)值匹配正則表達式
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=red, gree.
11、遠程地址匹配
spring:
cloud:
gateway:
routes:
- id: remoteaddr_route
uri: https://example.org
predicates:
- RemoteAddr=192.168.1.1/24
redis緩存文章來源:http://www.zghlxwxcb.cn/news/detail-509531.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-509531.html
到了這里,關于mqtt 與tcp上的區(qū)別的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!