반응형

MySQL 5.6 내에 InnoDB는 프러싱 작업을 수행하기 위한 전용쓰레드(page_cleaner)를 가지고 있다.

In MySQL 5.6 InnoDB has a dedicated thread (page_cleaner) that’s responsible for performing flushing operations.

 

Page_cleaner는 두가지 사실에 근거하여 버퍼풀로부터 더티 페이지의 플러싱을 수행한다.

Page_cleaner performs flushing of the dirty pages from the buffer pool based on two factors:

더티   : InnoDB 버퍼풀에 변경된 데이터

플러싱 : 더티 데이터를 디스크로 영구히 기록하는 작업

 

- access pattern – 가장 최근에 사용된 페이지들은 버퍼풀이 더 이상 프리 페이지를 가지지 못할 때 LRU List로부터 LRU flusher에 의해 플러시 되어 진다.

- access pattern  -  the least recently used pages will be flushed by LRU flusher from LRU_list when buffer pool has no free pages anymore;

- age – 가장 오래 전에 수정된 플러시되지 않은 페이지들은 flush_list 구조의 일부이며 여러가지 추론의 근거하여 flush_list flusher에 의해 플러시 된다.

- age – the oldest modified non-flushed pages are part of flush_list structure and will be flushed by flush_list flusher based on several heuristics.

 

LRU_list flusher

 

           MRU(Most Recently Used)          LRU(Least Recently Used)

<---------------------------------------------------><------------------------->

0%                                         62.5%                 100%

자주 사용되는 페이지들을 모아둔 곳           최근 사용된 페이지들을 모아둔 곳

 

innodb_old_blocks_pct 시스템 변수의 값을 변경해서 MRU LRU의 기준점을 변경할 수 있다.

 

Flush_list flusher

RDBMS의 리구 로그 작동 방식(Write Ahead Log) 특성상 리두 로그와 더티 페이지 중에서 항상 리두 로그가

먼저 디스크로 플러시되어야 한다. 그리고 InnoDB 버퍼 풀에서 더티 페이지가 디스크로 완전히

플러시되어야만 그 더티 페이지와 연관을 가지고 있던 리두 로그 슬롯이 재사용될 수 있다.

이때 버퍼 풀에서 더피 테이지들을 빠르게 찾도록 하기 위해서 더티 페이지들의 변경 시간 순서대로 목록을

관리하는데 이를 Flush_List 라고 한다.

 

Page_cleaner에 대한 개요이며 MySQL 5.6내에 플러싱에 대한 몇 가지 세부적인 사실을 여기서 찾아볼 필요가 있다.  아래에 나는 아직 적용하기 않은 플러시_list의 여러가지 추가 요소를 설명하였다.

There is a good overview of the page_cleaner and also here you may find some details about flushing in MySQL 5.6. Below I describe several additional aspects of the flush_list flushing that was not really covered yet.

 

 

flush_list flushing and checkpoint age

flush_list의 유지하기 위해 가능한 세 페이지들의 양은 innodb log 파일의 조합된 사이즈에 의해 제한 되어진다.

The amount of the aged pages that is possible to keep in the flush_list is limited by the combined size of the innodb log files.

 

그래서 flush_list 플러싱의 주 목적은 항상 로그 파일에 충분한 여유 공간을 허용하는 비율로 페이지(더티페이지)를 플러싱하는 것이다.

So the main purpose of the flush_list flushing is to flush pages from this list with such a rate that will also always allow enough free space in the log files.

 

반면에 너무 공격적인 플러싱은 덜된 읽기 조합, I/O 서브시스템에 대한 불필요한 로그, 너무 큰 리두 로그의 최종 실행 취소 성능상의 이점이다.

On the other hand, too aggressive flushing means less write combining, unnecessary load on the I/O subsystem, in the end undoing performance benefits of having larger redo logs.

 

MySQL 5.6에서는 플러시하기 위한 페이지의 양은 공식에 따라 현재 checkpoint age를 근거로 적용된 루틴에 따라 InnoDB내에서 계산되어졌다.

In MySQL 5.6 the amount of pages to flush is calculated in the InnoDB adaptive routine based on the current checkpoint age with the following formula:

 

InnoDB에서는 마지막 체크포인트가 발생한 시점의 리두 로그 위치(LSN, log sequence number)에서부터 마지막리두 로그 슬롯의 위치까지의 길이를 체크포인트 에이지(checkpoint age)라고 한다. 체크포인트 에이지가 중요한

이유는 InnoDB 모두 리두 로그의 전체 공간 크기의 체크포인트 에이지의 길이를 이용해서 플러시를 실행해야 할

더티 페이지의 개수를 결정하기 때문이다.

또한, 체크포인트 에이지가 얼마나 되는지에 따라서 InnoDB의 쿼리가 일부만 블로킹되거나 전부 블로킹 될 수도

있기 때문이다.

 

flush_list flushing and io_capacity

InnoDB는 백그라운드 플러싱 비율을 컨트롤하는 것을 허용하는 두가지 변수를 제공한다.

( innodb_io_capacity innodb_io_capacity_max )

 

