Use cgroup to restrict disk io of processes, and cgroup process disk io

Source: Internet
Author: User

Use cgroup to restrict disk io of processes, and cgroup process disk io

Cat/etc/cgconfig. conf

#

# Copyright IBM Corporation. 2007

#

# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>

# This program is free software; you can redistribute it and/or modify it

# Under the terms of version 2.1 of the GNU Lesser General Public License

# As published by the Free Software Foundation.

#

# This program is distributed in the hope that it wocould be useful,

# Without any warranty; without even the implied warranty

# MERCHANTABILITY or fitness for a special PURPOSE.

#

# See man cgconfig. conf for further details.

#

# By default, mount all controllers to/cgroup/<controller>


Mount {

Cpuset =/cgroup/cpuset;

Cpu =/cgroup/cpu;

Cpuacct =/cgroup/cpuacct;

Memory =/cgroup/memory;

Devices =/cgroup/devices;

Freezer =/cgroup/freezer;

Net_cls =/cgroup/net_cls;

Blkio =/cgroup/blkio;

}

Group shard_0 {

Blkio {

Blkio. throttle. read_iops_device = "253: 3 16000 ";

Blkio. throttle. write_iops_device = "253: 3 16000 ";

Blkio. weight = "500 ";

}

}

Group shard_1 {

Blkio {

Blkio. throttle. read_iops_device = "253: 3 16000 ";

Blkio. throttle. write_iops_device = "253: 3 16000 ";

Blkio. weight = "500 ";

}

}


Blkio. throttle. read_iops_device read iops

Blkio. throttle. write_iops_device write iops


253: 3 is the device number

For example, we want to restrict the iops of processes on flashcache.


[Root @ test ~] # Ls-l/dev/mapper/cachedev

Lrwxrwxrwx 1 root 7 Jan 25/dev/mapper/cachedev-> ../dm-3


Here we can see that it is just a soft connection.

[Root @ test ~] # Ls-l/dev/dm-3

Brw-rw ---- 1 root disk 253, 3 Jan 25/dev/dm-3


Therefore, if we limit a process to 16000 iops on flashcache, we can write it as 253: 3 16000.


Start cgroup

[Root @ c3-b2c-dba-backend-mysql09/] # service cgconfig restart

Stopping cgconfig service: [OK]

Starting cgconfig service: [OK]


Then you can write the process id into the task corresponding to the cgroup.


[Root @ test shard_0] # pwd

/Cgroup/blkio/shard_0

[Root @ test shard_0] # cat tasks

48554

339938

340404

340414

340487

340498

340547

340560

340568

340581

340587

340602

340608

340609

340624

340633

340650

340657

340659

340660

340669

340672

340675

340685

340687

340689

340690

340701

340708

340709

340710

340711

340712

340719

341151

341157

341158

341159

341160

341162

341171

341172

341178

341180

341186

341187

341192

341204

341212

341229

341231

341237

341245

341248

341249

341250

341251

341252

341253

341254

341255

341256

341257

341258

341259

341260

341261

341262

341263

341264

341265

341270

341273

341279

341284

341285

341286

341288

341294

341295

341296

341297

341298

341299

341300

341301

341307

341308

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.