Discover Centmin Mod today
Register Now

Xenforo Large attachments time out

Discussion in 'Forum software usage' started by sepulchre, Jan 26, 2025.

  1. sepulchre

    sepulchre Member

    168
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    8:54 PM
    Hello,


    my users are complaining about not being able to open large attachments (10mb-100mb) like PDF files. They just time out. When I try to open them via my browser, I see a loading sign on the browser tab and it times out and never opens.

    And files between 2-10mb take a while for them to open, before they were opened instantly and the large ones took like 2-3 seconds (to download).

    The site is super fast however, no complaints on that, just the attachments.

    I disabled all XF addons except for the S3 addon (I store my files elsewhere) and no luck.
    And I think I did my due dilligence about researching the problem, reading several threads on here and on XF and also no luck. I checked all log files I could find and I tweaked any config settings I found.

    Before doing all of this, I didn't touch anything for months (years) and it worked. I don't understand why suddenly this problem has begun. I assume some sort of server side limitation is in play here, which is why I am asking on here rather than on XF. If something times out, usually a config setting needs to be adjusted, but I believe I touched all of them and no luck so far.

    Here a list of files I looked at:
    upload_2025-1-25_18-9-2.png


    The server where the files are is a storage server, nothing else is on there. But maybe the connection to them times out? But I use it for years and its super fast normally. I also downloaded a backup of all my attachments from that and no problems with it via Filezilla. Alternatively maybe a Cloudflare problem? Or maybe a server side problem?

    At this point I am just desperate :D cause I don't know what else to do.

    Thanks.


    • CentOS Version:
      Code (Text):
      7.9
    • Centmin Mod Version Installed:
      Code (Text):
      124.00stable.s129
    • Nginx Version Installed:
      Code (Text):
      1.27.3 (240125-212948-centos7-kvm-24bcf87)
    • PHP Version Installed:
      Code (Text):
      7.4.33
    • MariaDB MySQL Version Installed:
      Code (Text):
      10.4.34
    • When was last time updated Centmin Mod code base ?
      Code (Text):
      Today
    • Persistent Config:
      Code (Text):
      LETSENCRYPT_DETECT='y'
      ENABLE_MARIADBTENTWOUPGRADE='y'
      ENABLE_MARIADBTENTHREEUPGRADE='y'
      ENABLE_MARIADBTENFOURUPGRADE='y'
      
      MARCH_TARGETNATIVE='n'
      
      
    • b_customphp.ini
      Code (Text):
      max_execution_time = 5000
      max_input_time = 5000
      short_open_tag = On
      realpath_cache_size = 1536k
      realpath_cache_ttl = 28800
      upload_max_filesize = 320M
      memory_limit = 768M
      post_max_size = 320M
      expose_php = Off
      mail.add_x_header = Off
      max_input_nesting_level = 128
      max_input_vars = 30000
      mysqlnd.net_cmd_buffer_size = 16384
      mysqlnd.collect_memory_statistics = Off
      mysqlnd.mempool_default_size = 32000
      always_populate_raw_post_data=-1
      
    • my.cnf
      Code (Text):
      [client]
      socket=/var/lib/mysql/mysql.sock
      
      [mysql]
      max_allowed_packet = 64M
      
      [mysqld]
      ignore_db_dirs=cmsetiofiotest
      local-infile=0
      ignore_db_dir=lost+found
      character-set-server=utf8
      datadir=/var/lib/mysql
      socket=/var/lib/mysql/mysql.sock
      
      #bind-address=127.0.0.1
      # optimized my.cnf for MariaDB 5.5.x
      # by eva2000
      # vbtechsupport.com
      
      tmpdir=/home/mysqltmp
      
      innodb=ON
      #skip-federated
      ###skip-pbxt
      ####skip-pbxt_statistics
      #skip-archive
      #skip-name-resolve
      #old_passwords
      back_log = 350
      max_connections = 350
      key_buffer_size = 256M
      myisam_sort_buffer_size = 256M
      myisam_max_sort_file_size = 2048M
      join_buffer_size = 256K
      read_buffer_size = 256K
      sort_buffer_size = 256K
      table_definition_cache = 8192
      table_open_cache = 4096
      thread_cache_size = 256
      wait_timeout = 1800
      connect_timeout = 10
      tmp_table_size = 256M
      max_heap_table_size = 256M
      max_allowed_packet = 64M
      #max_seeks_for_key = 4294967295
      #group_concat_max_len = 1024
      max_length_for_sort_data = 1024
      net_buffer_length = 16384
      max_connect_errors = 100000
      concurrent_insert = 2
      read_rnd_buffer_size = 512K
      bulk_insert_buffer_size = 8M
      # query_cache boost for MariaDB >10.1.2+
      # https://community.centminmod.com/posts/30811/
      query_cache_limit = 1024K
      query_cache_size = 80M
      query_cache_type = 1
      query_cache_min_res_unit = 2K
      query_prealloc_size = 262144
      query_alloc_block_size = 65536
      transaction_alloc_block_size = 8192
      transaction_prealloc_size = 4096
      default-storage-engine = InnoDB
      
      log_warnings=1
      slow_query_log=0
      long_query_time=1
      slow_query_log_file=/var/lib/mysql/slowq.log
      log-error=/var/log/mysqld.log
      
      # innodb settings
      innodb_large_prefix=1
      innodb_purge_threads = 1
      innodb_file_format = Barracuda
      innodb_file_per_table = 1
      innodb_open_files = 4000
      innodb_data_file_path= ibdata1:10M:autoextend
      innodb_buffer_pool_size = 512M
      
      ## https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_buffer_pool_instances
      innodb_buffer_pool_instances=2
      
      innodb_log_files_in_group = 2
      innodb_log_file_size = 256M
      innodb_log_buffer_size = 8M
      innodb_flush_log_at_trx_commit = 2
      #innodb_thread_concurrency = 0
      innodb_lock_wait_timeout=50
      innodb_flush_method = O_DIRECT
      
      # 200 * # DISKS
      innodb_io_capacity = 300
      innodb_io_capacity_max = 2000
      innodb_read_io_threads = 4
      innodb_write_io_threads = 2
      innodb_flush_neighbors = 1
      
      # mariadb settings
      [mariadb]
      #thread-handling = pool-of-threads
      #thread-pool-size= 20
      #mysql --port=3307 --protocol=tcp
      #extra-port=3307
      #extra-max-connections=1
      
      userstat = 0
      key_cache_segments = 1
      aria_group_commit = none
      aria_group_commit_interval = 0
      aria_log_file_size = 64M
      aria_log_purge_type = immediate
      aria_pagecache_buffer_size = 64M
      aria_sort_buffer_size = 64M
      
      [mariadb-5.5]
      innodb_file_format = Barracuda
      innodb_file_per_table = 1
      
      #ignore_db_dirs=
      query_cache_strip_comments=0
      
      innodb_read_ahead = linear
      innodb_adaptive_flushing_method = estimate
      innodb_flush_neighbor_pages = 1
      innodb_stats_update_need_lock = 0
      innodb_log_block_size = 512
      
      log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
      
      [mysqld_safe]
      socket=/var/lib/mysql/mysql.sock
      log-error=/var/log/mysqld.log
      #nice = -5
      open-files-limit = 8192
      
      [mysqldump]
      quick
      max_allowed_packet = 64M
      
      [myisamchk]
      tmpdir=/home/mysqltmp
      key_buffer = 256M
      sort_buffer = 32M
      read_buffer = 32M
      write_buffer = 32M
      
      [mysqlhotcopy]
      interactive-timeout
      
      [mariadb-10.0]
      innodb_file_format = Barracuda
      innodb_file_per_table = 1
      
      # 2 variables needed to switch from XtraDB to InnoDB plugins
      #plugin-load=ha_innodb
      #ignore_builtin_innodb
      
      ## MariaDB 10 only save and restore buffer pool pages
      ## warm up InnoDB buffer pool on server restarts
      innodb_buffer_pool_dump_at_shutdown=1
      innodb_buffer_pool_load_at_startup=1
      innodb_buffer_pool_populate=0
      ## Disabled settings
      performance_schema=OFF
      innodb_stats_on_metadata=OFF
      innodb_sort_buffer_size=2M
      innodb_online_alter_log_max_size=128M
      query_cache_strip_comments=0
      log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
      
      [mariadb-10.1]
      innodb_file_per_table = 1
      
      ## wsrep specific
      # wsrep_on=OFF
      # wsrep_provider
      # wsrep_cluster_address
      # binlog_format=ROW
      # default_storage_engine=InnoDB
      # innodb_autoinc_lock_mode=2
      # innodb_doublewrite=1
      # query_cache_size=0
      
      # 2 variables needed to switch from XtraDB to InnoDB plugins
      #plugin-load=ha_innodb
      #ignore_builtin_innodb
      
      ## MariaDB 10 only save and restore buffer pool pages
      ## warm up InnoDB buffer pool on server restarts
      innodb_buffer_pool_dump_at_shutdown=1
      innodb_buffer_pool_load_at_startup=1
      innodb_buffer_pool_populate=0
      ## Disabled settings
      performance_schema=OFF
      innodb_stats_on_metadata=OFF
      innodb_sort_buffer_size=2M
      innodb_online_alter_log_max_size=128M
      query_cache_strip_comments=0
      log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
      
      # Defragmenting unused space on InnoDB tablespace
      innodb_defragment=1
      innodb_defragment_n_pages=7
      innodb_defragment_stats_accuracy=0
      innodb_defragment_fill_factor_n_recs=20
      innodb_defragment_fill_factor=0.9
      innodb_defragment_frequency=40
      
      
      [mariadb-10.2]
      #innodb_file_format = Barracuda
      innodb_default_row_format = dynamic
      innodb_file_per_table = 1
      
      ## wsrep specific
      # wsrep_on=OFF
      # wsrep_provider
      # wsrep_cluster_address
      # binlog_format=ROW
      # default_storage_engine=InnoDB
      # innodb_autoinc_lock_mode=2
      # innodb_doublewrite=1
      # query_cache_size=0
      
      # 2 variables needed to switch from XtraDB to InnoDB plugins
      #plugin-load=ha_innodb
      #ignore_builtin_innodb
      
      ## MariaDB 10 only save and restore buffer pool pages
      ## warm up InnoDB buffer pool on server restarts
      innodb_buffer_pool_dump_at_shutdown=1
      innodb_buffer_pool_load_at_startup=1
      ## Disabled settings
      performance_schema=OFF
      innodb_stats_on_metadata=OFF
      innodb_sort_buffer_size=2M
      innodb_online_alter_log_max_size=128M
      query_cache_strip_comments=0
      log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
      
      # Defragmenting unused space on InnoDB tablespace
      innodb_defragment=1
      innodb_defragment_n_pages=7
      innodb_defragment_stats_accuracy=0
      innodb_defragment_fill_factor_n_recs=20
      innodb_defragment_fill_factor=0.9
      innodb_defragment_frequency=40
      
      # page compression
      # 10.1+ https://mariadb.com/kb/en/mariadb/compression/
      #innodb_compression_algorithm=zlib
      #innodb_use_fallocate=0
      #innodb_use_mtflush=0
      #innodb_mtflush_threads=4
      
      
      [mariadb-10.3]
      #innodb_file_format = Barracuda
      innodb_default_row_format = dynamic
      innodb_file_per_table = 1
      
      ## wsrep specific
      # wsrep_on=OFF
      # wsrep_provider
      # wsrep_cluster_address
      # binlog_format=ROW
      # default_storage_engine=InnoDB
      # innodb_autoinc_lock_mode=2
      # innodb_doublewrite=1
      # query_cache_size=0
      
      # 2 variables needed to switch from XtraDB to InnoDB plugins
      #plugin-load=ha_innodb
      #ignore_builtin_innodb
      
      ## MariaDB 10 only save and restore buffer pool pages
      ## warm up InnoDB buffer pool on server restarts
      innodb_buffer_pool_dump_at_shutdown=1
      innodb_buffer_pool_load_at_startup=1
      ## Disabled settings
      performance_schema=OFF
      innodb_stats_on_metadata=OFF
      innodb_sort_buffer_size=2M
      innodb_online_alter_log_max_size=128M
      query_cache_strip_comments=0
      log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
      
      # Defragmenting unused space on InnoDB tablespace
      innodb_defragment=1
      innodb_defragment_n_pages=7
      innodb_defragment_stats_accuracy=0
      innodb_defragment_fill_factor_n_recs=20
      innodb_defragment_fill_factor=0.9
      innodb_defragment_frequency=40
      
      # page compression
      # 10.1+ https://mariadb.com/kb/en/mariadb/compression/
      #innodb_compression_algorithm=zlib
      #innodb_use_fallocate=0
      #innodb_use_mtflush=0
      #innodb_mtflush_threads=4
      
      
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,864
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    5:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You really using this ancient Centmin Mod version?

    You'd want to be on Centmin Mod 131.00stable or 140.00beta01 release https://community.centminmod.com/th...ase-with-almalinux-rocky-linux-support.25572/ even if you're on EOL CentOS 7 https://centminmod.com/centos7eol.

    If you have large attachments for Xenforo and using Nginx, you can install and configure Xon's attachment improvement addon Attachment Improvements By Xon to configure Nginx Nginx X-Accel-Redirect so that Xenforo does the attachment permission validation but passes on actual attachment serving from PHP-FPM to Nginx instead so less likely for PHP-FPM related time outs and queued requests. See FAQ Attachment Improvements By Xon - Extra info to understand how to configure Nginx X-Accel-Redirect for locally hosted attachments within webroot vs outside of webroot. Where webroot for Nginx would be /home/nginx/domains/yourdomain.com/public

    Your issues most likely are due to PHP-FPM needing tuning. So best to start read thoroughly the guide at PHP-FPM - How to troubleshoot & optimize PHP-FPM server? and start with inspecting Nginx and PHP-FPM logs for clues for time outs. 10MB is pretty large depending on your server specs and Nginx and PHP-FPM config and average/peak attachment utilising PHP resources :)

    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    Nginx 502 or 504 Bad Gateway Errors



    Bad gateway 502 /504 timeouts are usually related to Nginx timing out waiting on PHP-FPM to respond as PHP-FPM is overloaded or overwhelmed with requests, so may need to tune PHP-FPM values. It also maybe due to PHP-FPM in turn being queued and backed up waiting on MariaDB MySQL server to respond - so also need to look at MySQL.

    You'll need to tune your PHP-FPM settings with php-fpm main pool config file at /usr/local/etc/php-fpm.conf (overview of config files) and this is left up to end user to do but here's a thread for starters to enable PHP-FPM status page output outlined at
    Enabling PHP-FPM status also allows setting up 3rd party PHP-FPM status metric monitoring from services like:

    Checking PHP-FPM etc logs



    You'll also need to check into your PHP-FPM, Nginx and MariaDB logs which you can find as outlined at How to troubleshoot Centmin Mod initial install issues

    Server logs include Nginx, PHP-FPM, MariaDB MySQL error logs as well as others. You can find your Centmin Mod install/menu logs at FAQ 7 and server logs at FAQ 19 at Centmin Mod FAQ (most up to date info in FAQ so always read that first). Spoiler tag below has info too but may not be up to date.

    Some of Centmin Mod's installed software will have their own access and error logs which maybe useful for diagnosing errors or give info, notes, or warning notices.

    Note: There's no support provided by me for diagnosing such errors which may occur for various reasons including misconfiguration of installed php/mysql scripts or applications.

    In SSH2 telnet you can use tail command to view the last X number of lines in the file.

    For example for viewing last 10 lines in the file for:

    For Nginx access and error logs:
    Code:
      tail -10 /usr/local/nginx/logs/access.log
      tail -10 /usr/local/nginx/logs/error.log
    
    For specific domainname.com access and error log:
    Code:
      tail -10 /home/nginx/domains/domainname.com/log/access.log
      tail -10 /home/nginx/domains/domainname.com/log/error.log
    
    For other system error logs located at /var/log:

    list /var/log files in ascending time order so the most recently modified files are at the bottom
    Code:
      ls -lhrt /var/log
    
    Code:
    total 2.7M
    -rw------- 1 root  root    0 Aug 29 15:33 tallylog
    -rw------- 1 root  root    0 Aug 29 15:33 spooler
    drwx------ 3 root  root 4.0K Aug 29 15:35 samba
    drwxr-xr-x 2 root  root 4.0K Aug 29 15:35 mail
    -rw-r--r-- 1 root  500     0 Oct  8 18:13 dmesg.old
    -rw------- 1 root  500     0 Oct  8 18:13 boot.log
    -rw-r--r-- 1 root  500     0 Oct  8 18:14 dmesg
    drwx------ 2 root  root 4.0K Oct  8 18:14 httpd
    drwxr-xr-x 2 root  root 4.0K Oct  8 19:08 php-fpm
    -rw-rw---- 1 mysql root 2.3K Oct  9 12:38 mysqld.log
    -rw------- 1 root  root 9.2K Oct 26 10:48 yum.log
    -rw------- 1 root  utmp  94K Nov  7 22:59 btmp
    drwxr-xr-x 2 root  root 4.0K Nov  8 00:00 sa
    -rw------- 1 root  root 269K Nov  8 21:39 messages
    -rw------- 1 root  root 110K Nov  8 23:08 secure
    -rw-rw-r-- 1 root  utmp  43K Nov  8 23:08 wtmp
    -rw-r--r-- 1 root  root 144K Nov  8 23:08 lastlog
    -rw------- 1 root  root  69K Nov  8 23:08 lfd.log
    -rw------- 1 root  root 332K Nov  8 23:08 maillog
    -rw------- 1 root  500  1.6M Nov  8 23:10 cron
    
    For PHP-FPM error log:
    Code:
      tail -10 /var/log/php-fpm/www-error.log
    
    and/or
    Code:
      /var/log/php-fpm/www-php.error.log
    
    For MySQL / MariaDB error log:
    Code:
      tail -10 /var/log/mysqld.log
    
    For CSF firewall LFD log:
    Code:
      tail -10 /var/log/lfd.log
    
    For Mail log:
    Code:
      tail -10 /var/log/maillog
    
    For Cron job logs:
    Code:
      tail -10 /var/log/cron
    

    PHP-FPM Ctatus Checks



    You can check your PHP-FPM extended status for what PHP-FPM is processing
    Code (Text):
    curl -s localhost/phpstatus
    

    and
    Code (Text):
    curl -s "localhost/phpstatus?full"
    

    or json format
    Code (Text):
    curl -s "localhost/phpstatus?full&json | jq"
    


    How to edit php.ini and php-fpm configuration files ?



    Centmin Mod install created command short cuts outlined here to allow you to quickly edit your /usr/local/lib/php.ini file and your /usr/local/etc/php-fpm.conf file. Full list of command shortcuts below:
    • Edit php.ini = phpedit ( /usr/local/lib/php.ini )
    • Edit my.cnf = mycnf ( /etc/my.cnf )
    • Edit php-fpm.conf = fpmconf ( /usr/local/etc/php-fpm.conf )
    • Edit nginx.conf = nginxconf ( /usr/local/nginx/conf/nginx.conf )
    • Edit (nginx) virtual.conf = vhostconf - only edits /usr/local/nginx/conf/conf.d/virtual.conf not the additional vhost domain.com.conf files added later
    • Edit (nginx) php.conf = phpinc ( /usr/local/nginx/conf/php.conf )
    • Edit (nginx) drop.conf = dropinc ( /usr/local/nginx/conf/drop.conf )
    • Edit (nginx) staticfiles.conf = statfilesinc ( /usr/local/nginx/conf/staticfiles.conf )
    • nginx stop/start/restart = ngxstop/ngxstart/ngxrestart
    • php-fpm stop/start/restart = fpmstop/fpmstart/fpmrestart
    • mysql stop/start/restart = mysqlstop/mysqlstart/mysqlrestart
    • nginx + php-fpm stop/start/restart = npstop/npstart/nprestart
    • memcached stop/start/restart =memcachedstop/memcachedstart/memcachedrestart
    • csf stop/start/restart = csfstop/csfstart/csfrestart

    Troubleshooting Tools



    However, there's many linux tools and scripts that can help you figure out what was causing the load issues and when.

    Tools and commands you will want to read up on and learn for basic system admin tasks and troubleshooting.
    Notes:
    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)
     
  3. MaximilianKohler

    MaximilianKohler Member

    201
    7
    18
    Jun 23, 2023
    Ratings:
    +34
    Local Time:
    12:54 PM
    I experienced something like this and was given a php value to increase. I can't remember what exactly but it's on the XF forum.