{"id":15062594,"url":"https://github.com/bmf-san/postgresql-pgcat-example","last_synced_at":"2026-02-19T18:03:17.633Z","repository":{"id":257076288,"uuid":"857188963","full_name":"bmf-san/postgresql-pgcat-example","owner":"bmf-san","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-27T22:42:53.000Z","size":1490,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-24T02:57:24.366Z","etag":null,"topics":["grafana","locust","pgcat","postgresql","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmf-san.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-14T02:18:02.000Z","updated_at":"2024-10-08T13:35:58.000Z","dependencies_parsed_at":"2025-10-06T02:48:31.550Z","dependency_job_id":null,"html_url":"https://github.com/bmf-san/postgresql-pgcat-example","commit_stats":null,"previous_names":["bmf-san/postgresql-connpooler-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bmf-san/postgresql-pgcat-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmf-san%2Fpostgresql-pgcat-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmf-san%2Fpostgresql-pgcat-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmf-san%2Fpostgresql-pgcat-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmf-san%2Fpostgresql-pgcat-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmf-san","download_url":"https://codeload.github.com/bmf-san/postgresql-pgcat-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmf-san%2Fpostgresql-pgcat-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29626622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grafana","locust","pgcat","postgresql","prometheus"],"created_at":"2024-09-24T23:43:21.542Z","updated_at":"2026-02-19T18:03:17.617Z","avatar_url":"https://github.com/bmf-san.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postgresql-pgcat-example\nThis repository is for testing PostgreSQL and PgCat.\n\nMetrics are collected by Prometheus and visualized with Grafana.\n\nThis repository is intended for testing the operation and performance of PostgreSQL and PgCat.\n\n# Usage\n| Command | Description |\n| --- | --- |\n| `make up` | Build and run containers. |\n| `make down` | Stop and remove containers. |\n| `open-srv` | Open services. |\n\n# Monitoring\n- Grafana: http://localhost:3001\n\t- User: admin\n\t- Password: password\n- Prometheus: http://localhost:9090\n\n![dashboard image](./dashboard_image.png)\n\n## Description\nThis section explains each item that defined in my Grafana dashboard.\n\n### Node\nMetrics for monitoring the system resource consumption of PostgreSQL and PgCat.\n\nThese need to be monitored to ensure the stable operation and optimization of PostgreSQL and PgCat.\n\n#### CPU\nMetrics for monitoring CPU usage.\n\n- System: CPU usage in kernel mode\n- User: CPU usage by processes in user mode\n- Nice: CPU usage by processes with adjusted priorities in user mode\n- Iowait: CPU usage waiting for disk I/O\n- Irq: CPU usage for handling hardware interrupts\n- Sftirq: CPU usage for handling software interrupts\n- Steal: CPU usage taken by the hypervisor in a virtual environment\n- Idle: CPU time spent waiting while not doing any work\n\n#### Memory Stack\nMetrics for monitoring memory usage.\n\n- Apps - Memory used by user-space applications: The amount of memory used by applications running in user mode\n- PageTables: The amount of memory used by page tables (data structures that maintain the mapping between virtual and physical memory)\n- SwapCache: The amount of memory used by swap cache (cache for data in the swap area on the disk)\n- Slab: The amount of memory used by the slab cache (cache for managing memory efficiently by the OS)\n- Cache: The amount of memory used by the cache (used to speed up data access between CPU and main memory)\n- Buffers: The amount of memory used by buffers (temporary storage areas for data)\n- Unused: The amount of physical memory not yet allocated by the OS\n- Swap: The amount of memory used by swap (when physical memory runs out, inactive memory pages are moved to swap space on the disk)\n- Hardware Corrupted: The amount of memory used when part of the physical memory is corrupted for any reason\n\n#### Disk IOps\nMetrics for monitoring the number of disk read/write operations.\n\nThis indicates the number of I/O operations per second.\n\n#### I/O Utilization\nMetrics for monitoring disk I/O utilization.\n\n### Config\nShows various PostgreSQL configuration values.\n\n#### Version\nIndicates the version.\n\n#### Max connections\nIndicates the maximum number of connections.\n\nIf the database exceeds the maximum number of connections, further connections may be rejected.\n\nTo prevent resource exhaustion and connection waiting, it is necessary to set an appropriate maximum number of connections.\n\n#### Max worker processes\nIndicates the maximum number of worker processes.\n\nIf the database exceeds the maximum number of concurrent processes, performance may degrade.\n\n#### Max parallel workers\nIndicates the maximum number of workers for parallel query execution.\n\nTo prevent parallel queries from excessively consuming resources, it is necessary to set an appropriate maximum number of parallel workers.\n\n#### Effective cache\nIndicates the effective cache size used by the database.\n\nTo maximize the cache hit rate, it is necessary to set an appropriate cache size.\n\n#### Shared buffers\nIndicates the amount of data the database holds in shared buffers.\n\nSetting an appropriate buffer size can reduce disk I/O and optimize database performance.\n\n#### Work mem\nIndicates the amount of memory used for temporary data processing.\n\nSince this is used for query operations such as sorting and hash joins, setting an appropriate work memory size can optimize query memory usage and performance.\n\n#### Maintenance work mem\nIndicates the amount of memory used for maintenance tasks (e.g., VACUUM, CREATE INDEX).\n\nIt affects the efficiency of maintenance operations, so it is necessary to set an appropriate maintenance work memory size.\n\n#### WAL buffers\nIndicates the size of the WAL (Write-Ahead Logging) buffers.\n\nWAL buffers are used for log writing and synchronization, so setting an appropriate WAL buffer size can optimize log writing performance and maintain transaction consistency.\n\n### Cache\nMetrics for monitoring database cache.\n\n#### Cache hit rate\nIndicates the percentage of data the database retrieves directly from the cache.\n\nTo reduce disk I/O and optimize database performance, it is necessary to maximize the cache hit rate.\n\n### Connections and activities\nMetrics for monitoring database connections and activities.\n\n#### Active connections\nIndicates the number of active clients connected to the database.\n\nExcessive connections can lead to resource exhaustion and performance degradation, so it is necessary to set an appropriate number of connections.\n\n### Transaction\nMetrics for monitoring database transactions.\n\n#### Number of transaction commits\nIndicates the number of committed transactions.\n\nThis can be used as an indicator of the database's processing capacity and load, and to optimize performance.\n\n#### Number of transaction rollbacks\nIndicates the number of rolled-back transactions.\n\nFrequent rollbacks may indicate problems with the application or data integrity, so monitoring is necessary.\n\n### WAL\nMetrics related to Write-Ahead Logging (WAL).\n\nWAL is a mechanism for writing database transaction logs to ensure data durability and consistency.\n\nWAL data is written to the WAL buffers in memory, and when committed or when the WAL buffers exceed the defined amount, it is written to the WAL files on disk.\n\n#### Buffers checkpoint total\nIndicates the total number of WAL checkpoints.\n\nIf this number is high, it means data is frequently being written to the disk, which can affect system performance, so monitoring is necessary.\n\nA checkpoint is a specific point in time where all data files are updated to reflect the information in the logs.\n\n### Vacuum\nMetrics related to Vacuum.\n\n#### Autovacuum execution count\nIndicates the number of times autovacuum has been executed.\n\nAutovacuum automatically runs VACUUM and ANALYZE.\n\nVACUUM is used to reclaim free space in the database, and ANALYZE is used to update database statistics.\n\nTo monitor whether database maintenance is being performed correctly, it is necessary to check the autovacuum execution count.\n\n#### Vacuum execution count\nIndicates the number of times vacuum has been executed.\n\nBy monitoring the number of times manual or scheduled vacuum has been executed, you can check whether database maintenance is being performed correctly.\n\n#### Number of dead tuples in table\nIndicates the number of dead tuples in the table.\n\nA tuple is a data structure representing a row in the database, and dead tuples refer to deleted rows.\n\nIf there are many dead tuples, database performance may degrade, so monitoring is necessary.\n\n### Lock\nMetrics for monitoring database locks.\n\n#### Lock count\nIndicates the number of locks that occurred in the database.\n\nMonitoring the number of locks is necessary to track performance degradation and the risk of deadlocks.\n\n### PgCat\nMetrics related to PgCat.\n\n#### Active connections\nIndicates the number of active client connections to PgCat.\n\nTo monitor system load and performance, it is necessary to monitor the number of active connections.\n\n#### Pool size\nIndicates the maximum size of the connection pool PgCat reserves for the database.\n\nBy setting an appropriate pool size, you can optimize the number of connections to the database and improve performance.\n\n#### Average errors\nIndicates the average number of PgCat errors.\n\nSince errors can affect system stability and availability, it is necessary to monitor the number of errors.\n\n#### Average wait time\nIndicates the average wait time in PgCat.\n\nIf wait times are long, system performance may degrade, so monitoring is necessary.\n\n#### Active clients\nIndicates the number of active clients in PgCat.\n\nBy monitoring the number of active clients, you can assess system load and performance.\n\n#### Waiting clients\nIndicates the number of clients waiting in PgCat.\n\nIf there are many waiting clients, system performance may degrade, so expanding pool size or optimizing query processing may be necessary.\n\n#### Idle clients\nIndicates the number of idle clients in PgCat. Idle clients are connected to the database but are not performing any operations.\n\nIf there are many idle clients, connection pool optimization and resource reuse may be required.\n\n#### Active server connections\nIndicates the number of active server connections PgCat has with the database.\n\nBy monitoring the number of active server connections, you can assess the number of connections and load on the database.\n\n#### Idle server connections\nIndicates the number of idle server connections PgCat has with the database.\n\nIf there are many idle server connections, connection pool optimization and resource reuse may be required.\n\n# Load Testing\n1. `http://localhost:8089`\n2. Run load testing\n\nIf you want to scale the worker, run like this.\n`docker compose up --scale worker=5`\n\nIf you run a load test with PostgreSQL or PgCat settings at extreme values, it will be easier to see trends in how changed parameters affect performance.\n\n# References\n- [PgCat configuration](https://postgresml.org/docs/open-source/pgcat/configuration)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmf-san%2Fpostgresql-pgcat-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmf-san%2Fpostgresql-pgcat-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmf-san%2Fpostgresql-pgcat-example/lists"}