当前位置:网站首页>Get the way to optimize the one-stop worktable of customer service

Get the way to optimize the one-stop worktable of customer service

2022-07-07 05:44:00 Acquisition technology

original | Get things Technology - The aftereffect

1. background

The customer service one-stop workbench includes online 、 Telephone 、 Four functional modules of work order and tools . Many of these general modules , For example, work order details 、 The order details are through iframe Nested form , It will be time-consuming in the process of system loading , In addition, the online message communication module is strongly dependent on tinode The third party SDK, Many methods are called directly tinode Provided API, At the same time, he inherited tinode Many unreasonable ways , From using tinode up to now , Due to the investment of iteration resources , I haven't been right tinode Optimize and improve the source code , When the mode of message communication is changed to broadcast , The conversation jam problem is exposed .

Through to tinode Read the source message link module , Found a lot of optimization space , This paper describes the specific optimization implementation of message link .

2. Find the problem

2.1 There are defects in the message data processing process

Yes tinode The third party SDK Reading source code , Found that the customer service is “ receive ” and “ send out ” There is a lot of optimization space on the message link , In the original logic , From sending messages to quickly rendering pages to tinode Respond to the returned results and then refresh the rendered page , And when customer service receives the message , The whole message will be refreshed , Deserialization 、 Sort 、 duplicate removal 、 State processing and so on , It takes many cycles , In addition, the communication mode is changed to broadcast mode , Large data cyclic tasks , It's a serious challenge for performance .

 Get the way to optimize the one-stop worktable of customer service

Customer service “ receive ” and “ send out ” Overview of message link ( One )

 Get the way to optimize the one-stop worktable of customer service

Customer service “ receive ” and “ send out ” Overview of message link ( Two )

In the figure The red area has more for Loops are the most time-consuming scenarios , The reason is to obtain the communication records between users and customer service ( The original tinode Methods provided in ,topic.message() Will execute n Time ), Deserialization 、 Session state processing 、 Sort 、 De duplication will traverse all chat messages , among Deserialize to the most time-consuming scenario , If the customer service has more previous chat messages with users , The more iterations , The longer it takes , Plus JavaScript A single thread , More traversal times will form a block , This leads to customer service switching sessions quickly , The cycle is not over yet , Page not rendered , There is a Caton phenomenon .

3. Optimization idea

