Git Product home page Git Product logo

pg_cgroup's Introduction

pg_cgroup

A PostgreSQL extension to manage cgroup (Control Group).

Overview

pg_cgroups provides set of SQL-callable functions to manage cgroup on Linux OS. pg_cgroups requires user to create a cgroup for PostgreSQL server in advance. Using pg_cgroup you can both create/delete/set cgroups and classify pids with in the cgroup of PostgreSQL server.

GUC Parameter

  • pg_cgroup.cgroup_name (text)
    • The name of cgroup of which owner is the user who was used for initdb.

Example

Installation

You can install pg_cgroup extension in similar way as other PostgreSQL extensions except for requiring libcgroup-devel package.

  1. Get libcgroup-devel package
$ sudo yum -y libcgroup-devel
  1. Get pg_cgroup source code
$ git clone [email protected]:MasahikoSawada/pg_cgroup.git
  1. Build and Install
$ make USE_PGXS=1
$ sudo make USE_PGXS=1 install

Setup

  1. Create cgroup for PostgreSQL with definition of user and group
$ cgcreate -g cpu,memory,disk:pgsql -t postgres -a postgres
  1. Configuration fo pg_cgroup
$ vi /path/to/postgresql.conf
shared_preload_libraries = 'pg_cgroup'
pg_cgroup.cgroup_name = 'pgsql'
  1. Start PostgreSQL Server
  2. Create EXTENSION
$ psql -c 'CREATE EXTENSION pg_cgroup'

Usage

  • Create new resource group of cpu controller
=# SELECT create_resource_group('test_cg', 'cpu');
 create_resource_group
-----------------------
 t
(1 row)

Now you can see the created new cgroup by using lscgroup or whatever you'd like to use as follows.

$ lscgroup | grep pgsql
cpu,cpuacct:/pgsql/
cpu,cpuacct:/pgsql/test_cg
  • Set parameter of cpu cgroup
=# SELECT set_resource_value('test_cg', 'cpu', 'cpu.cfs_quota_us', 50000);
 set_resource_value
--------------------
 t
(1 row)

Test Platforms

Category Module Name
OS CentOS 7.4
DBMS PostgreSQL 10
Library libcgroup 0.41-13

Copyright

Copyright © 2018- Masahiko Sawada

License

The PostgreSQL License. (same as BSD License)

pg_cgroup's People

Contributors

masahikosawada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.