Question

I'm a novice to database administration and have been depending on forum suggestions and answers to help resolve my database hang ups and too many connections errors; I've managed to reduce the frequency of too many connections errors but I'd like to eliminate them at this level.

According to an answer by RolandoMySQLDBA on this post, "If Open_tables climbs above (Opened_tables / Uptime), I have a cause for concern.."

My Server specs is 2.0Mhz and 484Mem; I've had a client whose having a lot of hits upto 1000 requests per hour and with processing mainly of their 2 InnoDB tables, that translates to roughly 3000 connections made to both tables in an hour.

From advise on another forum, I've made changes to my.cnf and it translates to this:

[mysqld]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
skip-locking
key_buffer_size = 30M
max_allowed_packet = 1M
table_cache = 300
sort_buffer_size = 256K
read_buffer_size = 1M
read_rnd_buffer_size = 1M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
net_buffer_length = 12K
thread_stack = 1M
innodb_buffer_pool_size=60M
interactive_timeout=300
wait_timeout=300

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 48M
sort_buffer_size = 48M
#key_buffer_size = 256M
#sort_buffer_size = 256M
#read_buffer = 2M
#write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

When I checked the parameters of opened_tables, open_tables and uptime as per the post, I get these values:

Uptime = 78018
Opened_tables = 1606999
Open tables = 300

therefore: Opened_tables / Uptime=1606999/78018= 20.6

However, my Opened_tables variable has not changed in 3 hours; It has been the same.

After these changes, the server load had occurred twice in the past 24Hours (at night) and I didn't record the value for Opened_tables at this period; But as you'll note from the calculation, the Opened_tables value increased drastically last night during when many client requests came through.

Output of thread variables are:

 Threads_cached                    | 7          |
| Threads_connected                 | 14         |
| Threads_created                   | 306        |
| Threads_running                   | 2 

and i note from the mysql documentation (http://dev.mysql.com/doc/refman/5.5/en/server-status-variables.html#statvar_Threads_connected) that I need to increase the thread_cache_size .

my max_connections is the default;

So basically:

  1. I need to increase thread_cache_size;
  2. I need to increase the table_open_cache (but a very large value also causes unreliability)

I've just had a "too many connections" error at the time of posting this and can't get results for Opened_tables and Open_tables; Also, I can't login with another session to the server; I automatically get disconnected.

QUESTIONS:

  1. What method should I use to approximate the values of
    thread_cache_size and table_open_cache?

  2. Is my max_connections too low? How can I calculate the best max_connections setting?

  3. How can I reduce the "too many connections" error (without creating another user and having that user be the one making the connections rather than root) ?

    NOTE: No I can't upgrade memory as at now. Thanks. Right now the only way I deal with this is to close the port form incoming messages (which is not exactly ethical) or to restart server to pending messages in system can be processed and memory freed.


After my now too many connections errors - which I've resolved by blocking the receiving port; my variables are now:

Opened_tables = 1970498 
Open_tables =300

| Threads_cached                    | 6          |
| Threads_connected                 | 15         |
| Threads_created                   | 437        |
| Threads_running                   | 2          |

Any advise i dealing with this wisely and efficiently will be much appreciated. Thanks in Advance.

[3]:

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top