Precautions for cropping Web pages and CSS, and precautions for css web pages

Source: Internet
Author: User
Tags net thread

Precautions for cropping Web pages and CSS, and precautions for css web pages
I. Thread Pool settings in Asp.net

In Asp.net service processing, every time the server receives a request, HttpRuntime will get an HttpApplication object from the HttpApplication pool to process the request. The request processing process will be queued into the thread pool. For Asp.net, in the Machine. you can set parameters in the thread pool in the processModel section of the config file.

Asp.net thread-related parameter configuration:

Parameters Configuration
AutoConfig Server-based configuration is automatically set.
MaxWorkerThreads Set the maximum number of worker threads for each CPU, which can be set to 5 ~ 100. The default value is 20, and the construction value is 100.
MinWorkerThreads Sets the minimum number of worker threads for each CPU. The default value is 1.
MaxIoThreads Configure the maximum number of I/O threads for each CPU, which can be set to 5 ~ 100. The default value is 20. We recommend that you set it to 100.
MinIoThreads Configure the minimum number of worker threads for each CPU. The default value is 1.

Configuration parameters of the HttpRuntime element:

Parameters Configuration
MinFreeThreads The minimum number of free threads reserved for processing new requests. The default value is 8. We recommend that you set each CPU to 88.These minimum Idle threads are used to avoid deadlocks caused by no threads available. Therefore, when the number of threads in the thread pool is smaller than this value, requests are queued without being processed by these threads.
MinLocalRequestFreeThreads The minimum number of free threads reserved for local host requests. The default value is 4. We recommend that you set each CPU to 76. Same as above (only for local requests)
AppRequestQueueLimit When Aso and net do not have enough threads to process requests, these requests will be queued into a request queue for medium waiting for processing. This item is used to set the queue length, if the queue length exceeds this parameter, 503 is returned and the default value is 5000.

The first principle of optimization is to use a single thread for processing every request as much as possible.

Ii. asynchronous points in asynchronous steps

In the process of processing HttpApplication, in order to improve the utilization of the thread, try to use only one thread for processing a request.

Because Asp.net adopts the pipeline processing mode, the logic sequence of the processing steps must be ensured. Therefore, some processing must be completed before subsequent processing. Therefore, unless multiple computing intensive tasks can be parallel at this time, starting multiple threads does not speed up website processing.

The process of each event in the HTTP application processing pipeline is synchronized and asynchronous:

  • Synchronization: provides an event handling method to directly complete the processing steps;
  • Asynchronous: one is used to start the processing steps involving I/O, and the other is used for the processing steps after I/O is completed;

For a processing step that needs to be waited, we can separate an asynchronous point, start the time-consuming operation before this asynchronous point, and then end the current thread directly. Without the thread involved, perform this time-consuming Input and Output task. After the task is completed, obtain a thread from the thread pool to continue processing the current request.

For example, the asynchronous processing method corresponding to the synchronized BeginRequest is defined as follows:

public void AddOnBeginRequestAsync(BeginEventHandler bh, EndEventHandler eh)

BeginEventHandler is used to start the processing delegate, and EndEventHandler is used to process the delegate after the task is completed.

For the processing of the HttpApplication pipeline, the Delegate types used for synchronization of these events are all EventHandler types. The delegation types are defined as follows:

public delegate void EventHandler(Object sender, EventArgs e)

For Asynchronous processing, two corresponding delegates are used to complete the process. One is used to start the BeginEventHandler and the other is used to end the delegate EndEventHandler. The end operation delegate will work on the thread provided by a thread pool.

  In asynchronous mode, the processing pipeline will not be completed by one thread consecutively, but every processing step may be performed on one thread,Therefore, we cannot assume that the processing pipeline is always in a thread.And Use thread-based features.

Related Article

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.