Shoot the breeze:

  • The threshold of performance testing is high, so be careful before choosing, so let’s look at the requirements of a qualified performance testing engineer:
    • General information about hardware, and suggestions for alternative hardware solutions when performance bottlenecks occur
    • The advantages and disadvantages of the system framework, and the reasonable configuration and optimization suggestions of each module under the framework
    • Let’s take a look at this:
      • Programming languages: Java, C, C#, C++, PHP, you do not know the future work which of them will appear in your sight…..
        • Java and PHP account for a high proportion. At present, mainstream Internet companies are using Java, and start-up companies PHP will be more
        • C, C#, C++, if you are not a bank outsourcing project or a game company, this part will not be needed.
      • Server: Tomcat, Apache, IIS, Nginx, Mybatis, servlet, these is not ask you to spell words oh ~
      • Data side: Oracle, Mysql, Sqlserver, Postgresql, Mongodb, Redis, Mercache
      • Well, I haven’t seen performance test engineers like this yet, but I think they have at least the following hard skills:
        • Selection of performance testing tools, as well as mastery of scripting language
        • Basic understanding of the company’s project framework, data flow and storage
        • Service configuration and optimization methods used in the project — I can’t remember many parameters. In fact, there is a lot of useful information to be found on the Internet, and optimization needs to be accumulated by myself
        • The programming language used by the server requires that you have this skill yourself – of course the low way is to bring in a backend developer to accompany you
        • The proper configuration and optimization of the database used in the project is available later in this article
  • Full-time performance is good, if you want to do everything, then you are not only tired, but also maintain a lot of knowledge, very painful, I still struggle in….
  • #### compiled in 4 hours, sharing a Github homepage compiled by Bootstrap (recording the bits and pieces accumulated in my career ~) :

Guide catalog:

  • Performance test division
  • Performance test preparation
  • Performance Testing FaQs
  • Linux monitor
  • Database Monitoring
  • Setting Server Parameters

Front-end performance framework:

  • Selenium+YSlow+ShowSlow is a great tool for automating page performance evaluation.

1. Performance test division

  • Configuration test: hardware selection, software parameter configuration (database, server configuration)
  • Benchmarking: Previous versions are used as benchmarks
  • Load testing: find system bottlenecks, evaluate performance metrics, more process, step by step
  • Stress test: High load is the stress that makes the system crash, see recovery ability as well as time

2. Evaluation before performance test

  • Key business
  • Daily amount of PV
  • Logical complexity
  • Operation to promote
  • Services with high memory and CPU consumption

3. General questions

4. Check performance

  • When performance indicators appear inflection point:
    • Load machine hardware resources
    • Network bottleneck – Observe network throughput calculations
    • Server hardware resources – CPU, memory, disks
    • Database server hardware resources – CPU, memory, disks
    • If the server parameters are configured in distributed mode, check whether the configuration takes effect and whether the request allocation rules are reasonable
    • Database performance metrics – Detailed analysis process is shown below
    • SQL pushes back to the code block
    • Third-party monitoring tools to monitor running code; Example: Jprofiler (Java) xhprof(PHP)

