当前位置:网站首页>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;
}
边栏推荐
- Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
- Apt command reports certificate error certificate verification failed: the certificate is not trusted
- Latex在VSCODE中编译中文,使用中文路径问题解决
- 实现strStr() II
- table 组件指定列合并行方法
- Build learning tensorflow
- CUDA and Direct3D consistency
- 默认google浏览器打不开链接(点击超链接没有反应)
- Redis - big key problem
- 由於不正常斷電導致的unexpected inconsistency;RUN fsck MANUALLY問題已解决
猜你喜欢
随机推荐
Latex在VSCODE中编译中文,使用中文路径问题解决
Blog directory of zzq -- updated on 20210601
sprintf_ How to use s
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
table 组件指定列合并行方法
CUDA and Direct3D consistency
Does the assignment of Boolean types such as tag attribute disabled selected checked not take effect?
[literature reading and thought notes 13] unprocessing images for learned raw denoising
Linked list (linear structure)
Redis——大Key问题
Code skills - Controller Parameter annotation @requestparam
Latex参考文献引用失败 报错 LaTeX Warning: Citation “*****” on page y undefined on input line *
sprintf_s的使用方法
2020-9-23 use of QT timer qtimer class.
MySql索引
20201025 Visual Studio2019 QT5.14 信号和槽功能的使用
selenium+msedgedriver+edge浏览器安装驱动的坑
自学table au
Three suggestions for all students who have graduated and will graduate
Fe - use of weex development weex UI components and configuration use