Performance Tuning Summary

Source: Internet
Author: User
Tags switches

Looking for performance bottlenecks

  Usually the performance bottleneck is the appearance of excessive resource consumption, external processing system performance is not enough, but the response speed of the program is still not up to the requirements.

Resources are mainly consumed in the CPU, file io, network io and memory, the machine's resources are limited, when a resource consumes too much, it usually causes the system to respond slowly.

The performance of external processing is not enough, mainly called the other system provides the function or the database operation response speed is not enough, the other system calls the performance is insufficient, in most cases is also excessive resource consumption, but the program performance is insufficient. The performance of database operation is usually based on the SQL Execution Speed of database, the IOPSof database machine, the Active Sessions of database, etc.

  Resource consumption is not much, but the program's response speed is still not up to the requirements of the main reason is that the program code is not efficient, insufficient use of resources or the structure of the program is unreasonable.

For Java applications, the method of looking for performance bottlenecks is typically to analyze resource consumption first, and then combine some Java tools to query for code that causes excessive resource consumption in the program.

CPU Consumption Analysis

Context Switches

Each CPU can execute only one thread at a time,andLinux uses preemptive scheduling, that is, each thread allocates a certain execution time, when it reaches the execution time, the thread has IO when a blocking or high-priority thread is to be executed, Linux The thread that will switch execution, when switching to store the execution state of the current thread, and restore the state of the thread to be executed, this process, called context switching.

Run queue

Each CPU Core maintains a thread queue that can be run.

Typically, the system's load is determined primarily by the CPU 's running queue, andthe larger theload value, This means that the longer the thread consumes, the more time it takes to complete.

Utilization

CPU Utilization is a percentage of CPU usage in user processes, cores, terminal processing,IO waits, and idle five parts. These five values are a key indicator for analyzing CPU consumption

For Java applications,CPU consumption is mainly manifested in US,SY two values.

US: When the US value is too high, it means that the running application consumes most of the CPU.

At this point, to find the code that is executed by the CPU-consuming thread,

Java Applications cause the US value to be too high, mainly because the threads are always in a running state, which is usually caused by actions such as non-blocking, looping, regular, or stored computations.

Another possible cause of high US values is the frequent GC.

Sy: When the sy value is high, it means that Linux spends more time on thread switching.

The main cause of this behavior in Java applications is that more threads are being started, and these threads are in constant blocking and performing state changes, which causes the operating system to constantly switch the threads of execution, resulting in a large number of context switches.

At this point, the most important thing is to find out why the thread is constantly switching state.

Performance Tuning Summary

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.