5. Performance test results analysis and positioning

  • Linux Information Collection (Learn from O&M)

    • Gossip:
      • Linux tuning requires a lot of knowledge, and we are not operations people, but we can use key metrics data to find intuitive problems and make sound recommendations
      • Common commands:
        • Netstat: View ports
        • Wc-l: collects statistics
        • Grep: filter criteria
    • top
      • Load Avg: three values (mainly depending on the number of CPU cores in the system. For example, if the Load value is less than or equal to 1, there is no pressure. If the Load value is greater than 1, partial congestion may occur)
        • One minute load
        • Load at two minutes
        • Load at three minutes
    • Iostat -x: monitors system I/O usage
      • Cpu
        • %user: percentage of CPU used to run at the user level
        • %sys: the percentage of CPU used to run at the kernel level
        • % ioWAIT: indicates the percentage of CPU occupied while waiting for hardware I/ OS
        • %idle: indicates the percentage of idle CPU time
      • Device
        • TPS: number of I/O requests sent per second
        • Avgqu-sz: is the average request queue length. The shorter the queue length is, of course, the better
        • Await: average time (in microseconds ms) to process each IO request
        • RkB /s: data read per second
        • WkB /s: data written per second
        • %util: Indicates that the disk is close to 100% busy
    • Vmstat, server CPU usage, memory usage, virtual memory swapping,I/O read and write status
      • Cpu
        • R: Run queue. When this value exceeds the number of cpus, there is a CPU bottleneck
        • Us: indicates the user CPU time
        • Sy: indicates the system CPU time. If it is too high, the system call time is long
        • Id: indicates the idle CPU time. Generally, id + US + sy = 100
      • Memory
        • SWPD: used size of virtual memory
          • If it is greater than 0, your machine is running out of physical memory, not the cause of a memory leak, and it is time to upgrade your hardware
        • Free: indicates the size of free physical memory
      • Swap
        • Si: The amount of virtual memory read from disk per second
          • If the value is greater than 0, it indicates that the physical memory is insufficient or the memory is leaked
        • So: the size of virtual memory written to disk per second. If this value is greater than 0, the same as si
      • System
        • In: indicates the number of CPU interrupts per second, including time interrupts
        • Cs: Number of context switches per second, thread/town switches
          • Too large a value indicates that the CPU is wasting most of its time on context switches, leaving it with less time to do serious things and underutilized the CPU
    • Nmon is IBM’s system monitoring tool with no guarantee of accuracy. It’s easy to use, one line command
      • This tool can do most of the data you need for performance monitoring, and too much file data can lose data – maybe I’m using it the wrong way
  • Database related optimization information (close to DBA)

    • Gossip:
      • There are many kinds of databases, and there are only a few commonly used databases, but as a test, it is not realistic to do a good job in tuning. The key indicators are the weapons we propose to rationalize. The correct responsibility positioning will allow you to have better room for progress
      • Interviews are often asked about interesting SQL
        • Mysql: select * from table_name where table_name order by table_name limit 1,3
        • Postgresql: select * from 表名 WHERE 表名 order by 表名 limit 2 OFFSET 0
        • Sqlserver: select top 10 * from (select top 20 * from 表 面 order by 表 面 Q desc)
        • oracle: Select * from (select rownum as an rn, id from the table name the where condition order by fields) where rn = number of rows (or rn between n and m (take n to the first m records))
      • Databases typically monitor metrics:
        • Database connections
        • The slow query SQL
        • Thread pool size
        • Transactions per second
        • QueryCache shooting
        • locked
    • Memcache(cache database)
      • Check the running status: Connect to memcache and run the status command to check the parameter values
        • Memcache hit ratio: get_hits/cmd_get*100% (1. 2. Get_hits: total hits)
    • Redis(Cached database)
      • Check the running status: Connect to Redis and run the info command to check the parameter values
        • Redis hits: keyspace_hits/(keyspace_hits+keyspace_misses)*100% (1. 2. How many keyspace_misses)
    • Mysql
      • Mysql has two engines:
        • MyISAM: table locks – table locks are not normally used
        • InnoDB: row lock – used
      • Table index query command: desc Table name
      • Check the Settings: show variables like…
      • Check status: show global status like…
      • Show variables like ‘%slow%’;
        • You need to enable slow log query. Slow log query consumes performance. Therefore, you are advised to write slow log query logs on an independent machine
        • Set the slow query time, usually within 5s
        • Set the slow query log location
      • Slow query: show global status like ‘%slow%’;
        • Displays the number of SQL queries that are longer than the query time
        • Slow queries can determine whether it is an indexing problem or a SQL statement writing problem
      • Show variables like ‘max_connections’;
      • Mysql current number of connections: show global status like ‘Max_used_connections’;
        • For example, the maximum number of connections is 10, and the number of database connections per second is 100, but it is not very reasonable
      • Key_buffer_size Index cache hit ratio (in-memory)
        • Key_buffer_size is the parameter that has the greatest impact on MyISAM engine performance
          • Query configuration: show variables like ‘key_buffer_size’;
          • To query the current read status: show global status like ‘key_read%’;
          • To query the current write status: show global status like ‘key_write%’;
            • Return Key_read_requests: total number of read index requests
            • Returns Key_reads: information not found in memory, read from disk
            • Return Key_write_requests: total number of write index requests
            • Return parameter Key_writes: write requests to disk
            • The hit rate is:
              • Read hit ratio: KEY_buffer_read_hits =(1-key_reads /Key_read_requests)*100%
              • Write hits: key_buffer_write_hits=(1-key_writes /Key_write_requests)*100%
      • InnodbBuffer cache hit ratio (in-memory)
        • Memory space that caches data and indexes of innoDB-type tables
        • InnodbBuffer is the single parameter that has the greatest impact on InnoDB engine performance
        • To query the current read status: show status like ‘Innodb_buffer_pool_read%’;
        • To query the current write status: show status like ‘Innodb_buffer_pool_write%’; * Hit ratio:
          • Read hit ratio: Innodb_buffer_read_hits =(1-Innodb_buffer_pool_reads/Innodb_buffer_pool_read_requests)*100%
          • Write hit ratio:……
      • Query thread pool Settings: show variables like ‘thread%’;
        • Thread pooling is even more effective in short links, frequently creating and destroying connections
        • Thread_cache_size: The number of connected threads that should be held in the thread pool
          • At startup, mysql is not completely created. As the requesting thread runs out, it is released to the thread pool. When the thread pool reaches its maximum value, it is no longer added to the thread pool
        • Thread_stack: Initializes the size of memory allocated for each thread
        • Query configuration: show variables like ‘thread%’;
        • Show status like ‘Connections’;
          • Total number of Connections: Connections
        • Query status: show status like ‘%thread%’;
          • Threads_created: created threads. If the value is large, the configured thread_cache_size is too small and needs to be added
          • Threads_cached: Threads cached in the thread pool
          • Threads_Cache_Hit=(connections-threads_created)/Connections*100%
      • Row locks
        • Query status: show status like ‘%lock%’;
          • Innodb_row_lock_current_waits: Number of locks currently waiting, number of blocks
          • Innodb_row_lock_time_avg: average lock time
          • Innodb_row_lock_time_max: specifies the maximum lock time
          • Innodb_row_lock_waits: Total number of lock waits since system startup
        • To query the latest deadlock: show engine innodb status;
    • The original writing document is also so tired, take a rest, [March 31] updated after the content ~ – temporary change, I first learn Java, feel Java familiar, will give more suggestions;
    • Postgre
    • Mongo
    • Oracle
  • Optimized server parameters

    • Nginx
    • Apache