Skip to content

Latest commit

 

History

History
180 lines (117 loc) · 4.52 KB

Description.md

File metadata and controls

180 lines (117 loc) · 4.52 KB

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Install Jar

https://maven.apache.org/download.cgi Update POM with pacakage Jar and plugins for maven In Plugins do compile and then jar Copy from target to root path, then type:

mvn install:install-file -Dfile=target/OnlineShopping-1.0.jar -DgroupId=com.qiuzhitech -DartifactId=OnlineShopping -Dversion=1.1 -Dpackaging=jar

1. Basic Framework

Spring Boot

MVC

RestfulAPI

MyBatis 逆向生成

Packages

Lombok

Junit

Mockito

2. Redis - 处理高并发high concurrency

Jmeter压力测试 - PrimeDay优化

事务思路

分布式锁 - 防止缓存击穿

缓存预热 - 防止缓存击穿

3. RocketMQ - 流量控制 - 削峰 - PrimeDay优化

  • 异步化处理数据。Asynchronous data processing.
  • 削峰处理 - 流量控制和顺序处理。
  • 下单和付款解耦 - 遵循Least Knowledge Principle。
  • 限制每个用户只下一笔订单。

环境配置Environment setup

Key: ROCKETMQ_HOME, Val: rocketmq-4.9.3

启动

  1. Enter CMD go to Folder /rocketmq-4.9.3/bin
  2. Start RocketMQ with: ./mqnamesrv or nohup sh bin/mqnamesrv &
  3. Launch a new terminal with:
    sh mqbroker -n localhost:9876 -c ../conf/broker.conf autoCreateTopicEnable=true
    

检查端口Check Port:

netstat -ano | findstr "9876"

关闭端口ShutDown RocketMQ:

mqshutdown broker
mqshutdown namesrv

删除消息Delete Message:

./mqadmin deleteTopic -c DefaultCluster -n localhost:9876 -t {topicName}

4. Elasticsearch - 搜索加速

倒排索引 Inverted Index in Distributed NoSQL DBMS.

启动

  1. Enter CMD go to Folder /elasticsearch-7.4.2/bin
  2. Type ./elasticsearch
  3. Enter CMD goto folder /kibana-7.4.2-darwin-x86_64/bin
  4. Type ./kibana

Visit http://127.0.0.1:9200/ to check ElasticSearch status

Visit http://127.0.0.1:5601/ to manage database via Kibana console

Elastic Search概念

基础

字段,文档,映射,索引,节点,分片

数据类型

text, keyword

分词器analyzer

5. Alibaba Sentinel - 流量控制 - 限流Rate Limitor

监控流量的QPS或并发数量,当达到设定的threshold时,阻止流量访问。用于处理:

  1. 某个用户请求量过多(DDoS/恶意刷屏)
  2. 整体请求量过多,服务器无法承受

实现高可用性(high availability): 保护后端系统不被冲垮,抵挡恶意攻击。

6. 数据库分库分表

分库:单机数据库存储和并发连接数有限, 分表:单表数据量大时影响sql执行性能。

7. UUID雪花算法

Distributed ID System - Snowflake

优点:

  1. 保证id安全性
  2. 数字类型搜索比字符串id快
  3. 支持依据id搜索,保证

8. Consul - 分布式静态页面

分布式服务发现和配置管理工具。 Distributed service discovery and configuration management tool.

  1. Download Consul https://developer.hashicorp.com/consul/downloads
  2. Start with ./consul agent -dev
  3. Visit Web http://localhost:8500/

静态页面和动态页面

CDN Thymeleaf Ngix服务器 反向代理

实验1:Spring Cloud OpenFeign

分布式部署,模拟多机器的服务注册和服务发现 用RPC call,比api或http快,因为少了安全性检测

外部和内部用api 内部和内部用RPC

长连接 WebSocket Long Polling Http Keep Alive

Please see Project SpringCloudDemo

实验2: Spring Cloud Gateway

Load Balancer 网关 设置routing

order和commodity注册在consul上, request经过gateway,和consul沟通,重定向到特定服务上