Mysql – Why monitor bytes sent and received on thesql

MySQL

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

Thanks.

Best Answer

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:

What is a MySQL Packet ?

According to the page 99 of the Book

Understanding MySQL Internals

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