当前位置:网站首页>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
边栏推荐
- JS date comparison
- [C /vb.net] convert PDF to svg/image, svg/image to PDF
- The essence of interview
- Laravel frame step pit (I)
- Software testing assignment - the next day
- Realize PDF to picture conversion with C #
- centos php7.3安装redis扩展
- php artisan
- Application scenarios of Catalan number
- Win 10 find the port and close the port
猜你喜欢

Software testing learning - the next day

JMeter test result output

Practice of enterprise ab/testing platform

Inno setup production and installation package

Software testing learning - day 3

IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library

HMS core helps baby bus show high-quality children's digital content to global developers
![[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

Win 10 find the port and close the port

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
随机推荐
Search engine Bing Bing advanced search skills
error C2017: 非法的转义序列
机械观和系统观的科学思维方式各有什么特点和作用
The 10000 hour rule won't make you a master programmer, but at least it's a good starting point
机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
Architecture notes
RestHighLevelClient获取某个索引的mapping
Setting up the development environment of dataworks custom function
爬虫代码基础教学
The essence of interview
Practice of enterprise ab/testing platform
Shim and Polyfill in [concept collection]
Unittest attempt
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
Laravel frame step pit (I)
Journal quotidien des questions (11)
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
每日刷題記錄 (十一)
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
多个全局异常处理类,怎么规定执行顺序