- innodb_io_capacity_max는 실제로 플러싱 비율을 제한하는 것으로 적용하는 플러싱인 경우 가장 중요한 변수이다.

- innodb_io_capacity_max is the most important variable in case of adaptive flushing as only that variable actually limiting the flushing rate.

 

innodb_io_capacity_max

InnoDB에 대해 긴급한 경우 innodb_io_capacity로 값을 늘리는 것은 허용되지만 최대값을 제한한다.

The limit up to which InnoDB is allowed to extend the innodb_io_capacity setting in case of emergency.  

 

만약 당신은 mysql 시작시 innodb_io_capacity를 지정하고 innodb_io_capacity_max값을 지정하지 않았다면, innodb_io_capacity의 두배가 디폴트가 된다. 2000을 넘지는 않는다.

If you specify an innodb_io_capacity setting at startup and do not specify a value for innodb_io_capacity_max, the innodb_io_capacity_max value defaults to twice the value of innodb_io_capacity, with a lower limit of 2000.

 

2000 innodb_io_capacity_max 설정값의 초기 값이다.

2000 is also the initial default innodb_io_capacity_max configuration value.

 

Innodb_io_capacity_max는 모든 버퍼풀 인스턴스들에 대한 총 제한값이다.

The innodb_io_capacity_max setting is a total limit for all buffer pool instances.

 

- innodb_io_capacity는 서버비활성화/셧다운의 경우에 인서버버퍼의 병합과 플러싱하는 동안 IO동작을 제한하기

위해 사용되어졌다.

- innodb_io_capacity is used for limiting IO operations during merging of the insert buffer and flushing in cases of server inactivity/shutdown.

innodb_io_capacity

기본값은 200이다. The default value is 200.

 

Innodb_io_capacity 매개변수는 인서트버퍼로부터 데이터를 머징하고 버퍼풀로부터 페이지를 플러싱하는 거와 같이 InnoDB 백그라운드에 의해 수행되는 I/O 활성화는 제한을 설정할 수 있다.

The innodb_io_capacity parameter sets an upper limit on the I/O activity performed by the InnoDB background tasks, such as flushing pages from the buffer pool and merging data from the insert buffer.

 

높은 I/O 비율을 보이는 바쁜 시스템의 경우, 당신은 서버 스타트업에서 높은 값을 설정할 수 있다.

(서버는 행 변경의 높은 비율과 관련된 백그라운드 유지보수 작업을 처리하기 위해)

For busy systems capable of higher I/O rates, you can set a higher value at server startup, to help the server handle the background maintenance work associated with a high rate of row changes.

 

각각의 5400 RPM 또는 7200 RPM 드라이브로 구성된 시스템에서는 당신은 100보다 낮은 값으로 기본값을 해야 한다.

For systems with individual 5400 RPM or 7200 RPM drives, you might lower the value to the former default of 100.

 

이 매개변수는 시스템이 초당 수행  수있는 I / O 동작의 대략 값으로 설정되어야 한다.

This parameter should be set to approximately the number of I/O operations that the system can perform per second.

 

일반적으로, 부분적으로 빠른 드라이브 능력을 요구한다면 InnoDB I/O로 사용되는 드라이버에 대해 이 변수값을 증가시킬 수 있다.

In general, you can increase the value as a function of the number of drives used for InnoDB I/O, particularly fast drives capable of high numbers of IOPS.

 

예를 들어, 다수의 디스크나 SSD에 대한 InnoDB 시스템은 이 매개변수를 조절하여 이득을 볼 수 있다.

For example, systems that use multiple disks or solid-state disks for InnoDB are likely to benefit from the ability to control this parameter.

 

innodb_io_capacity_max 의해 정의  최대 개수 (100) 이상으로 innodb_io_capacity 값을 설정할  있다.

You can set the innodb_io_capacity value to any number 100 or greater to a maximum defined by innodb_io_capacity_max.

 

MySQL 옵션 파일 (my.cnf 파일 또는 my.ini 파일)에서이 매개 변수의 값을 설정하거나 SUPER 권한 필요 SET GLOBAL 명령을 동적으로 변경할  있다.

You can set the value of this parameter in the MySQL option file (my.cnf or my.ini) or change it dynamically with the SET GLOBAL command, which requires the SUPER privilege.

 

- 만약 활성화 상태인 MySQL 서버라면 당신은 플러싱 비율을 증가/감소하는 innodb_io_capacity_max값을 조정할 필요가 있다.

- if  the MySQL server is in an active state (serving user requests) you need to adjust innodb_io_capacity_max to increase/decrease flushing rate.

 

- MySQL 서버가 유휴 상태 또는 flush_list에서 페이지 종료 플러싱 수행하는 경우 innodb_io_capacity  의해서만 제한됩니다

- if the MySQL server is in an idle state or performing shutdown flushing of the pages from flush_list will be limited byinnodb_io_capacity value only.

 

출처 :

http://www.percona.com/blog/2013/10/30/innodb-adaptive-flushing-in-mysql-5-6-checkpoint-age-and-io-capacity/

http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_io_capacity_max

 

Real MaiaDB p378 ~ p385


반응형

+ Recent posts