Interview question: Which layer of MVC should be optimized first when the system traffic is high?

Source: Internet
Author: User
Interview question: Which layer of MVC should be optimized when the system has a large traffic volume? Please describe in detail. Interview question: Which layer of MVC should be optimized when the system has a large traffic volume?

Please describe in detail.

Reply content:

Interview question: Which layer of MVC should be optimized when the system has a large traffic volume?

Please describe in detail.

I personally think it should be C-layer. If C-layer processing is good, various caches can be used to speed up the process.

In fact, I think we should first profile... if there is really a silly bottleneck, it may be solved without spending money.

If 0 is required, then M is needed. After this is done, the other two scales out are easier. Spending money and machines can solve the problem.

M layer.
First, the most resource-consuming query is generally for the database.
Second, database servers are also the most expensive.
Finally, the view layer is related to the user experience. We do not recommend that you optimize it first.

Why is there always such an egg interview question? If you don't say where the bottleneck is, it's a serious nonsense...

The Controller layer minimizes the number of requests, and the request means the overhead of resources such as links, threads, and memory. For example, tomcat uses nio. Merge static resources such as images and js, use browser cache, and cdn acceleration. Let me talk about it. The controller and the attempt layer are mixed up.

We should start with the View layer which is the easiest way to solve the user's access experience and ensure the normal operation of the system first.
Increase the server access bandwidth, set the system access cache system, adjust the performance of the WEB server, and adjust the Server Load balancer ~~~
Then, adjust database access, optimize SQL, read/write splitting, table sharding, and cache data level 1 and level 2 ~~~
Then check whether the code is unreasonable ~~~~

I personally think that in the MVC framework, when the access volume increases, the most optimized is the M layer, followed by the C layer.

Cause:

When the traffic volume increases, the performance bottleneck is generally in the database, and the most relevant to the database is the M layer. To solve the problem, you have to start from the M layer, read/write splitting and SQL optimization are all solutions.

The Optimization of the C layer includes a better cache deployment scheme and business code optimization.

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.