Needing to restart php5-fpm/MySql constantly; internal error 500

I upgraded from ubuntu 10.04 lts 32 bit to 12.04 lts 64 bit a month or two ago so not sure if that is the cause, but im noticing there is massive lag which eventually lead to an internal server error 500. It happens alot when one of the WP sites get to around 30 users. (it was fine with 130 before on 10.04.. just a little slow) Restarting PHP5-fpm or mysql will cause the server to come back online. The static stuff (html, css, pictures) work fine.. anything that invokes mysql hangs (it eventually comes back and dies again. rinse and repeat) Is anyone able to provide some insight? Thanks!! //linux semi n00b

P.S. I can also provide other details if needed

Server is running Apache2, Php5-fpm (fastcgi), (2gb linode)

Apache/2.2.22 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_fcgid/2.3.6

FPM SETTINGS

pm.max_requests = 200
pm = ondemand
pm.max_children =16
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 2

MySQL (my.cnf)

key_buffer        = 64M
max_allowed_packet    = 16M
thread_stack        = 256K
thread_cache_size       = 8
#CUSTOM ADJUSTMENTS
open_files_limit = 5000
query_cache_size=16M
tmp_table_size = 16M
max_heap_table_size = 16M
table_cache = 500
innodb_buffer_pool_size=512M
max_connections = 150
expire_logs_days    = 10
max_binlog_size         = 100M

MySqlTuner

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.44-0ubuntu0.12.04.1
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in MyISAM tables: 257M (Tables: 706)
[--] Data in InnoDB tables: 1G (Tables: 953)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 969

-------- Performance Metrics -------------------------------------------------
[--] Up for: 8h 43m 41s (2M q [93.855 qps], 29K conn, TX: 57B, RX: 731M)
[--] Reads / Writes: 84% / 16%
[--] Total buffers: 624.0M global + 2.8M per thread (150 max threads)
[OK] Maximum possible memory usage: 1.0G (51% of installed RAM)
[OK] Slow queries: 0% (0/2M)
[OK] Highest usage of available connections: 8% (13/150)
[OK] Key buffer size / total MyISAM indexes: 64.0M/17.8M
[OK] Key buffer hit rate: 99.9% (1M cached / 2K reads)
[OK] Query cache efficiency: 89.2% (2M cached / 2M selects)
[!!] Query cache prunes per day: 281907
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 66K sorts)
[!!] Temporary tables created on disk: 32% (10K on disk / 31K total)
[OK] Thread cache hit rate: 99% (18 created / 29K connections)
[!!] Table cache hit rate: 16% (500 open / 3K opened)
[OK] Open file limit used: 11% (551/5K)
[OK] Table locks acquired immediately: 99% (394K immediate / 394K locks)
[!!] InnoDB data size / buffer pool: 1.2G/512.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    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
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    query_cache_size (> 16M)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_cache (> 500)
    innodb_buffer_pool_size (>= 1G)

1 Reply

I am not very familiar with php-fpm, but my understanding is that the number of fpm servers should be around 1x to 2x the number of CPUs on your machine. Run cat /proc/cpuinfo to see how many CPUs you have and adjust maxchildren, startservers, and maxspareservers accordingly.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct