The reference of American Highway system to IT system

Source: Internet
Author: User

I had a two-week tolerance in May 12 to the United States, and I was impressed by the developed and efficient highway system in the United States.

We often hear that the United States is the country on wheels, in a sense, the efficiency of the highway system directly affects the labor productivity of the people, and the sound of the road network has promoted the balance between urban and rural areas.

Here I try to record some of the American Highway system's reference to IT system from the point of view of performance.

I. Read and write separation

American highways are mainly divided into interstate highways, state highways, rural highways 3 levels, roughly corresponding to China's highways, national road, provincial roads.

The interstate is the trunk of a truck, with a wide barrier between the two directions of the road. Although the state highway does not necessarily have a barrier, it is at least underlined to distinguish the direction of travel. and rural roads because of small traffic, often only one lane, so there is no need to distinguish and mark.

In the language of it, this design is equivalent to read-write separation.

From the point of view of demand, read and write operations are part of the normal process, from the logic to understand and there is no particularity. But if read and write target the same database object, then we have to consider the effect of concurrency: the lock table caused by the write operation causes the read operation to wait.

According to the object-oriented methodology, if the read and write targets the same object, then after the object has been mapped, all of the properties for the operation should be placed in the same table, then the logic of this mapping relationship is the most concise.

For example, for object A, to read attribute 1, to write property 2, then the mapping, equivalent to read table A field 1, Write Table a field 2. Because these two properties are placed in the same table, a write to field 2 causes lock protection for this row of data in table A, until lock protection is lifted (Commit/rollback) to perform the read operation of this row of data. Therefore, this design can have a performance impact.

Give an example of a production system.

For example, work orders This object, there are ticket metadata such as planned production date, product number, quantity, etc., in addition to the work order is currently located in the manufacturing station and location information.

Once in the manufacturing process, then the meta-information of the ticket will not be changed, the operation of it only read operation, but very frequently, because each station will be read.

The work Order's current position and location will constantly change, so it will continue to write, and each write operation will cause the data row lock protection, thus affecting the meta-information data read.

Therefore, from the point of view of performance, we should put the meta-information of work orders in one table, and the current position and location and other constantly updated properties in another or several tables, so that the read-write separation, so that the operation will not affect the read operation.

Second, redundancy

There are 3 examples in the American Highway system that can be understood by reference to the concept of redundancy in the IT system.

1. Urban Highway Central Belt

There is a wide barrier between the 2 routes of the city Road, and when the road has a turn, the belt area shrinks, leaving a parking space for the left steering car to be parked when waiting.

The advantage of this design is that the steering vehicle will not affect the direct driving, after all, the impact of direct driving on the overall flow is the biggest, because the straight lane is the highest priority.

2. Path Waiting area

Vehicles traveling on the road, if the green light, even through the intersection, the speed of the vehicle to maintain the normal speed of travel, the driver will not slow down, because everyone thinks the main road of high priority.

Vehicles traveling on a small road may have to wait longer before entering the road to avoid competing with the main road vehicle. As a result, the area should be designed to allow more vehicles to stay temporarily before access to the main road.

3. Stop Card

When a vehicle is traveling in a residential or office area, a stop warning sign will be set at the intersection with the person's car, and the driver must slow down the car before the card (even if there is no one at the Junction), confirm the safety and then pass.

The move appears to be a significant redundancy, as many intersections are not as likely to be met, but the law requires drivers to stop before the cards, what is the point?

This is because the probability of the accident is very low, but as the Black Swan incident, it is difficult to predict, and once the accident will cause congestion traffic bottlenecks.

So despite the increased road dwell time, the probability of a vicious accident is reduced, so this redundancy is reasonable.

Redundant design is often an effective way to improve performance for IT systems.

In terms of database query performance, there are 3 scenarios that typically affect database queries:

1. Group Query

According to the design principle of the database, when the group query, the query field type is the highest efficiency, if the character field to group, the query consumes hundreds of times.

So when the business needs a group query, first we need to add redundant fields to the database, map the character data to be grouped into integer data, summarize the data according to the integer field, then associate the dataset with the mapping table, and finally get the business data we need.

From a business perspective, this increased integer field is redundant data, but it is essential to improve performance.

2. Full table Scan

Full table scan is a frequently encountered scene, will consume a lot of query time, the solution is very simple, is to build an index.

For business, indexes are also redundant data, but the results are immediate.

3. Recursive query

For recursive processing is the weak of the database, even if the database has some built-in functions to handle recursion, but often will generate a lot of query time.

A common example is the structure of the BOM. Usually the BOM uses the multi-level parent-child relationship to establish the complete structure, so there will be a large number of recursive queries during the restore, and the query time will become quite long as the number and level of queries increases.

A common solution for such queries is to do data processing in advance, query the structure of the BOM before the business occurs, and store it in a table or materialized view in a flattened tabular format, so that when the business occurs, it can directly query the flat table or materialized view.

It will also be said to take advantage of the redundancy time before the business to take advantage of redundant data unrelated to the business logic to advance processing to reduce the query time when the business occurs.

The reference of American Highway system to IT system

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.