mqtt 与tcp上的区别

mqtt 与tcp上的区别,第1张

1.基于一个传输层 协议定位:面向连接的可靠的,基于字节流的传输层通信协议

2.mqtt是一基于应用层 协议定位:低宽带,高延迟不可靠的网络下进行数据相对 可靠的传输.传输的定位:消息

3. (1)在服务质量上比对的时候:tcp通过acr确认和重传机制,发送和接收报文完全 一样,并且进行保存

(2) mqtt 是提供了三种可选的消息服务等级,消息传输不保存

redis缓冲的定义: 首次存储在计算机上的一个原始数据复制集以便去访问 一般有几种的情况: 分为cpu缓存->匹配cpu的频率,客户端缓存->减少网络访问 服务器本地缓存->减少磁盘io 分布式缓存 ->减少耗时的复杂运算->加快DB中 的热点数据访问。

缓存原理:将数据副本存入速度更快的存储设备 将数据放到与使用更近的位置 缓存击穿: 对于一些设置了过期时间的key,如果这些key可能会在某些时间点 被超高并发地去访问是一种热点数据。 原因:缓存在某时间点过期的时候恰好在这个时间点对这个key有大量并发请求 过来,该key没有命中大量请求穿透到数据库服务器。

解决方案: 1.首先对于热点数据慎重考虑过期时间,确保热点期间key不会过期,甚至 有些可以设置永不过期。 2.使用互斥锁 第一线程访问key的时候就会锁住等查询数据库返回后 把值插入到缓存后再释放锁 

流程图

 

 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、时间区间匹配
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、请求包含某参数
spring:
 cloud:
  gateway:
   routes:
    - id: query_route
      uri: https://example.org
      predicates:
       - Query=green
10、请求包含某参数并且参数值匹配正则表达式
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缓存

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/2990412.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-23
下一篇 2022-09-23

发表评论

登录后才能评论

评论列表(0条)

保存