ASTRAPI Posted November 11, 2009 Posted November 11, 2009 Hello I own a dedicated server: Processor : PE R200 Dual Core Xeon 3065 (2.33GHz, 4MB, 1333MHz FSB) Memory : 4GB (4x1GB Dual Rank DIMMs) 667MHz Harddisk : 500GB SATA (7,200rpm) 3.5inch Hard Drive (non hot-plug) 100Mbit Unshared Centos OS 32Bit One partition for the hard disk. Cpanel as Control panel. One partition for the hard disk. I have about 500.000 posts and about 30.000 users with daily 1000 new messages. Sql queries on index 11 and 1mb extra graphics. When i have the maximum for me 500 users per hour i can see about 900 sql connections using \s. My problem is that my forum is very very slow and sometimes i am getting IPS Error (the connection lost with the database) but i don't know why and what can i do to improve it. When i have 450 users and i need 10-20 seconds to open a topic i was try to restart the server and then i was able to have 500 users and super speed 1-2 seconds for openng a topic. So i was thinking as my Datacenter don't have a better hard disk to add more ram and 64bit OS Centos but how i must ask to be the partition? swap - 16GB /vz - the rest of the disk /boot - 400 MB A configuration like this? This is my my.cnf: local-infile=0 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-locking ## skip-innodb query_cache_limit=8M query_cache_size=4M query_cache_type=1 max_user_connections=240 max_connections=500 interactive_timeout=100 wait_timeout=60 connect_timeout=50 thread_cache_size=128 key_buffer=155M join_buffer=1M max_allowed_packet=16M table_cache=1024 record_buffer=1M sort_buffer_size=4M read_buffer_size=4M max_connect_errors=10 thread_concurrency=8 concurrent_insert=2 long_query_time=3 join_buffer_size=2M low_priority_updates=1 myisam_sort_buffer_size=64M skip-networking server-id=1 #[mysql.server] #user=mysql #basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/lib/mysql/mysql.pid open_files_limit=8192 #[mysqldump] #quick #max_allowed_packet=16M [mysql] no-auto-rehash [isamchk] key_buffer=64M sort_buffer=64M read_buffer=16M write_buffer=16M [myisamchk] key_buffer=64M sort_buffer=64M read_buffer=16M write_buffer=16M [mysqlhotcopy] interactive-timeout Top output: 1621 root 0 -20 0 0 0 R 11.4 0.0 1:47.02 loop0 20315 nobody 20 4 32024 15m 2876 S 2.3 0.5 0:01.69 httpd 20933 nobody 19 4 30136 14m 2844 S 2.3 0.4 0:00.45 httpd 20987 nobody 20 4 32692 16m 2848 S 2.3 0.5 0:00.51 httpd 20923 nobody 20 4 29076 13m 2840 S 2.0 0.4 0:00.56 httpd 21378 nobody 20 4 31520 15m 2772 S 2.0 0.5 0:00.11 httpd 20968 nobody 19 4 25044 9.8m 2844 S 1.6 0.3 0:00.38 httpd 20997 root 15 0 0 0 0 S 1.6 0.0 0:02.50 pdflush 21392 nobody 19 4 30020 14m 2708 S 1.6 0.4 0:00.05 httpd Now is it possible having there cpanel to use lihtttpd or nginx and xcache? Thank you/ - 50GB[mysqld]2280 mysql 21 6 126m 72m 3704 S 149.3 2.2 121:12.99 mysqld
3DKiwi Posted November 11, 2009 Posted November 11, 2009 What version of IPB are you running? Think I must get 500 users per hour at peak times and I'm running a lower specced dedicated server. I don't understand your question at the end. Linux mumbo jumbo. You might want to file a support ticket with IPS and get them to have a look at your configuration. 3DKiwi
Guest Posted November 11, 2009 Posted November 11, 2009 My suggestion would be to have you mySQL settings optimised with the amount of ram you have you should be able to zoom through 500 without even breaking a small sweat.
rct2·com Posted November 11, 2009 Posted November 11, 2009 Have you tried running www.mysqltuner.com ? Why do YOU think it's slow? Is it paging to disk and the memory is completely utilised, or is paging to disk and a lot of memory is unallocated, or is it not paging to disk at all? What is the server load figure when it's slow? (Could you post dumps from config files in code boxes instead of quote boxes. The fixed width font in code boxes makes them easier to read)
ASTRAPI Posted November 11, 2009 Author Posted November 11, 2009 V2.3.6 I need more than 10 seconds to open a topic. How can i check this? Config in code boxes:What version of IPB are you running?Why do YOU think it's slow?Is it paging to disk and the memory is completely utilised, or is paging to disk and a lot of memory is unallocated, or is it not paging to disk at all?[mysqld] local-infile=0 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-locking ## skip-innodb query_cache_limit=8M query_cache_size=4M query_cache_type=1 max_user_connections=240 max_connections=500 interactive_timeout=100 wait_timeout=60 connect_timeout=50 thread_cache_size=128 key_buffer=155M join_buffer=1M max_allowed_packet=16M table_cache=1024 record_buffer=1M sort_buffer_size=4M read_buffer_size=4M max_connect_errors=10 thread_concurrency=8 concurrent_insert=2 long_query_time=3 join_buffer_size=2M low_priority_updates=1 myisam_sort_buffer_size=64M skip-networking server-id=1 #[mysql.server] #user=mysql #basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/lib/mysql/mysql.pid open_files_limit=8192 #[mysqldump] #quick #max_allowed_packet=16M [mysql] no-auto-rehash [isamchk] key_buffer=64M sort_buffer=64M read_buffer=16M write_buffer=16M [myisamchk] key_buffer=64M sort_buffer=64M read_buffer=16M write_buffer=16M [mysqlhotcopy] interactive-timeout 2280 mysql 21 6 126m 72m 3704 S 149.3 2.2 121:12.99 mysqld 1621 root 0 -20 0 0 0 R 11.4 0.0 1:47.02 loop0 20315 nobody 20 4 32024 15m 2876 S 2.3 0.5 0:01.69 httpd 20933 nobody 19 4 30136 14m 2844 S 2.3 0.4 0:00.45 httpd 20987 nobody 20 4 32692 16m 2848 S 2.3 0.5 0:00.51 httpd 20923 nobody 20 4 29076 13m 2840 S 2.0 0.4 0:00.56 httpd 21378 nobody 20 4 31520 15m 2772 S 2.0 0.5 0:00.11 httpd 20968 nobody 19 4 25044 9.8m 2844 S 1.6 0.3 0:00.38 httpd 20997 root 15 0 0 0 0 S 1.6 0.0 0:02.50 pdflush 21392 nobody 19 4 30020 14m 2708 S 1.6 0.4 0:00.05 httpd Mysql Tunner results: [!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM [!!] MyISAM is enabled but isn't being used [!!] Total fragmented tables: 12 [!!] Allocating > 2GB RAM on 32-bit systems can cause system instability [!!] Maximum possible memory usage: 5.3G (164% of installed RAM) [!!] Query cache prunes per day: 60755 [!!] Sorts requiring temporary tables: 88% (96K temp sorts / 108K sorts) [!!] Table locks acquired immediately: 93% Tunining Primer for aql results: SLOW QUERIES The slow query log is NOT enabled. Current long_query_time = 3 sec. You have 2916 out of 1886723 that take longer than 3 sec. to complete Your long_query_time seems to be fine BINARY UPDATE LOG The binary update log is NOT enabled. You will not be able to do point in time recovery See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html WORKER THREADS Current thread_cache_size = 128 Current threads_cached = 117 Current threads_per_sec = 0 Historic threads_per_sec = 0 Your thread_cache_size is fine MAX CONNECTIONS Current max_connections = 500 Current threads_connected = 5 Historic max_used_connections = 121 The number of used connections is 24% of the configured maximum. Your max_connections variable seems to be fine. MEMORY USAGE Max Memory Ever Allocated : 1.39 G Configured Max Per-thread Buffers : 5.09 G Configured Max Global Buffers : 169 M Configured Max Memory Limit : 5.26 G Physical Memory : 3.21 G Max memory limit exceeds 90% of physical memory KEY BUFFER Current MyISAM index space = 162 M Current key_buffer_size = 155 M Key cache miss rate is 1 : 14493 Key buffer free ratio = 61 % Your key_buffer_size seems to be too high. Perhaps you can use these resources elsewhere QUERY CACHE Query cache is enabled Current query_cache_size = 4 M Current query_cache_used = 3 M Current query_cache_limit = 8 M Current Query cache Memory fill ratio = 99.06 % Current query_cache_min_res_unit = 4 K However, 44905 queries have been removed from the query cache due to lack of memory Perhaps you should raise query_cache_size MySQL won't cache query results that are larger than query_cache_limit in size SORT OPERATIONS Current sort_buffer_size = 4 M Current read_rnd_buffer_size = 256 K Sort buffer seems to be fine JOINS Current join_buffer_size = 2.00 M You have had 42 queries where a join could not use an index properly You should enable "log-queries-not-using-indexes" Then look for non indexed joins in the slow query log. If you are unable to optimize your queries you may want to increase your join_buffer_size to accommodate larger joins in one pass. Note! This script will still suggest raising the join_buffer_size when ANY joins not using indexes are found. OPEN FILES LIMIT Current open_files_limit = 2558 files The open_files_limit should typically be set to at least 2x-3x that of table_cache if you have heavy MyISAM usage. Your open_files_limit value seems to be fine TABLE CACHE Current table_cache value = 1024 tables You have a total of 163 tables You have 559 open tables. The table_cache value seems to be fine TEMP TABLES Current max_heap_table_size = 16 M Current tmp_table_size = 32 M Of 1464 temp tables, 17% were created on disk Effective in-memory tmp_table_size is limited to max_heap_table_size. Created disk tmp tables ratio seems fine TABLE SCANS Current read_buffer_size = 4 M Current table scan ratio = 2701 : 1 read_buffer_size seems to be fine TABLE LOCKING Current Lock Wait ratio = 1 : 14 You may benefit from selective use of InnoDB. Mysql \s when i got ips driver error: Threads: 44 Questions: 2065042 Slow queries: 4298 Opens: 1056 Flush tables: 1 Open tables: 851 Queries per second avg: 30.721
rct2·com Posted November 11, 2009 Posted November 11, 2009 When I asked why YOU thought it was slow, I meant what you thought the cause (server load very high, no spare memory, no spare page memory, etc) might be, rather than the effect!(it takes 10 seconds for a page to appear) :) Surprised you cannot answer the questions about server load, memory occupancy and paging to disk when you run a dedicated server. Is it being managed for you, or are you expected to manage it yourself. Next time it goes really slow, run top and give us the lines above the mysqld line. Do you have the 'debug level' set to 1 so you can see server load, page generation time on the bottom right of your forum page? What are these values when it goes really slowly? Finally, it's dedicated server, but are there any other scripts/sites running at the same time when your board goes slowly? If so, have you eliminated them from your investigations so far?
ASTRAPI Posted November 11, 2009 Author Posted November 11, 2009 I don't know. I am trying myself to handle it as my budget is low. No other sites pages only a IPS Shoutbox (10 seconds refresh rate) and Top 10 Ajax (30 seconds refresh rate).When I asked why YOU thought it was slow, I meant what you thought the cause (server load very high, no spare memory, no spare page memory, etc) might be, rather than the effect!(it takes 10 seconds for a page to appear)Surprised you cannot answer the questions about server load, memory occupancy and paging to disk when you run a dedicated server. Is it being managed for you, or are you expected to manage it yourself.Next time it goes really slow, run top and give us the lines above the mysqld line.2280 mysql 21 6 126m 72m 3704 S 149.3 2.2 121:12.99 mysqld 1621 root 0 -20 0 0 0 R 11.4 0.0 1:47.02 loop0 20315 nobody 20 4 32024 15m 2876 S 2.3 0.5 0:01.69 httpd 20933 nobody 19 4 30136 14m 2844 S 2.3 0.4 0:00.45 httpd 20987 nobody 20 4 32692 16m 2848 S 2.3 0.5 0:00.51 httpd 20923 nobody 20 4 29076 13m 2840 S 2.0 0.4 0:00.56 httpd 21378 nobody 20 4 31520 15m 2772 S 2.0 0.5 0:00.11 httpd 20968 nobody 19 4 25044 9.8m 2844 S 1.6 0.3 0:00.38 httpd 20997 root 15 0 0 0 0 S 1.6 0.0 0:02.50 pdflush 21392 nobody 19 4 30020 14m 2708 S 1.6 0.4 0:00.05 httpd 384 root 10 -5 0 0 0 S 1.3 0.0 0:09.99 kjournald 21190 nobody 19 4 28300 12m 2844 S 1.3 0.4 0:00.22 httpd 21398 nobody 27 4 28648 12m 2716 S 1.3 0.4 0:00.04 httpd 21401 nobody 29 4 28648 12m 2740 S 1.3 0.4 0:00.04 httpd 19875 nobody 20 4 28336 12m 2844 S 1.0 0.4 0:01.43 httpd 20945 nobody 19 4 28252 12m 2796 S 1.0 0.4 0:00.32 httpd 20964 nobody 19 4 29884 14m 2848 S 1.0 0.4 0:00.90 httpd 20974 nobody 19 4 28252 12m 2836 S 1.0 0.4 0:00.52 httpd 21359 nobody 19 4 29288 13m 2828 S 1.0 0.4 0:00.13 httpd 21402 nobody 29 4 27896 12m 2708 S 1.0 0.4 0:00.03 httpd 21404 nobody 29 4 27892 11m 2712 R 1.0 0.4 0:00.03 httpd 1622 root 12 -5 0 0 0 S 0.7 0.0 0:08.14 kjournald 21189 nobody 19 4 30792 15m 2836 S 0.7 0.5 0:00.28 httpd 21376 nobody 19 4 24456 9372 2760 S 0.7 0.3 0:00.07 httpd 2670 root 29 4 23652 9272 3836 S 0.3 0.3 0:01.68 httpd 20242 nobody 20 4 29308 13m 2848 S 0.3 0.4 0:00.98 httpd 20299 nobody 19 4 29432 14m 3172 S 0.3 0.4 0:00.95 httpd 20873 nobody 19 4 29364 13m 2844 S 0.3 0.4 0:00.67 httpd 20887 nobody 20 4 32972 16m 2796 S 0.3 0.5 0:00.54 httpd 20941 nobody 19 4 30680 15m 2844 S 0.3 0.5 0:00.76 httpd 20952 nobody 19 4 29356 14m 3284 S 0.3 0.4 0:00.42 httpd 20953 nobody 19 4 29248 13m 2796 S 0.3 0.4 0:00.36 httpd 20982 nobody 19 4 30108 14m 2844 S 0.3 0.4 0:00.56 httpd 21184 nobody 19 4 24404 9404 2836 S 0.3 0.3 0:00.13 httpd 21185 nobody 19 4 26132 10m 2844 S 0.3 0.3 0:00.36 httpd 21381 nobody 20 4 29160 13m 2732 S 0.3 0.4 0:00.05 httpd 21384 root 15 0 2328 1096 796 R 0.3 0.0 0:00.01 top 1 root 15 0 2064 664 572 S 0.0 0.0 0:00.59 init 2 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/0 3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0 4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0 5 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/1 6 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1 7 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/1 8 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0 9 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/1 10 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khelper 11 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread 15 root 10 -5 0 0 0 S 0.0 0.0 0:00.12 kblockd/0 16 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kblockd/1 17 root 14 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid 88 root 14 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0 89 root 14 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/1Finally, it's dedicated server, but are there any other scripts/sites running at the same time when your board goes slowly?
rct2·com Posted November 11, 2009 Posted November 11, 2009 Lines above mysqld on a CentOS system are like this: Try and capture that when the server is slow, it will help us to help you. It gives us an idea whether the server is CPU bound or memeory bound or I/O bound. It would also be useful to do the same output when the server is really fast.6:18pm up 93 days, 13:11, 1 user, load average: 0.91, 0.87, 1.07 149 processes: 148 sleeping, 1 running, 0 zombie, 0 stopped CPU states: 14.3% user, 1.9% system, 0.0% nice, 83.7% idle Mem: 2075064K av, 1961744K used, 113320K free, 0K shrd, 187704K buff Swap: 2040244K av, 7656K used, 2032588K free 1244712K cached
ASTRAPI Posted November 11, 2009 Author Posted November 11, 2009 When it takes 7 seconds for my index and 15 for any topic i got this from top: Try and capture that when the server is slow, it will help us to help you. It gives us an idea whether the server is CPU bound or memeory bound or I/O bound. It would also be useful to do the same output when the server is really fast.top - 20:26:37 up 23:26, 1 user, load average: 9.29, 11.03, 11.42 Tasks: 108 total, 5 running, 99 sleeping, 0 stopped, 4 zombie Cpu(s): 4.9%us, 18.6%sy, 22.0%ni, 38.8%id, 15.2%wa, 0.0%hi, 0.4%si, 0.0%st Mem: 3368496k total, 1879356k used, 1489140k free, 295264k buffers Swap: 2096472k total, 75024k used, 2021448k free, 1229356k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2093 mysql 21 6 391m 150m 3948 S 87.1 4.6 794:26.12 mysqld 28909 admunde 20 4 45944 17m 9808 S 15.8 0.5 0:00.08 php 28895 admunde 20 4 46192 18m 9468 S 13.9 0.6 0:00.12 php 28908 admunde 20 4 0 0 0 Z 13.9 0.0 0:00.07 php <defunct> 28904 admunde 20 4 45944 18m 9828 S 11.9 0.5 0:00.09 php 28906 admunde 23 4 41932 12m 7496 R 7.9 0.4 0:00.04 php 28278 nobody 21 4 287m 10m 2020 S 5.9 0.3 0:00.91 httpd 24115 nobody 21 4 288m 10m 2276 S 2.0 0.3 0:07.50 httpd 28736 nobody 21 4 285m 7556 2016 S 2.0 0.2 0:00.14 httpd Another one when things are worst: top - 21:11:03 up 1 day, 11 min, 1 user, load average: 29.45, 34.41, 25.35 Tasks: 203 total, 1 running, 202 sleeping, 0 stopped, 0 zombie Cpu(s): 4.8%us, 18.8%sy, 22.3%ni, 37.8%id, 15.8%wa, 0.0%hi, 0.5%si, 0.0%st Mem: 3368496k total, 2317904k used, 1050592k free, 64468k buffers Swap: 2096472k total, 74948k used, 2021524k free, 1092252k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2093 mysql 21 6 384m 147m 3948 S 102.4 4.5 823:00.08 mysqld 1506 root 0 -20 0 0 0 D 9.9 0.0 55:19.75 loop0 16458 admunde 21 4 41932 9960 5384 D 5.9 0.3 0:00.03 php [quote name='rct2·com' date='11 November 2009 - 06:21 PM' timestamp='1257963696' post='1878245'] Lines above mysqld on a CentOS system are like this: 6:18pm up 93 days, 13:11, 1 user, load average: 0.91, 0.87, 1.07 149 processes: 148 sleeping, 1 running, 0 zombie, 0 stopped CPU states: 14.3% user, 1.9% system, 0.0% nice, 83.7% idle Mem: 2075064K av, 1961744K used, 113320K free, 0K shrd, 187704K buff Swap: 2040244K av, 7656K used, 2032588K free 1244712K cached
Rhett Posted November 11, 2009 Posted November 11, 2009 you have some major config issues, I suggest you let someone with server management experience take over. If you want to tackle this yourself you need to do some research on tweaking apache and mysql to start with.
rct2·com Posted November 11, 2009 Posted November 11, 2009 You may find this link interesting to understand what the lines at top of 'top' mean. http://www.kernelhardware.org/linux-top-command/ What that tells me is that the CPU is hardly being used so no processing going on. (Cpu(s): 4.8%us) But the things that are waiting for processing time is enormous (load average: 29.45, 34.41, 25.35) There is an awful lot of memory (around 1GB) of memory that isn't being used at all. (Mem: 3368496k total, 2317904k used, 1050592k free) The memory swap area on disk is hardly used, not surprising as there is so much unused memory ;) (Swap: 2096472k total, 74948k used, 2021524k free) Of things that are using the CPU it is nearly all mySQL ( PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2093 mysql 21 6 384m 147m 3948 S 102.4 4.5 823:00.08 mysqld) Everything points at a hugely sub-optimal MySQL configuration. It is probably not using memory as effectively as it should, and spending a large amount of time waiting for data from to/from disk. You should keep running MySQLtuner and implement its recommendations on a regular basis. It may also be worth getting the hard disk tested. Perhaps it is very slow or has bad sectors. As others have side here a server with the spec you have shoul easily handle the number of users you have. By the way who is user 'admunde' in the top output, and what php script are they running? When top is running, hit the character 'C' and you will get more info where it says 'php'.
ASTRAPI Posted November 11, 2009 Author Posted November 11, 2009 admunde is my username on cpanel. I got unknown command...When top is running, hit the character 'C' and you will get more info where it says 'php'.
nes718 Posted November 20, 2009 Posted November 20, 2009 Make sure you're allowing persistent connection to the the MySQL server from PHP in php.ini: Otherwise, every single request spawns and new thread and you'll quickly run out of concurrent users. This would be a reason why you're getting connection errors. Once users are exausted, MySQL will wait until a thread is available or simply drop the request if it surpasses the timeout limit. [MySQL] ; Allow or prevent persistent links. mysql.allow_persistent = On
Bono Posted November 22, 2009 Posted November 22, 2009 Like somebody said You should hire professional, you have misconfigured Apache and Mysql. Apache spawns too many processes and Mysql is not caching properly. WTF is that your cache limit is higher than your query size? 30 QPS is really low, ATOM 270 can handle that with ease and with 20% load. With similar xeon i had 120 QPS and I never had database error. And you do not need to use mysql persistent links, I do not use it and my avg. connection is 10 max 47. With similar setup (Xeon 3060 and 2GB of ram) I had more than 700 people online with 10 other sites and load avg. was in range of 0.5-1.5. Please post output of this commands: free -m when site is under heavy load vmstat 3 and iostat Thanks
mast0rx Posted November 24, 2009 Posted November 24, 2009 You should use nginx or litespeed (VERY GOOD website, but it costs money) or lighttpd as Webservers. This 3 webservers use much lower ressources, so you have more power. Also the configuration of lighttpd is very easy, there is no mpm configuration like at apache. http://maisonbisson.com/blog/post/12249/chris-lea-on-nginx-and-wordpress/ “Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache.” –Chris Lea.
Luke Posted November 27, 2009 Posted November 27, 2009 Alright... First I would check the memory allotment for MySQL. You may need to increase the available memory for MySQL. Given the top you gave (although `top -c` I find is more helpful), I only see MySQL at the top. This, however, does not mean that MySQL is to blame because most of the processes you have running are Apache processes. What I would highly recommend doing is switching from mod_php to FastCGI (specifically mod_fcgid). The difference between mod_php, and fcgi is this:mod_php: Loads PHP as an Apache DSO (apache module) which means that for every HTTP request to your server, PHP and all of it's plugins is loaded into memory. If you have 500 users on the server every request loads PHP and it's plugins into memory that many times. And it's not just for .php requests either: This includes requests for .html, .jpg, .png (anything), etc... So for every page request multiply it by how many images you have. When the request is finished, the memory is recycled. However, the more users you have the more likely it is that your request pool is filled (Apache has a certain number of processes it can spawn, and once filled the request is "queued" until a slot is avaiable. This is how you start getting timeouts).fast cgi: It uses the cgi version of PHP. The difference between fcgi and mod_php, however, is that fcgi has it's own service and request pool separate from Apache. What this means for you is this: When Apache gets a request if it's anything but a .php file it handles the request and doesn't have to load anything else into memory (php and plugins are not loaded). If it is a .php request Apache hands the request off to the fcgi service to handle the request. The benefit in this is that fcgi only loads php and it's plugins into memory once, and non-php requests do not load php into memory. The draw back to this is you don't have as tight integration with Apache because PHP is external, but unless your doing HTTP authentication (Basic or Digest) in PHP, you shouldn't really notice much of a difference. (There is also cgi - essentially Apache loads PHP for every request externally. Very slow, much like mod_php in that it loads PHP for every request). Some other things to consider: - If you're using mod_php, which has been standard for a long time (fcgi is realitvely new), PHP is running as the user "nobody" (on Linux servers). What this means is if you upload files via FTP you're uploading them as the Linux user that was assigned to you by WHM/Cpanel. PHP cannot write to these files or directories unless they are chmoded to 0666 or 0777 (CHMOD is a common request among PHP apps like IPB). Likewise files written by PHP with the user nobody cannot be deleted via FTP unless the application CHMODs the files as 0666 or 0777 (these are usually user uploaded files). When a file is CHMODd as 0666 or 0777 it is writable by ANYONE on the server. So if you're on shared hosting another user could write to or delete that file. (Usually for this reason PHP has open_basedir enabled which prevents PHP from accessing files outside it's home directory). You *can* use SuPHP to make PHP use the same user, but I've heard bad things about it security wise (you don't want to get root hacked). - If you're using fcgi it takes advantage of Apache's SuEXEC which, like SuPHP, allows you to run PHP under each user's account. This means that you no longer have to CHMOD anything as PHP runs as the same user as your FTP. The issue is, however, that PHP can write to ANY file within your account, including source files. Some see this in itself as a security issue. The benefit, however, is that each user can only write to his/her files (unless they CHMOD'd them). For me personally I'd rather the user shoot their own feet rather than expose everyone elses content to risk (usually the uploaded files in PHP are more important than the source files, which are generally replaceable). - If you are using mod_php you usually can't take advantage of Apache's "MPM Worker" which takes advantage of multi-threading. There is some issue with PHP when loaded as a DSO module and multi-threading. To handle requests Apache opens up multiple processes to handle requests. If you use fcgi you are capable of using "MPM Worker", which has some benefits. I would recommend trying it out. Another thing to consider is a cache engine like eAccelerator. This tremedosly speeds up PHP requests. PHP is a scripting language and does not compile scripts. Each script is loaded from disk and converted into byte-code. What PHP cache engines do (generally) is convert PHP scripts into byte-code and cache it so that the next request doesn't have to do it (eliminates some steps). The result is the PHP scripts are loaded faster so they can be executed. There are some other engines out there (some better than others). If you have cPanel/WHM all this is extreemly easy to setup through EasyApache (literally checking boxes and telling it to compile). Another thing to consider is increasing how much RAM you have. 4GB is a nice amount, but you may consider increasing it. If you run out of physical memory, you're just going to start using SWAP, which will just shoot the server load up exponentially. If at all possible, the 64-bit version of CentOS 5 would help out as well. This would mean having to reformat the OS, however, so it may be a tad late to change that.
AnthonyKinson Posted December 1, 2009 Posted December 1, 2009 going back to your first post.... my.cnf.... max_connections=500 ... 500 active members = 500 connections to the database if they are all truly active, plus guests, bots and so on. the slow down could be MySQL waiting for a one of the connections to finish. if suddenly everyone starts hammering the refresh button because its running slow mysql will suddenly be pounded with connections causing it to lag even more.
ASTRAPI Posted January 5, 2010 Author Posted January 5, 2010 How can i fix this?the slow down could be MySQL waiting for a one of the connections to finish
Recommended Posts
Archived
This topic is now archived and is closed to further replies.