HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Why monitor bytes sent and received on mysql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whysentmysqlbytesreceivedmonitorand

Problem

I want to know why we should monitor bytes sent and received on mysql ?
I hope I have not asked a vague question.

Thanks.

Solution

First, let's identify each status variable:

  • Bytes_received: The number of bytes received from all clients.



  • Byte_sent: The number of bytes sent to all clients.



The only place I can think of where these number would make sense would be in the network. These status values represent the amount of data passing in and out of DB Connections. These bytes would most likely be visible from another perspective: the Operating System.

You could measure the amount on incoming/outgoing traffic in netstat against MySQL's view of it. If the amount of incoming data is low, or if the amount of outgoing data from MySQL is significantly higher than netstat says, check MySQL and/or the network. You may also want to look for any signs of dropped packets along any interfaces.

In light of this, when it comes to tuning, the only thing I can think of that you may want to tune is setting two things:

  • net_buffer_length : Connection and result buffer size



  • max_allowed_packet : Maximum packet size used internally by MySQL



What is a MySQL Packet ?

According to the page 99 of the Book

here are paragraphs 1-3 explaining it:


MySQL network communication code was
written under the assumption that
queries are always reasonably short,
and therefore can be sent to and
processed by the server in one chunk,
which is called a packet in MySQL
terminology. The server allocates the
memory for a temporary buffer to store
the packet, and it requests enough to
fit it entirely. This architecture
requires a precaution to avoid having
the server run out of memory---a cap
on the size of the packet, which this
option accomplishes.


The code of interest in relation to
this option is found in
sql/net_serv.cc. Take a look at my_net_read(), then follow the call to my_real_read() and pay
particular attention to
net_realloc().


This variable also limits the length
of a result of many string functons.
See sql/field.cc and
sql/intem_strfunc.cc for details.

Given this information, you may want to

  • raise net_buffer_length to its max value of 1048576



  • raise max_allowed_packet to 256M, 512M, or 1G (especially if you have BLOB data)

Context

StackExchange Database Administrators Q#45559, answer score: 6

Revisions (0)

No revisions yet.