当前位置:网站首页>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
边栏推荐
- Unittest attempt
- Understand software testing
- 2022-06-23 VGMP-OSPF-域間安全策略-NAT策略(更新中)
- Code management tools
- instanceof
- 这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
- 如何迁移或复制VMware虚拟机系统
- [open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
- 【无标题】
- These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
猜你喜欢
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
dataworks自定義函數開發環境搭建
Selenium - by changing the window size, the width, height and length of different models will be different
Flask Foundation
【无标题】
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
My 2020 summary "don't love the past, indulge in moving forward"
Software testing assignment - the next day
Notes on the core knowledge of Domain Driven Design DDD
随机推荐
Code management tools
php artisan
JS date comparison
CentOS switches and installs mysql5.7 and mysql8.0
[set theory] partition (partition | partition example | partition and equivalence relationship)
HMS core helps baby bus show high-quality children's digital content to global developers
File links cannot be opened or downloaded in Google browser
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
MySQL transaction rollback, error points record
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
golang操作redis:写入、读取hash类型数据
2022 cisp-pte (III) command execution
JMeter test result output
Thoughts in Starbucks
Pits encountered in the use of El checkbox group
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
Simple understanding of bubble sorting
[LeetCode]404. 左叶子之和
How to plan well?
2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution