59e71bc209848

2020-02-27 193浏览

  • 1.如何利用Redisson分布式化传统Web项目 How to Distributify Traditional Web Applications with Redisson Redisson Team 顾睿
  • 2.关于我 About Me
  • 3.1 2 3 4 传统Web项目的构成 分布式化的历程 Redis银弹+Redisson 改造方案的实施 Composition of a Traditional Web Application The Journey to Distributify a Traditional Web Application Redis the Silver Bullet and Redisson Ready, Steady, Action!
  • 4.传统Web项目的构成 Composition of a Traditional Web Application
  • 5.传统Web项目基本架构 Typical Architecture of a Traditional Web Application 表现层 / Presentation Layer 应用层 / Application Layer 业务层 / Business Layer 持久层 / Persistent Layer
  • 6.传统Web项目基本技术栈 Typical Technology Stack of a Traditional Web Application 表现层 / Presentation Layer HTML + JavaScript Mobile App
  • 7.传统Web项目基本技术栈 Typical Technology Stack of a Traditional Web Application 应用层 / Application Layer 业务层 / Business Layer 持久层 / Persistent Layer
  • 8.传统Web项目基本技术栈 Typical Pivotal Technology Stack of a Traditional Web Application
  • 9.传统Web项目的典型特征 Characteristics of a Traditional Web Application 非分布式 Not Distributed 非高并发 非高可用 Not Highly Concurrent Not Highly Available
  • 10.分布式化的历程 The Journey to Distributify a Traditional Web Application
  • 11.什么是分布式系统 What is Distributed Systems 网络 – 高度互联 Interconnected network 集群 – 多节点 Multi-node cluster Prof. Andrew Stuart Tanenbaum Creator of MINIXSource:Wikipedia 单一 – 透明化 Transparent single coherent system
  • 12.分布式系统的特点 Characteristics of Distributed Systems 开放性 Openness 透明性 Transparency 扩展性 Scalability 并发性 Concurrency
  • 13.分布式化的实现方式 Methods to Implement Distributed Systems 1 架构细分 Slicing 表现层 / Presentation Layer 应用层 / Application Layer 业务层 / Business Layer 第N层 / Layer N 第N-1层 / Layer N-1 第N-2层 / Layer N-2 第N-3层 / Layer N-3 第四层 / Layer 4 第三层 / Layer 3 第二层 / Layer 2 持久层 / Persistent Layer 第一层 / Layer 1
  • 14.分布式化的实现方式 Methods to Implement Distributed Systems 2 服务化、模块化 Service Oriented Modularisation 第N层 / Layer N 第N-1层 / Layer N-1 第N-2层 / Layer N-2 第N-3层 / Layer N-3 第四层 / Layer 4 第三层 / Layer 3 第二层 / Layer 2 第一层 / Layer 1
  • 15.分布式化的实现方式 Methods to Implement Distributed Systems 3 数据中心化 Data Centralised Transformation
  • 16.分布式化的实现方式 Methods to Implement Distributed Systems 4 事件驱动 Event Driven Transformation 消息总线 / Message Bus
  • 17.分布式系统的挑战 Challenges Faced in Implementing Distributed Systems 分布式 Distributed 高并发 高可用 High Concurrency Highly Available
  • 18.分布式系统的挑战 Challenges Faced in Implementing Distributed Systems 高并发 High Concurrency 缓存 同步异步处理 列队 Cache Sync – Async Processing Queue 线程池 分库 全局锁 Thread Pool Sharding Global Locking
  • 19.分布式系统的挑战 Challenges Faced in Implementing Distributed Systems 高可用 Highly Available 重试策略 限流 限频 Retry Strategy Flow Limiting Rate Limiting
  • 20.Redis银弹+Redisson Redis the Silver Bullet and Redisson
  • 21.Redis银弹 Redis as a Silver Bullet 数据结构丰富 读写性能优异 Rich Data Types High Performance Read Write Access 稳定性极强 Extremely Stable 多种高可用模式 支持持久化 Multiple HA Mode Support Persistence
  • 22.什么是Redisson What is Redisson 操作最简单 功能最丰富的 Redis智能客户端 Simplest, yet Feature-Rich Smart Client for Redis 为JVM提供基于Redis的 高性能驻内存数据网格 Ultra-Fast Redis Based In-Memory Data Grid for JVM
  • 23.什么是Redisson What is Redisson 开源版 企业版
  • 24.Apache 2.0 License Redisson Commercial License 社区开源版 企业版 Open Source Community Edition Commercial Enterprise Edition
  • 25.Redisson的性能 Redisson Performance 本地单机 Local Single Intel Core i7 3612QM Redisson * Jedis 16GB RAM 平均响应时间 每秒吞吐量 Average Response Time Throughput per second ⩽ 1ms 193K – 231K ⩽ 1ms 52K – 55K * 采用企业版高速引擎测试 * Tests undertaken with Ultra-Fast PRO Engine 256线程 Thread
  • 26.Redisson操作简单 Redisson is Simple to Use 线程安全 标准Java接口 门槛低上手易 Thread Safe Operations Standard Java Interface No Learning Curve
  • 27.Redisson的智能化 Smart Redis Client 1. 多种连接类型:单机、主从、哨兵、集群和云平台 1. Topology Neutral :Supports all types of connection mode (single, M-S, sentinel, cluster and cloud) 2. 支持配置文件:开发 -> 生产变化,连接类型变化无需修改代码 2. Configuration:File based configuration provides smooth transition between dev and prod environment 3. 适配拓扑变化:支持节点自动发现 3. Topology Sensing:Support node auto-discovery 4. 弹性的连接池:自主管理连接数量,可伸可缩 4. Connection Pool:Provides configurable self-managed elastic connection pool 5. 动态连接监控:断线重连,命令失败重试,监控DNS变化 5. Connection Monitoring:Supports auto reconnect, command auto retry and detects DNS changes
  • 28.Redisson的智能化 Smart Redis Client 6. 连接池独立性:阻塞命令,非阻塞命令连接池独立 6. Command Isolation:Employs dedicated connection pools for blocking and non-blocking commands 7. 读写操作可控:读写分离方式可控,支持可控负载均衡 7. Load Balancing:Provides configurable load balancer and read-write separation strategy 8. 操作方式灵活:同时支持同步和异步操作,支持集群管道 8. Flexible Operation:Supports both sync and async operations, including pipeline usage in Cluster environment 9. 底层扩展性强:支持底层客户端,支持定制命令 9. Low Level:Supports low level command invocation, supports custom command invocation 10.数据编码丰富:官方提供10种数据编码类型,无需手动转换 10.Serialisation:Officially supports 10 different (de)encoders for automatic (de)serialisation
  • 29.Redisson的架构 Architecture of Redisson Advanced Features 高 级 功 基 功 其他Redis客户端 能 Clients Other Redis Basic Features Basic Features 础 能 基 础 功 Redisson 能
  • 30.Redisson的架构 Architecture of Redisson Redisson客户端(红线在下面)Redisson Client 其他客户端功能最多到此即止 Other Clients Ends Here or Somewhere Below 连接类型管理 Connection Management 单机 Single 哨兵 Sentinel 主从 M-S 集群 Cluster 云服务 Cloud 连接池和连接监控 Connection Pool & Monitoring 主节点连接池 Master Pool 从节点连接池 Slave Pool 订阅发布连接池 PubSub Pool Redis客户端(执行Redis指令) Redis Client (Command Execution) Redis连接 Redis Connection Redis发布订阅连接 Redis PubSub Connection Redis协议解析 Redis Protocol
  • 31.Redisson的架构 Architecture of Redisson 第三方框架/工具支持 Third Party Frameworks / Tools Support Spring框架 Spring Framework Spring缓存 Spring Cache Spring会话 Spring Session Hibernate 二级缓存 Hibernate Level2 Cache JCache (JSR 107) Tomcat 会话管理 Tomcat Session Manager 分布式实时对象服务 (OHM) Distributed Live Object Service 分布式执行服务 Distributed Executor Service 分布式调度任务服务 Distributed Scheduler Service MapReduce服务 MapReduce Service 分布式基础数据结构 Distributed Data Structures 分布式集合 Distributed Collections 分布式通用对象 Distributed Objects 分布式锁 Distributed Locks Redisson客户端 (红线在下面)Redisson Client 分布式同步器 Distributed Synchronisers Dropwisard Metrics 分布式远程服务 (RPC) Distributed Remote Service JMX 分布式服务中间件 Distributed Services Middleware 监控与统计 Management & Statistics Redisson 独立运算节点 Redisson Node
  • 32.Redisson功能丰富 Features of Redisson 分布式集合 分布式对象 分布式锁及同步器 分布式服务 第三方框架/工具直接支持 Distributed Collections Distributed Objects Distributed Locks and Synchronisers Distributed Services Direct Support for Third Party Frameworks & Tools 10种 9种 5种 7种 29种
  • 33.其它Redis客户端 Features of Other Redis Clients 分布式集合 分布式对象 分布式锁及同步器 分布式服务 第三方框架/工具直接支持 Distributed Collections Distributed Objects Distributed Locks and Synchronisers Distributed Services Direct Support for Third Party Frameworks & Tools 5种 无 无 无 N/A N/A N/A 5种
  • 34.分布式集合 Distributed Collections 29 种结构 Data Types Java 接口 原子性 操作 元素单 独过期 Java Interface Atomic Operations Individual Element Eviction 本地缓存 45倍性能 提升 Near Cache 45X Performance
  • 35.分布式集合 Distributed Collections • Map • Set • BlockingQueue • BlockingFairQueue • MapCache * • SetCache * • BlockingDeque • BlockingFairDeque • SetMultiMap • SortedSet • BoundedBlockingQueue • ClusteredMap • ListMultiMap • ScoredSortedSet • BlockingFairQueue • ClusteredSet • SetMultiMapCache * • LexSortedSet • DelayedQueue • ClusteredLocalCachedMap * • ListMultiMapCache * • List • PriorityQueue • ClusteredMapCache * • LocalCachedMap ∆ • Queue • PriorityDeque • LocalCachedMapCache *∆ • Deque * 允许集合中单个元素过期,此功能原生Redis及其他客户端均不具备 ∆ 提供本地缓存(Near Cache)功能,能使读取速度最高提升45倍,此功能其他客户端均不具备 * Allow individual element eviction in collection. Not supported in vanilla Redis and other clients. ∆ Support local cache (Near Cache), improves read operation up to 45x. Not supported in other clients.
  • 36.分布式对象 Distributed Objects 10 种结构 Data Types 类Java 接口 原子性 操作 Java Compatible Interface Atomic Operations
  • 37.分布式对象 Distributed Objects • Bucket (通用对象桶) • AtomicLong • BinaryStream (Input & Output Stream) • AtomicDouble • Geo (地理空间对象桶) • Topic (Pub/Sub) • BitSet • BloomFilter • HyperLogLog
  • 38.分布式锁和同步器 Distributed Locks & Synchronisers 5 3 种锁 种同步器 Locks Synchronisers Java Lock接口 Java Lock Interface 红锁 实现 RedLock Implementation
  • 39.分布式锁和同步器 Distributed Locks & Synchronisers • Lock • Semaphore • FairLock • PermitExpirableSemaphore • RedLock • CountDownLatch • MultiLock • Phaser (计划中 Planned) • ReadWriteLock
  • 40.分布式服务中间件 Distributed Services Middleware 远程服务 Remote Service • RPC 服务 • RPC Service • 支持同步异步 • Support sync & async operation • 支持列队模式和并发模式 • Support serial & concurrent invocation • 支持异常反馈 • Support exception transportation
  • 41.分布式服务中间件 Distributed Services Middleware 实时对象服务 Live Object Service • OHM 服务 • OHM Service • 普通Java对象分布式化 • Distributify standard Java Objects • Java对象映射为Redis的 • Java Objects maps to Redis hash hash结构 • 支持内嵌复杂结构 • Support nested and complex structure
  • 42.分布式服务中间件 Distributed Services Middleware 执行服务 Executor Service • 实现了Java的ExecutorService 接口 • Supports ExecutorService Java interface • 支持Callable和Runnable任务 • Supports Callable & Runnable tasks • 支持Redisson独立运算节点 • Supports Redisson Node execution • 任务支持Redisson依赖注入 • Supports Redisson instance injection in tasks
  • 43.分布式服务中间件 Distributed Services Middleware 调度任务服务 Scheduler Service • 实现了Java的 ScheduledExecutorService接口 • 支持所有分布式执行服务功能 • 支持Quartz的CRON格式定义触发 • Supports ScheduledExecuterService Interface • Supports all features of Executor Service • Supports CRON notation for execution time and frequency
  • 44.分布式服务中间件 Distributed Services Middleware MapReduce服务 MapReduce Service • RMap,RSet,RList和 RQueue提供均支持MR服务 • 提供Mapper,Reducer和 Collator接口 • Provides MapReduce service to RMap, RSet, RList and RQueue • Supports Mapper,Reducer and Collator Interface • 支持Redisson独立运算节点 • Supports Redisson Node execution • 支持并行执行二次拆分的任务 • Supports Splitting and concurrent execution for both Map and Set based types
  • 45.Redisson独立运算节点 Redisson Node • 分布式独立计算节点,微服务节点 • 可参与执行所有分布式服务提交的任务 • 可以嵌入运行在业务JVM • 亦可独立运行,提供可执行Jar包和Docker镜像 • Distributed compute node and micro service node • Can participate in all tasks submitted by distributed services • Can be embedded into application • Can also be ran as an independent process • Provides Docker image and executable Jar
  • 46.Redisson独立运算节点 Redisson Node Redisson Node 运算节点 Redisson Node 运算节点 Redisson Node 运算节点 Redis (单机,主从,哨兵,集群或云平台) 业务JVM Redisson 客户端 业务JVM 业务JVM Redisson Redisson 客户端 客户端
  • 47.改造方案的实施 Ready, Steady, Action!
  • 48.数据缓存方案 Data Oriented Caching Solution Id 1 2 3 4 数据库 内存 Database Memory table1 map1 Column1 A1 A2 A3 A4 Column2 B1 B2 B3 B4 Column3 C1 C2 C3 C4 SELECT * FROM table1 WHERE id = ? 缓存 Cache Key 1 2 3 4 Value {id:1,column1:'>column1: