1、超时关单
- delayQueue
- 延迟队列不支持分布式
- RocketMQ
- 延迟投递
- Redis
- 设置过期时间
- 监听过期事件
- 定时任务(阿里)
- 定时任务搂数据库(对数据库有压力)
- 超时中心
2、分布分表如何进行分页查询
- 采用es,由es完成分页查询(在es中数据冗余)
- 采用映射表(维护成本较高)
- 内存合并所有分片的查询结果
3、减少线程池中的阻塞时间
- 核心线程数、最大线程数
- 线程数在核心线程数与最大线程数之间,会加入阻塞队列进行等待
- 重写阻塞队列的offer方法(判断下是否到达最大线程数)
public void execute(Runnable command) {if (command == null)int c = ctl.get();//是否达到核心线程数if (workerCountOf(c) < corePoolSize) {if (addWorker(command, true))return;c = ctl.get();}//阻塞队列是否满if (isRunning(c) && workQueue.offer(command)) {int recheck = ctl.get();if (! isRunning(recheck) && remove(command))reject(command);else if (workerCountOf(recheck) == 0)addWorker(null, false);}//释放达到最大线程数else if (!addWorker(command, false))reject(command); }