当前位置:网站首页>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
边栏推荐
- Yolov2 learning and summary
- MySQL mistakenly deleted the root account and failed to log in
- (翻译)异步编程:Async/Await在ASP.NET中的介绍
- In depth analysis of reentrantlock fair lock and unfair lock source code implementation
- The difference between CONDA and pip
- Class and object summary
- mongodb
- 爬虫代码基础教学
- Pytest -- write and manage test cases
- Notes on the core knowledge of Domain Driven Design DDD
猜你喜欢

HMS core helps baby bus show high-quality children's digital content to global developers

vmware虚拟机C盘扩容

Software testing learning - day one

100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
![[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle](/img/f8/0e3fbfd13bf06291a73200552ff17a.png)
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle

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

dataworks自定義函數開發環境搭建

2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)

How to migrate or replicate VMware virtual machine systems

Pytest -- write and manage test cases
随机推荐
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
How to plan well?
Yolov1 learning notes
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
[LeetCode]404. Sum of left leaves
Selenium - by changing the window size, the width, height and length of different models will be different
Liang Ning: 30 lectures on brain map notes for growth thinking
Interface learning
爬虫代码基础教学
A letter to graduating college students
Climb movie paradise 2021 hot
PHP install the spool extension
2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
crontab定时任务
Unit test notes
Error c2017: illegal escape sequence
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
[day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
Golang operation redis: write and read hash type data
保险公司怎么查高血压?