When each user enters the line from the client to the customer service workbench , A session will be generated id(sessionId), Every conversation id There will be a message in each of the following human messages id(msgid) There are many rounds of communication between customer service and users , In order to reduce the “ Old code ” Operations that degrade performance in multiple cycles , The thought of Core tasks Try to avoid traversing the chat message data ( Because there's too much news ), Follow the principle of not traversing chat messages , For... In the original logic “ duplicate removal ” and “ Sort ” The logic has been rewritten , This is the time , The conversation mentioned above id And news id Has played a very important role .

3.1 duplicate removal

In this optimization scheme, a global maintenance method is adopted msgidCacheMaps Map data structure , This data structure has two dimensions ,sessionId  and  msgid , Used to save the current session (sessionId) Of each message in the msgid, In the message conversation , Messages sent by human customer service will experience from Virtual messages To True news Two phases ( The virtual message here refers to in a human session , After the customer service sends a message to the gateway , In order to quickly display messages in the chat area , Through the previous message seq + 0.002 Generate virtual seq namely :virtualSeq, Wait until the gateway returns the real seq after , then virtualSeq Replace it with real seq), The virtual message phase will save msgid To Map in , For messages pushed by the system , No, msgid, You don't need to go through this process , Put it directly into the session pool , True news (tinode return seq) Stage , according to msgid To msgidCacheMaps Map Query in data structure , There is this msgid, Description is duplicate data , coordination seq Replace it .

3.2 Sort

This optimization scheme adopts   Binary search insertion sort Methods , Maintain a seqCacheMaps Map data structure , This data structure is similar to the above de duplication , There are also two dimensions ,sessionId and seq, Binary search insertion sorting method , use seq( real seq) and virtualSeq( fictitious seq) As a basis for finding , Every time a message comes in , Quickly find the current... According to the dichotomy seq Pluggable position , Virtual message phase , Directly inserted into the , The real news phase (msgidCacheMaps There is this msgid), Direct replacement , But there is a problem at this time , Because in the process of manual conversation, every message sent by customer service to users will be checked for sensitive words at the gateway , If the sensitive word is not triggered, the message will be sent to the customer service side and displayed to the user , If a sensitive word is triggered , Messages containing sensitive words will be intercepted by the gateway , The message will not reach the user side , At this time, the gateway will not return seq, Then there is no return seq, How to deal with it ? That's it stay tinode Return phase , Will the front virtualSeq Replace with Previous message seq + 0.002, Make sure its location is orderly and will not be displayed disorderly in the chat area .

 Get the way to optimize the one-stop worktable of customer service

“ duplicate removal ” and “ Sort ” Overview

3.3 Cache recovery ( End session destroy )

on top   duplicate removal   and   Sort   I mentioned , To reduce the number of iterations , Maintain two data warehouses globally (msgidCacheMaps Map data structure 、seqCacheMaps Map data structure ), however Every customer service everyday The number of conversations is 100+, Plus The number of back and forth messages between customer service and users in each session is about 40+, If the customer service goes to check the historical news again , One page 20 strip , If you only save without deleting , The amount of data stored is still relatively large , Easy to cause memory overflow , So when is it more appropriate to delete ? According to the business situation , The last choice is End the conversation 、 Session transfer 、 Push offline In this case, it will be attached to the global hash map To destroy , Free memory .

 Get the way to optimize the one-stop worktable of customer service

data “ Storage ” and “ Delete ” Overview

3.4 Message state

The message status here refers to : read 、 unread 、 Received 、 In sending 、 Sending failed .

In the process of customer service and user communication , The message status displayed on the customer service side and the user side is updated in real time , Customer service sends a message to the user , When the user reads this message, it will return info agreement ( Push message notification ) tell h5 This message has been read , then h5 The side updates the status of this message .

  • The original treatment : When the customer service sends a message to the user , Traverse all the historical messages of this user in the current session , Perform all reset operations , At this time, if there are many messages communicated between users and customer service , It will lead to more traversal times , Serious performance consumption and other problems .
  • Optimization plan : First filter out historical messages and messages sent by non customer service , Find the message by dichotomy , Then change the state directly . After receiving the message sent by the user , Yes messagePools( All sessions of the current user ) Medium Messages sent by customer service Update the status to read in reverse order , Because now that users have sent messages , It means that the message sent by customer service has been read , There is no need to traverse every message to set the state according to the old logic , Waste performance , Except for sending and sending failed messages , Render all as read .
    • Send a message : At present, sending a message will only execute 2 Time , For the first time, the message will be quickly displayed on the communication page , Then send the message (wss), When I received ack after , The secondary message status update will be carried out , Only pass msgid You will find the message that needs to be updated to update , No longer need to use tinode Provided topic.message Method to traverse the whole quantity ;
    • receive messages : The customer service will only trigger a message update when receiving a user message , There is no need to traverse the full amount of data of the current user and update the new status , It will also return to ack;
    • Concrete realization : Client push long chain note Events tell H5,H5 The side records the message that has been read seq, For less than or equal to seq Update the status of the message data sent by the customer service , namely :recv( Received ) => read( read ).

3.5 Sensitive word interception processing

IM Chat page after the user enters the line , For the messages sent between the user and the agent customer service, the line sensitive words will be monitored ( Monitor only and Prohibit sending ).

  • Original plan : Agent customer service after editing the message , Click Send , Call the back-end sensitive word interface , It is not triggered. It can be sent out only after the sensitive word verification passes , In case of network fluctuation, when the interface returns slowly , It will make the customer service feel that they can't go out until they send a message card .
  • Optimization plan : Intercept through the gateway , When customer service sends a message , Render directly to the chat area , The gateway checks whether the sent message triggers sensitive words , If there is a trigger to a sensitive word , Then the gateway will return a status to tell h5,h5 Then change the status according to the returned results to prompt the customer service .

 Get the way to optimize the one-stop worktable of customer service

Logical overview of sensitive words

4. Data comparison before and after optimization

Optimize the link technology scheme to realize the overall release and launch on a certain day , therefore Take the release day as the time cutoff , Pull the data comparison before and after optimization , The details are as follows .

4.1 Before optimization

 Get the way to optimize the one-stop worktable of customer service

 

As shown in the figure above , Two data indicators of the total incoming line in a certain period of time are counted :

  • Average first response time :8.40 second
  • Average response time :19.9 second

4.2 After optimization

 Get the way to optimize the one-stop worktable of customer service

As shown in the figure above , Two data indicators of the total incoming line in a certain period of time are counted :

Average first response time :6.82 second , Less than before optimization 1.58 second

Average response time :18.22 second , Less than before optimization 1.68 second

5. summary

Generally speaking IM The number of users and activity of products are usually very large , At some special time points, it is often easy to cause flow peaks , Therefore, the technology needs to be able to deal with the magnitude of emergencies , meanwhile IM Generally, it mainly includes this 4 Characteristics : The real time 、 reliability 、 Uniformity 、 Security , about IM There is still a long way to go to optimize , Under the condition of ensuring business stability , In the future, we will continue to polish around the four characteristics , Let the things in line have their own IM SDK More and more perfect , Form the benchmark of industry information communication .

 

* writing / The aftereffect

Focus on Technology , Every Monday, three or five nights 18:30 Update technology dry goods
If you think the article is helpful to you , Welcome to comment and forward some likes ~

原网站

版权声明
本文为[Acquisition technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062353373084.html