当前位置:网站首页>Stress test modification solution
Stress test modification solution
2022-07-02 06:44:00 【Dairyzz】
primary :
Introduce
The project is xxl-job Next scheduled task Own an actuator Therefore, it can be enabled according to one node Exclusive port
The project java Package configuration :
jdk8
Memory size :2GB
Do not use third-party caching and message processing software Pure primary
Business content : Accept messages of Foreign Exchange , Analytic message , Determine the message type , Judge the primary key of the message to be processed , Update if in the database , If not in the database, insert ( The number of message primary keys is small , Mainly update , The operation of inserting is negligible )
Processing mode : Adopted LinkedBlockingQueue Put all the received messages into the queue
Then start another thread to process the queue information Then judge whether the message is processed before database operation
Under pressure test :
The pressure test time is one hour and the data volume is one million , The amount of data to be processed is 5w about
Pressure test 10 Minutes less than Queue memory exceeded 2G The direct stack is full
PLAN1
Processing mode : Judge and process the message before inserting it into the queue , Only the messages that need to be processed are added to the blocking queue
Under pressure test :
A little smoother than the original way , but 20 Minutes or so, the stack exploded , Check the log and find that the queue has been inserted within one second 100 Data to be processed , But one second only deals with 10 Data , The processing speed is far from keeping up .
PLAN2
Processing mode : Put the message into memory , Create a management class , The thread receiving the message calls this managed class to insert the message into the corresponding map in , The thread processing the message calls this managed class to take out the data that needs to be updated and update .
The reason for this treatment : The processing speed in memory is faster than that of querying the database to determine whether to process , Many messages correspond to the same primary key, and the operation of the database is more about updating , Will not squash the stack
Processing steps :
- Create a message class that is compatible with all message fields ( Take the union of all messages ) And whether to update the field
- Create a management class There is a private map key Primary key value It is a message class There is an add method in the management class , Set the received message update field to true, And then put in map in , There is also a method in the management class to get the message queue that needs to be updated , First new A blocking queue pair map Traversal will update the field to true The message class update field of is set to false Then put it into the blocking queue , Finally, return to the blocking queue
- The thread receiving the message calls the add method The thread processing the message calls the method of obtaining and updating the message queue , Process the data in the queue
Because these two methods are similar to write and read operations , So both methods should be locked
Writing of management class :
private HashMap<String, BankQuoteNode> quoteMap = new HashMap<>();//k It is your primary key
@Override
public synchronized void addQuote(BankQuoteNode node) {
node.setUpdateFlag(true);
StringBuilder key = new StringBuilder();
key.append(node.getMarketInicator()).append('-').append(node.getSecurityCode()).append('-').append(node
.getSecurityName());
String quoteMapKey=key.toString();
quoteMap.put(quoteMapKey,node);
}
@Override
public synchronized Queue<BankQuoteNode> getAllQuote() {
LinkedBlockingQueue<BankQuoteNode> quoteQueue =new LinkedBlockingQueue<>();
quoteMap.forEach((k,v)->{
quoteQueue.add(v);
});
return quoteQueue;// Back to all
}
@Override
public synchronized Queue<BankQuoteNode> getRefreshedQuote() {
LinkedBlockingQueue<BankQuoteNode> refreshedQuoteQueue = new LinkedBlockingQueue<>();
// Traverse quoteMap
// hold UpdateFlag=true Of node Insert the returned queue
quoteMap.forEach((k,v)->{
if(v.isUpdateFlag()){
quoteMap.get(k).setUpdateFlag(false);
refreshedQuoteQueue.add(v);
}
});
return refreshedQuoteQueue;
}
边栏推荐
- Alibaba cloud MFA binding Chrome browser
- apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted
- Warp shuffle in CUDA
- Self study table Au
- How to try catch statements that return promise objects in JS
- Sentinel Alibaba open source traffic protection component
- The intern left a big hole when he ran away and made two online problems, which made me miserable
- Automation - when Jenkins pipline executes the nodejs command, it prompts node: command not found
- Win10网络图标消失,网络图标变成灰色,打开网络设置闪退等问题解决
- 20201002 vs 2019 qt5.14 developed program packaging
猜你喜欢

Pytest (1) case collection rules

Idea announced a new default UI, which is too refreshing (including the application link)

Warp shuffle in CUDA

查询GPU时无进程运行,但是显存却被占用了

如何调试微信内置浏览器应用(企业号、公众号、订阅号)

实现strStr() II

pytest(1) 用例收集规则

Latex compiles Chinese in vscode and solves the problem of using Chinese path

Redis - big key problem

Sentinel Alibaba open source traffic protection component
随机推荐
Latex error: the font size command \normalsize is not defined problem solved
eslint配置代码自动格式化
ctf-web之练习赛
Sentry搭建和使用
[literature reading and thought notes 13] unprocessing images for learned raw denoising
ModuleNotFoundError: No module named ‘jieba.analyse‘; ‘jieba‘ is not a package
js的防抖和节流
Virtualenv and pipenv installation
Build learning tensorflow
PgSQL学习笔记
The intern left a big hole when he ran away and made two online problems, which made me miserable
20201025 visual studio2019 qt5.14 use of signal and slot functions
Error "list" object is not callable in Web automatic switching window
Selenium+msedgedriver+edge browser installation driver pit
Render minecraft scenes into real scenes using NVIDIA GPU
Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
Record RDS troubleshooting once -- RDS capacity increases dramatically
Nodejs - Express middleware modification header: typeerror [err_invalid_char]: invalid character in header content
奇葩pip install
Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)