写点什么

架構師訓練營 week7 總結

用户头像
ilake
关注
发布于: 2020 年 11 月 08 日

7.1 性能测试:系统性能的主要技术指标


Performance testing

subjective view
  • User’s real feeling

objective view
  • Performance metrics

  • Response time

  • Concurrent 

  • Concurrent = Throughput x Latency

  • Throughput => system Processing efficiency

  • Latency  => The length of time the user feels

  • Throughput

  • TPS

  • HPS

  • QPS

  • Throughput vs Latency

  • In short, the throughput is a function of how many stages are in parallel while latency is a function of how many are in series when there are multiple stages in the processing. The stage with the lowest throughput determines the overall throughput.


Different names for different concurrent level testing

  • Performance testing

  • Load testing

  • Add more concurrent requests

  • Stress testing

  • More concurrent requests until system crashes

  • Stability testing





7.2 全链路压测的挑战


Whole business stress testing

  • Stress testing on all related business services to simulate real users’ behaviors

  • How to generate mass testing data

  • How to simulate without any effect on the production environment

Data isolation

  • Logical isolation 

  • Put testing data and real data together

  • Might affect production data

  • Virtual isolation

  • Use mock testing, do not write testing data to the production environment

  • Mock data might not be correct

  • Physical isolation

  • Real write testing data to other places



7.3 性能优化:系统性能优化的分层思想

  1. You can't optimize the software which doesn’t have any testing

  2. You can’t optimize the software which you don’t really know 


  1. Response time: time of finishing the task

  2. Concurrent: Number of tasks processed simultaneously

  3. Throughput: Number of tasks completed per unit time

  4. Performance matrix: System load, Process, Thread, CPU, Memory, Disk, network usage


General methods

  1. Get performance data

  2. Analyze performance data

  3. Analyze architecture and code to find bottleneck

  4. Optimize architecture and code

  5. Performance testing again


Optimization layers

  1. Network

  2. Server/hardware

  3. OS

  4. Virtual system

  5. Fundamental component (Nginx, Jboss….)

  6. Software architecture

  • cache

  • async

  • Cluster

  1. Software code

  • Concurrent processing

  • Multi-thread and lock

  • Resource reusing

  • Thread pool and object pool

  • Async processing

  • Producer and consumer

  • Data structure



7.4 操作系统:计算机如何处理成百上千的并发请求?

Process/ Thread/ Cpu Core


Process/Thread status 

  • Processing

  • Ready

  • Wait


7.5 锁:锁原语 CAS 与各类锁


CAS(Compare and swap)


E,V,N

  • E => original object’s value

  • V => value after updating the original object

  • N => check original object’s value again before an update


Get E => want to update to V => compare E and N again

  1. If E == N => update to V

  2. If E != N => failed, back to get E again


Locking

  • Biased Lock

  • Lightweight Lock

  • Other threads will use spinlock

  • Heavyweight Lock

  • Affect performance, others need to wait

  • 總線鎖

  • Use CPU lock signal

  • Cache lock

  • FairSync - lock

  • NonFairSync - lock

  • 可重入鎖

  • ReentrantLock (獨享)

  • Only one thread can the lock at the same time

  • Shared lock

  • Write lock

  • Pessimistic lock

  • Think all operations are for update => so lock everything

  • Optimistic lock

  • Think all operation are not for update => default unlock => but if it finds some object changed when it wants to update=> then give up that update

  • 分段鎖

  • 自旋鎖


用户头像

ilake

关注

还未添加个人签名 2019.04.15 加入

还未添加个人简介

评论

发布
暂无评论
架構師訓練營 week7 總結