当前位置:网站首页>Parallelism, concurrency and several directions for high concurrency optimization
Parallelism, concurrency and several directions for high concurrency optimization
2022-07-26 10:35:00 【Fan Xuebo】
Reprinted , Personal reservation , Forgive me for moving bricks this time , After all, moving bricks is my job ?
1. The difference between concurrency and parallelism
- Concurrent : When there are multiple threads operating , If there is only one system CPU, hold CPU The running time is divided into several time periods , Assigned to each thread to execute , In a period of time when the thread code runs , Other threads are in suspended state . This way we call concurrency (Concurrent). Concurrent = Interval occurrence
- parallel : When the system has more than one CPU when , Then the thread operation may be non concurrent . When one CPU When executing a thread , the other one CPU Another thread can be executed , Two threads do not preempt each other CPU resources , You can do it at the same time , This way we call parallel (Parallel). parallel = At the same time
- High concurrency is one of the factors that must be considered in the design of Internet distributed system architecture , It usually refers to the design to ensure that the system can process many requests in parallel at the same time .
- difference : Parallel is when two or more events occur at the same time ; Concurrency means that two or more events occur at the same time interval .
2. High concurrency refers to a large number of accesses and requests in a short time , for example 12306 Ticket grabbing and tmall double 11 Activities , Want the system to be able to adapt to high concurrency , It needs to be comprehensively optimized , Include , Hardware 、 The Internet 、 System architecture 、 Selection of development language 、 The use of data structures 、 Algorithm optimization 、 Database optimization …… Multithreading is only one of the solutions .
The role of multithreading in solving the problem of high concurrency is to maximize the utilization of computer resources at every moment , So as not to waste computer resources and make them idle
3. High concurrency needs to be considered :
- Architecture design of the system , How to reduce unnecessary processing at the architecture level ( Network request , Database operation, etc )
- Network topology optimization reduces network request time 、 How to design topology , How to implement distributed ?
- Code optimization at the system code level , What design patterns are used to work ? Which classes need singletons , What needs to be minimized new operation ?
- Improve the efficiency of the code level 、 How to select the appropriate data structure for data access ? How to design an appropriate algorithm ?
- Synchronous and asynchronous operations at the task execution mode level , Where to use synchronization , Where to use asynchronous ?
- JVM tuning , In order to server Mode or clien mode , How to set up Heap、Stack、Eden Size , How to choose GC Strategy , control Full GC The frequency of ?
- Database optimization reduces query modification time . Database selection ? The selection of database engine ? Design of database table structure ? Database index 、 Trigger design ? Whether to use read-write separation ? Still need to consider using data warehouse ?
- Use of cache database , How to choose the cache database ? yes Redis still Memcache? How to design caching mechanism ?
- Data communication problems , How to choose the mode of communication ? Use TCP still UDP, Long connection or short connection ?NIO still BIO?netty、mina Still original socket?
- Operating system selection , It's using winserver still Linux? perhaps Unix?
- hardware configuration ? yes 8G Memory or 32G, network card 10G still 1G?
边栏推荐
猜你喜欢

SAP ABAP Netweaver 容器化的一些前沿性研究工作分享
![[Halcon vision] image filtering](/img/4b/e73a8d589b49276d96621f0ef02449.png)
[Halcon vision] image filtering

MLX90640 红外热成像仪测温传感器模块开发笔记(六)红外图像伪彩色编码

Uniapp uses the simple method signalr (only for web debugging, cannot package apps)

The difference between equals and = =

抓包工具fiddler和wireshark对比

uniapp使用简单方法signalR(仅用于web调试,无法打包app)

【机器学习小记】【搭建循环神经网络及其应用】deeplearning.ai course5 1st week programming(keras)

videojs转canvas暂停、播放、切换视频
![[leetcode每日一题2021/2/14]765. 情侣牵手](/img/be/8639a05c733638bf0b3fdeb11abccf.png)
[leetcode每日一题2021/2/14]765. 情侣牵手
随机推荐
.net operation redis sorted set ordered set
卸载魅族应用商店
Tradingview tutorial
Uniapp uses the simple method signalr (only for web debugging, cannot package apps)
PTA class a 1001
Redis特殊数据类型使用场景
PTA class a 1002
.net operation redis hash object
记给esp8266烧录刷固件
Uninstall Meizu app store
一些你不知道的 web API
议程速递 | 7月27日分论坛议程一览
并行、并发及对于高并发优化的几个方向
12 复制对象时勿忘其每一个成分
Navicat15 MySQL (centos7) connected to local virtual machine
string null转空字符串(空字符串是什么意思)
Okaleido ecological core equity Oka, all in fusion mining mode
抓包工具fiddler和wireshark对比
结构体操作报错:Segmentation fault (core dumped)
Redis docker instance and data structure