LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > LSWS Rails App MySQL Connection Errors

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-30-2009, 01:27 AM
malffred malffred is offline
Member
 
Join Date: Dec 2006
Location: Hawaii
Posts: 27
Question LSWS Rails App MySQL Connection Errors

I don't know if this is specifically Rails related, but it might be.

I frequently get these types of errors:
  1. Mysql::Error: Lost connection to MySQL server during query
  2. Mysql::Error: Server has gone away

I definitely get the first one the most. Are there any settings in Litespeed (or Rails if you know them) I can tweak to either increase a timeout that causes this or force a reconnect? Do I need to tweak MySQL, LiteSpeed, LSAPI or Rails (We're running Rails 2.3.2)?

We have LiteSpeed to spawn up to (Max connections) 4 Rails instances and hte site feels really fast, also memory is not maxed out. Should we increase the instances? Or maybe the timeout limits on our current LSWS settings are too high? They are set to around 60-120sec. Some of our timeout settings in LSWS:
  • Server Level: Keep-Alive Timeout - 2sec
  • Server Level: Ruby on Rails - LSAPI_MAX_IDLE=300
  • Server Level: Ruby on Rails - Initial Request Timeout - 120sec
  • Server Level: Ruby on Rails - Connection Keepalive Timeout - 90sec
  • Server Level: Ruby on Rails - Retry Timeout - 0sec
  • Server Level: Ruby on Rails - Max Idle Time = -1
  • Server Level: Ruby on Rails - Max Idle Time = -1

Some other details:
  • 2GB Server Memory, about 800MB goes to LSWS
  • Max Connections: 4 Rails Instances
  • 550/600MB LSWS Rails Soft/Hard Limit
  • LSWS 4.0+ Caching Disabled
  • MySQL Ruby Gem = v2.7
  • MySQL Version = 5.0.51a-3
  • LSWS Version = 4.0.10

I have not specified any specific settings in MySQL to drop the connection, in fact in my my.cnf file I have this: max_connect_errors = 999999 also in config/database.yml we have reconnect: true

We also have memcached running with 350MB cache and is using well below that.

MySQLTuner script shows things are pretty good regarding mysql server settings:

Code:
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.51a-3ubuntu5.3-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in InnoDB tables: 145M (Tables: 121)
[OK] Total fragmented tables: 0

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 7h 6m 3s (103K q [0.924 qps], 1K conn, TX: 502M, RX: 10M)
[--] Reads / Writes: 93% / 7%
[--] Total buffers: 745.0M global + 3.5M per thread (70 max threads)
[OK] Maximum possible memory usage: 990.5M (48% of installed RAM)
[OK] Slow queries: 0% (3/103K)
[OK] Highest usage of available connections: 10% (7/70)
[OK] Key buffer size / total MyISAM indexes: 200.0M/170.9M
[!!] Key buffer hit rate: 85.5% (942 cached / 137 reads)
[OK] Query cache efficiency: 51.1% (45K cached / 88K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2K sorts)
[!!] Temporary tables created on disk: 46% (7K on disk / 15K total)
[OK] Thread cache hit rate: 99% (7 created / 1K connections)
[OK] Table cache hit rate: 84% (143 open / 170 opened)
[OK] Open file limit used: 2% (36/1K)
[OK] Table locks acquired immediately: 100% (49K immediate / 49K locks)
[OK] InnoDB data size / buffer pool: 145.2M/250.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Enable the slow query log to troubleshoot bad queries
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
    tmp_table_size (> 100M)
    max_heap_table_size (> 100M)
Thanks for any help or ideas.
Reply With Quote
 

Tags
lsws, mysql, rails, ruby on rails

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:45 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.