Load details

Updated at:

DBGateway runs on your ECS instance alongside your self-managed MySQL database. This page describes how much CPU DBGateway consumes under different operating modes and how full SQL collection works at the packet level.

CPU overhead at a glance

Operating mode CPU overhead
Monitoring and alerting only (no full SQL, no slow SQL collection) 2%
Full SQL collection enabled — 4 vCPUs, 8 GiB, kernel 3.10, 8,000 TPS 10.7%

CPU overhead for full SQL collection depends on the Linux kernel version, the ECS hardware configuration, and the MySQL workload (measured in transactions per second, or TPS). See CPU overhead benchmarks for complete data.

How full SQL collection works

On Linux, DBGateway captures traffic by creating an AF_PACKET socket. The socket intercepts packets at the network layer without affecting data transmission.

DBGateway then:

  1. Parses captured packets using the TCP/IP protocol.

  2. Filters to inbound packets on MySQL ports only; all other ports are ignored.

  3. Assembles the filtered packets into complete SQL statements using the MySQL protocol.

  4. Packages, compresses, encrypts, and uploads the SQL statements to a DAS storage cluster.

PACKET_MMAP optimization (kernel 3.2 and later): On Linux kernels 3.2 and later, DBGateway uses PACKET_MMAP instead of a plain AF_PACKET socket. PACKET_MMAP allocates a kernel buffer in kernel space and maps it to user space via mmap(), which significantly reduces CPU overhead compared to older kernels.

CPU overhead benchmarks

The following results are from online stress testing with full SQL collection enabled.

Test environment:

Attribute Value
Hardware I/O optimized ECS, ecs.c5.xlarge type (4 vCPUs, 8 GiB memory)
OS and kernel 64-bit CentOS 6.8 (kernel 2.6), 64-bit CentOS 7.4 (kernel 3.10), 64-bit Ubuntu 16.04 (kernel 4.4)
Database client MySQL application on a separate ECS instance
Session threads 40 threads running SELECT, INSERT, UPDATE, DELETE
SQL statement size 50–281 bytes per statement
Measurement tool Linux top command

CPU utilization by kernel version and TPS:

Note: If you enable only basic monitoring (database performance monitoring and host performance monitoring), DBGateway uses only 2% of CPU.
Kernel version 1,000 TPS 2,000 TPS 4,000 TPS 8,000 TPS 16,000 TPS
2.6 6.3% 8.6% 12.3% 21% 33.9%
3.10 3.7% 4.7% 7% 10.7% 18%
4.4 4% 5.3% 7% 11% 18.7%

Kernels 3.10 and 4.4 show substantially lower CPU overhead than kernel 2.6 at all TPS levels, reflecting the PACKET_MMAP optimization. For example, at 8,000 TPS on kernel 3.10, DBGateway uses only 10.7% of CPU.