What affects the performance of mysql - optimization of hardware resources and systems

With the increased amount of data, database performance problems are also a concern, many companies do not attach too much importance on the performance mysql, resulting in excessive waste of resources and services, mysql poor service performance and thus directly affect the user experience, here we simply the first to talk about what impact the performance of mysql, so that it can focus on these issues.

Aspects that affect performance
  • Server Hardware
  • Server system
  • Database storage engine of choice (in the form of plug-ins)
    • MyISAM: does not support transactions, table-level locking
    • InnoDB: transaction-level storage engine, the perfect support for row-level locking, transaction ACID properties
  • Database configuration parameters
  • Database design and SQL statements
    • Slow query (database table structure design)
    • Preparation and optimization of SQL statements

The impact of hardware resources What?

CPU resources and memory size available
  • We are not CPU-intensive, and if you need better CPU
  • It does not support multi-CPU on the same SQL concurrency
  • How our system concurrency?
    • If the case is complicated by the big scene, it is more important than the number of CPU frequency
    • MYSQL version of the decision to support multi-core CPU (try to use the latest version)
      • High version of mysql more multi-core support
  • Select 32-bit or 64-bit CPU?
    • 64-bit 32-bit version of the server (can not ignore this problem, test / development environment may encounter problems system version)
    • 32 there are restrictions on the performance of
  • Memory size affect the performance
    impact of memory, but more explanation, of course, not to say that large memory, the better the greater the performance, there is a blog written by listening to the whole describes the parameters of interest can refer https://www.cnblogs.com/xuan52rock/p /4569835.html
Configuration and select disk
  • The use of traditional machine's hard disk

    • storage capacity
    • transfer speed
    • interview time
    • Spindle speed (7200 rpm / 15 000 rpm)
    • Physical Dimensions
  • RAID hard drives increase the performance of a conventional machine

    • RAID 0 (do not worry about data loss)
      • Does not provide redundancy or bug fixes can in
      • low cost
    • RAID 1 (available rate, a good read operation can be improved)
      • In the same time written to one disk, hard disk write to another image
    • RAID 5 (many applications read from the database)
    • RAID 10 (slice image, important choice)
      • A damaged disk performance degrades
  • Solid-state storage (SSD flash memory)

    • Compared mechanical disk solid state disk random read and write better
    • Better support concurrent
    • Solid State Disk Disk relatively easier mechanical damage (disadvantage)
      • SSD (solid state drive)
        • Use the SATA interface
        • SSD SATA interface also supports RAID technology
        • scenes to be used
          • Suitable for a large number of random IO
          • To solve the bottleneck of a single-threaded load IO
          • Only a solid-state storage devices, should be placed on the server
            • On the master server multi-threaded, single-threaded from the server
      • PCI-E SSD (Fusion-io)
        • You can not use the SATA interface
        • The price is relatively expensive (but also take up server memory and CPU)
  • SAN and NAS network storage

    • Scene use network storage (not applicable)

      • database backup
    • Limiting network performance

      • delay

      • bandwidth

      • Network Quality

        Suggest

        • High-performance and high-bandwidth network interfaces and switches
        • To bind to multiple network cards, enhanced usability and bandwidth
        • Network isolation

    to sum up:

    • CPU
      • 64-bit CPU must work on 64-bit systems
      • For a relatively high number of concurrent scenes CPU important than the frequency
      • For CPU-intensive scenarios and complex SQL is the higher the frequency, the better
    • RAM
      • Selecting the highest frequency that can be used motherboard memory
      • Memory size bigger the better
    • I / O subsystem
      • PCIe Card - "SSD -> -" Raid10> Disk - "SAN
The impact on the performance of the operating system
  • centos system parameter optimization

    • Kernel-related parameters (/etc/sysctl.conf)

      # net.core.somaxconn是Linux中的一个kernel参数,表示socket监听(listen)的backlog上限。什么是backlog呢?backlog就是socket的监听队列,当一个请求(request)尚未被处理或建立时,他会进入backlog。而socket server可以一次性处理backlog中的所有请求,处理后的请求不再位于监听队列中。当server处理请求较慢,以至于监听队列被填满后,新来的请求会被拒绝
      net.core.somaxconn = 65535
      net.core.netdex_max_backlog = 65535
      net.ipv4.tcp_max_syn_backlog = 65535
      加快TCP连接,快速回收TCP连接资源
      net.ipv4.tcp_fun_timeout = 10
      net.ipv4.tcp_tw_reuse = 1
      net.ipv4.tcp_te_recycle = 1
      加快资源回收效率
      net.ipv4.tcp_keepalive_time = 120
      net.ipv4.tcp_keepalive_intvl = 30
      net.ipv4.tcp_keepalive_probes = 3
      kernel.shmmax = 4294967295
      这个参数应该设置的足够大,以便能在一个共享内存段下容纳下整个innodb缓冲池的大小
      
      vm.swappiness = 0
      MYsql上保留内存交换分区还是有必要的
      
      增加资源限制(/etc/security/limit.conf)
      * soft nofile 65535
      * hard nofile 65535
      * 表示对所有用户有效
      soft 指的是当前系统生效的配置
      hard 表明系统中所能设定的最大值
      nofile 表示所限制的资源是打开文件的最大数目
      65535 就是限制的数量
      磁盘调度策略(/sys/block/devname/queue/scheduler)
      
      cat /sys/block/sda/queue/scheduler
      noop anticipatory deadline [cfq]
      
      noop(电梯式调度策略)
      deadline(截止时间调度策略) 对数据库最好选择
      anticipatory(预料I/O)
      
      改变磁盘调度策略(/sys/block/devname/queue/scheduler)
      echo deadline > /sys/block/devname/queue/scheduler
  • The impact on performance file system

    • XFS for best performance

      data = writeback | ordered | journal
      常用的文件系统的配置
      /dev/sda1/ext4  noatime,nodiratime,data=writeback 1 1

Guess you like

Origin www.cnblogs.com/only-me/p/11531289.html