当前位置:网站首页>Thoughts on project development
Thoughts on project development
2022-07-03 06:59:00 【W_ Meng_ H】
Nearly period of time , Then reorganize your knowledge structure , I have some ideas about project concurrency and optimization , Take a brief note of ; You guys have good suggestions and ideas , Hope to share , If there are mistakes in the content , Hope to point out , thank !
Highly concurrent projects are hard to reach , But programmers , We can create some concurrency by ourselves ( Although it's very low , Ha ha ha )
I have written a small second kill before Demo, interested , You can look at it .
seckill Demo:https://github.com/Vmetrio/spike.git
For this project , I'm thinking about how to optimize , Solve the problem of a large number of visits !
One 、 Single machine performance optimization
① Use Jmeter、wrk Isobaric tool , Of pressure measurement items QPS and TPS.
QPS: full name Queries Per Second, intend “ Query rate per second ”, Is the number of queries a server can respond to per second , It is a measure of how much traffic a specific query server handles in a given period of time .
To put it simply ,QPS = req/sec = Number of requests / second . It represents the performance and maximum throughput of the server machine .
TPS namely Transactions Per Second Abbreviation , The number of transactions processed per second . A transaction is a process in which a client sends a request to the server and the server responds .
The client starts timing when it sends the request , End timing after receiving server response , This is used to calculate the time used and the number of transactions completed , The final assessment score made with this information .
TPS The process includes : The client requests the server 、 Server internal processing 、 The server returns to the client .
QPS It's basically like Tps, But here's the difference , A visit to a page , To form a TPS; But a page request , There may be multiple requests to the server , The server requests for these , You can count in “QPS” In .
for example , Visit one Index The page will request the server 3 Time , Including once html, once css, once js, Then visiting this page will produce a “T”, Produce three “Q”.
② I'm on a real project , Use wrk During pressure measurement , Different modules of the project , Performance is different , In fact, each module has different concurrency indicators , have access to wrk, Write pressure test scripts for different modules .
③ Single machine optimization , Need to be right JVM tuning ; In the case of multithreading , Also consider whether the variables used are thread safe , for example :HashMap The problem that leads to the dead cycle ,( stay put During operation , When two threads are triggered at the same time rehash operation , A closed loop )
④ JVM And code optimization , We will encounter database problems ,mysql The default maximum number of connections to the database is 100, More connections , It will make the database unavailable . therefore , The whole project needs to use load to solve new problems .
Two 、 Load balancing shares the access pressure
① When users visit , We can use Nginx To do the load balancing of the project ( polling 、ip_hash、 Rules such as weighting ), Deploy the project to multiple servers .
② The project is behind multiple servers , Still haven't solved the problem of database , For many visits , Little change in data , We can use cache to solve , Use redis As cache middleware , At the same time, it can also solve the sharing among multiple projects session problem ( User information, etc ).
③ Again using wrk Pressure test each module of the project , There will be new problems ( For example, server configuration 、 Different performance , The processing capacity is also different , You need to adjust the load algorithm ,Nginx Polling weighting of )
3、 ... and 、 Use middleware for different modules
① Full text search elasticsearch; Message queue kafka; cache redis; Microservices springcloud; Load balancing nginx、zookeeper wait .
② Component clustering , To avoid a single point of failure , Cluster the components , To maintain high availability .
③ You need to learn and understand the ideas and underlying principles of various components , Use different technologies for different business scenarios .
④ Project degradation , Current limiting treatment, etc .
1、 Modules can process asynchronously , Using asynchronous processing
2、 Using caching technology
To be continued ......
QPS、TPS What is it? :https://www.cnblogs.com/leadership/p/11555409.html
边栏推荐
- php artisan
- Yolov1 learning notes
- Stream stream
- 万卷书 - 价值投资者指南 [The Education of a Value Investor]
- VMware virtual machine C disk expansion
- 卡特兰数(Catalan)的应用场景
- New knowledge! The virtual machine network card causes your DNS resolution to slow down
- Know flex box
- Liang Ning: 30 lectures on brain map notes for growth thinking
- Redis command
猜你喜欢

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库

Software testing assignment - day 1

Arctic code vault contributor

Golang operation redis: write and read kV data

golang操作redis:写入、读取kv数据

golang操作redis:写入、读取hash类型数据
![[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)](/img/7f/3d6b6ea5319f7165e07baf0a78d318.jpg)
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
![Gridome + strapi + vercel + PM2 deployment case of [static site (3)]](/img/65/8d79998e96a2c74ba6e237bee652c6.jpg)
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]

Software testing learning - the next day

Selenium - by changing the window size, the width, height and length of different models will be different
随机推荐
Yolov3 learning notes
Simple understanding of bubble sorting
Use the jvisualvm tool ----- tocmat to start JMX monitoring
修改MySQL密码
[day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
Class and object summary
Software testing assignment - day 1
Thoughts in Starbucks
每日刷題記錄 (十一)
Asynchronous programming: async/await in asp Net
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
Operation principle of lua on C: Foundation
Centos切换安装mysql5.7和mysql8.0
DNS forward query:
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
PHP install the spool extension
EasyExcel
How to specify the execution order for multiple global exception handling classes
Golang operation redis: write and read hash type data