Data Structure Design

Source: Internet
Author: User

Recently, I am working on a statistical project about network access.

The background is that a single access device can access dozens of users, and each user may call at the same time.

To collect phone data for each user, and store historical data.

First, you need to know that each user needs to save historical data, so it is inevitable to add, delete, and query data during data persistence.

This process, especially when searching, is time-consuming.

Another important point is that we only use a thread to record data for users. That is to say, after a user's call ends, we will calculate data for the user until the end of the persistent data.

And then serve another user.

This poses a problem. When multiple users end the call at the same time, the processing process is unsatisfactory. After the first user finishes processing the call, the session is persisted, and then the second user is processed, this will cause data inaccuracy to the second user.

The solution we came up with is to separate computing from persistence. Because the computing time complexity is relatively small. The time complexity of persistence is relatively large.

So the design is

A thread only calculates the call and pushes it to the linked list after the calculation.

This linked list is like a buffer, and the input end is like the I/O of our computer.

It just means that the input table of the computer is slow and the processing is fast. On the contrary, the data is fast and the processing is slow (persistent ).

The other thread processes the list every two seconds or one second. In this way, the processing is more even.

In the list.

Uniform processing list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.