logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Need some help advice [Stress testing & Performance] Apa Page 1, 2  Next
Author
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Thu 09 Aug '07 21:27    Post subject: Need some help advice [Stress testing & Performance] Apa Reply with quote

Hi all,

My setup is as follows...

Software:

Windows XP SP2 Fully updated, fully optimized with all useless services turned off.
Apache: 2.0.59
mySQL: 5.0.45
PHP: 5.2.3

Hardware:

CPU 3.2ghz P4 (Northwood)
RAM: 2GB PC3200 DDR
HDD: Seagate Barracuda 7200rpm SATA2

Issue:

Im running a image gallery on this server, and when i get around 2-5 users browsing images apache starts running sluggish.

I've tried to use newer versions of apache without any luck (actually it got worse)

I'm a newbie when it comes to caching and i think thats where my solution might be lie, as i've heard that apache is bad on hosting images raw without any caching.

On PHP side ive installed eAcellerator and it does its job well (loadtime reduced)

What i need some advice with is how i could do performance tests using the "AB" binary which is included in the apache package. Ive done some tests and the results seem frightening, but i have nothing to compare with so i don't know if they are bad or just average.

This is what i tested:

ab -kc 10 -t 30 http://localhost/

Code:
Benchmarking localhost (be patient)
Finished 811 requests


Server Software:        Apache
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        12356 bytes

Concurrency Level:      10
Time taken for tests:   30.62500 seconds
Complete requests:      811
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      10594175 bytes
HTML transferred:       10028211 bytes
Requests per second:    26.98 [#/sec] (mean)
Time per request:       370.684 [ms] (mean)
Time per request:       37.068 [ms] (mean, across all concurrent requests)
Transfer rate:          344.12 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.9      0      31
Processing:    62  351 307.6    265    4000
Waiting:       62  334 302.6    250    4000
Total:         62  352 307.6    265    4000

Percentage of the requests served within a certain time (ms)
  50%    265
  66%    328
  75%    421
  80%    484
  90%    703
  95%   1000
  98%   1281
  99%   1390
 100%   4000 (longest request)


4000ms sounds like alot to me, but then again i don't know if this would be common using the command i did use.

However im pretty sure the issue lies within apache configuration. I've played around with Keepalives , threadsperchild, maxrequestsperchild etc and i've noticed changes in the behaviour of apache but i still end up getting the same load issue with apache almost completely stop serving new requests when some people are browsing. It can take up to 10-15 seconds before apache start serving a new request.

I did some tweaking with Keepalivetimeout and it became better when i reduced it to 8 from 15, but if i reduce it to 3 as many webpages recommend most requests get timeout before apache gets time to even start to serve them.

One more thing i might need to add is that it is not a network problem. Once i get load problems ive tested to browse the image gallery through localhost, and i get the exact same results as i get browsing it through lan or internet.

Im open for all suggestions, even testing other webservers if nessesary (lighthttpd?!).

Thanks in advance.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Thu 09 Aug '07 22:02    Post subject: Reply with quote

Just done the test on apachelounge.com. The page at localhost is a index.html.

Quite different figures then you, I noticed I have Keep-Alive requests: 30713 and you 0


Software;

Windows XP SP2 Fully updated, fully optimized with all useless services turned off.
Apache: 2.2.4 (from Apachelounge)
mySQL: 5.0.46
PHP: 5.2.3

On the same box running Mail server, Sambar server, BIND and see www.apachelounge.com/siteinfo.html


Hardware:

CPU 2.8ghz P4 (Northwood)
RAM: 2GB PC3200 DDR
HDD: 2X Seagate ST340014A (40 GB, 7200 RPM, Ultra-ATA/100)


ab -kc 10 -t 30 http://localhost/
Code:

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Finished 31015 requests


Server Software:        Apache
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        6910 bytes

Concurrency Level:      10
Time taken for tests:   30.000 seconds
Complete requests:      31015
Failed requests:        0
Write errors:           0
Keep-Alive requests:    30713
Total transferred:      223426327 bytes
HTML transferred:       214313650 bytes
Requests per second:    1033.83 [#/sec] (mean)
Time per request:       9.673 [ms] (mean)
Time per request:       0.967 [ms] (mean, across all concurrent reque
Transfer rate:          7272.97 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0      15
Processing:     0    9  11.3     15     171
Waiting:        0    8  11.1      0     140
Total:          0    9  11.3     15     171

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     15
  75%     15
  80%     15
  90%     15
  95%     31
  98%     31
  99%     46
 100%    171 (longest request)
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Thu 09 Aug '07 22:22    Post subject: Reply with quote

Hi Steffen,

That's impressive statistics compared to mine, and you're running tons of stuff on it also! Maybe i've finally located my issue.

Would you be so kind to share some of your settings in httpd.conf?

Timeout
Keepalive (on obviously?)
MaxKeepAliveRequests
KeepAliveTimeout
ThreadsPerChild
MaxRequestPerChild

Also any other setting you feel might be nessesary?

I'll try the apachelounge apache2.2.4 build tomorrow again, to see if i maybe did something wrong with it the first time i tested (i felt that i got degraded performance with it)

Thanks for the quick reply!
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Fri 10 Aug '07 10:00    Post subject: Reply with quote

Hi again,

Ive tested some things now and the issue lies with PHP somewhere.

When PHP is disabled i get these statistics:

Code:
Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Finished 33101 requests


Server Software:        Apache/2.2.4
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        40834 bytes

Concurrency Level:      10
Time taken for tests:   30.000 seconds
Complete requests:      33101
Failed requests:        0
Write errors:           0
Keep-Alive requests:    32779
Total transferred:      1361140254 bytes
HTML transferred:       1351654139 bytes
Requests per second:    1103.37 [#/sec] (mean)
Time per request:       9.063 [ms] (mean)
Time per request:       0.906 [ms] (mean, across all concurrent requests)
Transfer rate:          44307.93 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0      15
Processing:     0    8  27.4      0     718
Waiting:        0    7  26.7      0     718
Total:          0    8  27.4      0     718

Percentage of the requests served within a certain time (ms)
  50%      0
  66%     15
  75%     15
  80%     15
  90%     15
  95%     31
  98%     46
  99%     93
 100%    718 (longest request)


But when PHP is enable i get the same result as my first post.

I enable PHP using these lines in httpd.conf:

Code:

LoadModule php5_module "c:/Program Files/php/php5apache2_2.dll"
PHPIniDir "C:/windows"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


I've also tested f_cgi (fastcgi) and the performance gain is slim, about 28 requests per second with it. But its still far from close to being anywhere near the optimal solution Sad

Everything works great with PHP only problem is that apache only serves about 25 requests per second at PEAK and it runs REALLY sluggish.

It somewhat seems that when i enable PHP the use of "KeepAlives" gets disabeled, even though i have the string "KeepAlive On" in my httpd.conf.

When i look in the Taskmanger while doing this test having PHP enable, i get around 70% of the cpu going to httpd.exe while the rest goes to mysql-nt.exe , can this issue be directly related to sql maybe?

Thanks in advance

EDIT:

Its not the fact that apache is PHP enable that causes this, its only when apache communicate with PHP. When i benchmark a location where PHP is not enabled on my server i get the same results as php being turned off.

However it seems that all PHP related things are having the same effect on the server, no matter if its a complex php script causing lots of sql queries or its a simple one.. they all generate the same issue...
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Fri 10 Aug '07 21:48    Post subject: Reply with quote

Running a virus scanner which is scanning .php files ?
Not used php modules commented out ?
When you run as fastCGI is the httpd.exe also consuming 70% CPU or it is then going to php_cgi ?

I have:

Keepalive on
MaxKeepAliveRequests 100
KeepAliveTimeout 20
ThreadsPerChild 250
MaxRequestPerChild 0

25 requests per second is not bad at all. You can run with this a very busy site. compare it with www.apachelounge.com/stats/apache-taccesses-week.png , it's far lower then 25/sec, so I have plenty of room to grow.

Steffen
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Fri 10 Aug '07 22:04    Post subject: Reply with quote

Steffen wrote:
Running a virus scanner which is scanning .php files ?
Not used php modules commented out ?


No and yes.

Quote:
When you run as fastCGI is the httpd.exe also consuming 70% CPU or it is then going to php_cgi ?


all cpu goes to php-cgi.exe (alot of them maybe 6-10 of them, cpu is spread out between them)

Quote:

I have:

Keepalive on
MaxKeepAliveRequests 100
KeepAliveTimeout 20
ThreadsPerChild 250
MaxRequestPerChild 0


Does no difference for me.

Quote:

25 requests per second is not bad at all. You can run with this a very busy site. compare it with www.apachelounge.com/stats/apache-taccesses-week.png , it's far lower then 25/sec, so I have plenty of room to grow.


Im suspecting it might not be apache anyway, but as i see it, coppermine gallery which i use is used by ALOT of people, maybe its the winnt_MPM that cannot handle it, cause i've not heard anything like this on the coppermine forum, and the devs there doesn't know what it might be, they suspect apache.

Im stuck in a loop here, ive been engaging this problem for over 1 month now and i've not gotten anywhere close to fixing it. Maybe it's "Unfixable" Sad

The things that REALLY improved performance for me was to install eacellerator, it gave me a little bit more then 2x performance, which was awesome. I'm thinking to look for other caching solutions, any recommendations?

Also i must ask, the page you benchmark, is it using PHP? Cause if i benchmark any location where there is a .php file loading, i get Keep-Alive Requests 0 , but when i benchmark a location where there's no PHP , then i get Keep-Alive usage... This i find highly odd, but maybe it is the same for others?

Thanks for the help!
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Sun 12 Aug '07 17:54    Post subject: Reply with quote

ive configured steffens build of 2.2.4 using fcgi now and ive noticed a heavy improvement when changeing some of the fcgi settings.. now i actually get some load on my cpu, mysql is up to 40-60% cpu usage and page is running lots smoother, can handle alot more now..

Im pretty happy with as it is now, but id though id ask you experts if theres anything i could improve in mysql to make it run even better?

below is taken from info script that steffen made

Code:

   Aborted_clients = 2   
    Aborted_connects = 0   
    Binlog_cache_disk_use = 0   
    Binlog_cache_use = 0   
    Bytes_received = 81651550   
    Bytes_sent = 478395074   
    Com_admin_commands = 0   
    Com_alter_db = 0   
    Com_alter_table = 0   
    Com_analyze = 0   
    Com_backup_table = 0   
    Com_begin = 0   
    Com_call_procedure = 0   
    Com_change_db = 20040   
    Com_change_master = 0   
    Com_check = 0   
    Com_checksum = 0   
    Com_commit = 0   
    Com_create_db = 0   
    Com_create_function = 0   
    Com_create_index = 0   
    Com_create_table = 0   
    Com_create_user = 0   
    Com_dealloc_sql = 0   
    Com_delete = 39245   
    Com_delete_multi = 0   
    Com_do = 0   
    Com_drop_db = 0   
    Com_drop_function = 0   
    Com_drop_index = 0   
    Com_drop_table = 0   
    Com_drop_user = 0   
    Com_execute_sql = 0   
    Com_flush = 0   
    Com_grant = 0   
    Com_ha_close = 0   
    Com_ha_open = 0   
    Com_ha_read = 0   
    Com_help = 0   
    Com_insert = 10356   
    Com_insert_select = 0   
    Com_kill = 0   
    Com_load = 0   
    Com_load_master_data = 0   
    Com_load_master_table = 0   
    Com_lock_tables = 0   
    Com_optimize = 0   
    Com_preload_keys = 0   
    Com_prepare_sql = 0   
    Com_purge = 0   
    Com_purge_before_date = 0   
    Com_rename_table = 0   
    Com_repair = 0   
    Com_replace = 0   
    Com_replace_select = 0   
    Com_reset = 0   
    Com_restore_table = 0   
    Com_revoke = 0   
    Com_revoke_all = 0   
    Com_rollback = 0   
    Com_savepoint = 0   
    Com_select = 65810   
    Com_set_option = 0   
    Com_show_binlog_events = 0   
    Com_show_binlogs = 0   
    Com_show_charsets = 0   
    Com_show_collations = 0   
    Com_show_column_types = 0   
    Com_show_create_db = 0   
    Com_show_create_table = 0   
    Com_show_databases = 0   
    Com_show_errors = 0   
    Com_show_fields = 0   
    Com_show_grants = 0   
    Com_show_innodb_status = 0   
    Com_show_keys = 0   
    Com_show_logs = 0   
    Com_show_master_status = 0   
    Com_show_ndb_status = 0   
    Com_show_new_master = 0   
    Com_show_open_tables = 0   
    Com_show_privileges = 0   
    Com_show_processlist = 0   
    Com_show_slave_hosts = 0   
    Com_show_slave_status = 0   
    Com_show_status = 7   
    Com_show_storage_engines = 0   
    Com_show_tables = 617   
    Com_show_triggers = 0   
    Com_show_variables = 4   
    Com_show_warnings = 0   
    Com_slave_start = 0   
    Com_slave_stop = 0   
    Com_stmt_close = 0   
    Com_stmt_execute = 0   
    Com_stmt_fetch = 0   
    Com_stmt_prepare = 0   
    Com_stmt_reset = 0   
    Com_stmt_send_long_data = 0   
    Com_truncate = 0   
    Com_unlock_tables = 0   
    Com_update = 24746   
    Com_update_multi = 0   
    Com_xa_commit = 0   
    Com_xa_end = 0   
    Com_xa_prepare = 0   
    Com_xa_recover = 0   
    Com_xa_rollback = 0   
    Com_xa_start = 0   
    Compression = OFF   
    Connections = 20048   
    Created_tmp_disk_tables = 9   
    Created_tmp_files = 1224   
    Created_tmp_tables = 946   
    Delayed_errors = 0   
    Delayed_insert_threads = 0   
    Delayed_writes = 0   
    Flush_commands = 1   
    Handler_commit = 0   
    Handler_delete = 10216   
    Handler_discover = 0   
    Handler_prepare = 0   


   

    Handler_read_first = 1764   
    Handler_read_key = 2404533   
    Handler_read_next = 82842792   
    Handler_read_prev = 850074   
    Handler_read_rnd = 7505340   
    Handler_read_rnd_next = 140885363   
    Handler_rollback = 0   
    Handler_savepoint = 0   
    Handler_savepoint_rollback = 0   
    Handler_update = 1390894   
    Handler_write = 21084   
    Innodb_buffer_pool_pages_data = 0   
    Innodb_buffer_pool_pages_dirty = 0   
    Innodb_buffer_pool_pages_flushed = 0   
    Innodb_buffer_pool_pages_free = 512   
    Innodb_buffer_pool_pages_latched = 0   
    Innodb_buffer_pool_pages_misc = 0   
    Innodb_buffer_pool_pages_total = 512   
    Innodb_buffer_pool_read_ahead_rnd = 0   
    Innodb_buffer_pool_read_ahead_seq = 0   
    Innodb_buffer_pool_read_requests = 0   
    Innodb_buffer_pool_reads = 0   
    Innodb_buffer_pool_wait_free = 0   
    Innodb_buffer_pool_write_requests = 0   
    Innodb_data_fsyncs = 0   
    Innodb_data_pending_fsyncs = 0   
    Innodb_data_pending_reads = 0   
    Innodb_data_pending_writes = 0   
    Innodb_data_read = 0   
    Innodb_data_reads = 1   
    Innodb_data_writes = 0   
    Innodb_data_written = 0   
    Innodb_dblwr_pages_written = 0   
    Innodb_dblwr_writes = 0   
    Innodb_log_waits = 0   
    Innodb_log_write_requests = 0   
    Innodb_log_writes = 0   
    Innodb_os_log_fsyncs = 0   
    Innodb_os_log_pending_fsyncs = 0   
    Innodb_os_log_pending_writes = 0   
    Innodb_os_log_written = 0   
    Innodb_page_size = 16384   
    Innodb_pages_created = 0   
    Innodb_pages_read = 0   
    Innodb_pages_written = 0   
    Innodb_row_lock_current_waits = 0   
    Innodb_row_lock_time = 0   
    Innodb_row_lock_time_avg = 0   
    Innodb_row_lock_time_max = 0   
    Innodb_row_lock_waits = 0   
    Innodb_rows_deleted = 0   
    Innodb_rows_inserted = 0   
    Innodb_rows_read = 0   
    Innodb_rows_updated = 0   
    Key_blocks_not_flushed = 0   
    Key_blocks_unused = 718588   
    Key_blocks_used = 1183   
    Key_read_requests = 9763041   
    Key_reads = 10687   
    Key_write_requests = 35376   
    Key_writes = 23709   
    Last_query_cost = 0.000000   
    Max_used_connections = 11   
    Not_flushed_delayed_rows = 0   
    Open_files = 24   
    Open_streams = 0   
    Open_tables = 12   
    Opened_tables = 235   
    Prepared_stmt_count = 0   
    Qcache_free_blocks = 4   
    Qcache_free_memory = 126885536   
    Qcache_hits = 531041   
    Qcache_inserts = 55181   
    Qcache_lowmem_prunes = 0   
    Qcache_not_cached = 11255   
    Qcache_queries_in_cache = 3716   
    Qcache_total_blocks = 7466   
    Questions = 711911   
    Rpl_status = NULL   
    Select_full_join = 0   
    Select_full_range_join = 0   
    Select_range = 2332   
    Select_range_check = 0   
    Select_scan = 3733   
    Slave_open_temp_tables = 0   
    Slave_retried_transactions = 0   
    Slave_running = OFF   
    Slow_launch_threads = 0   
    Slow_queries = 0   
    Sort_merge_passes = 610   
    Sort_range = 26262   
    Sort_rows = 7505465   
    Sort_scan = 441   
    Ssl_accept_renegotiates = 0   
    Ssl_accepts = 0   
    Ssl_callback_cache_hits = 0   
    Ssl_cipher =   
    Ssl_cipher_list =   
    Ssl_client_connects = 0   
    Ssl_connect_renegotiates = 0   
    Ssl_ctx_verify_depth = 0   
    Ssl_ctx_verify_mode = 0   
    Ssl_default_timeout = 0   
    Ssl_finished_accepts = 0   
    Ssl_finished_connects = 0   
    Ssl_session_cache_hits = 0   
    Ssl_session_cache_misses = 0   
    Ssl_session_cache_mode = NONE   
    Ssl_session_cache_overflows = 0   
    Ssl_session_cache_size = 0   
    Ssl_session_cache_timeouts = 0   
    Ssl_sessions_reused = 0   
    Ssl_used_session_cache_entries = 0   
    Ssl_verify_depth = 0   
    Ssl_verify_mode = 0   
    Ssl_version =   
    Table_locks_immediate = 133160   
    Table_locks_waited = 10558   
    Tc_log_max_pages_used = 0   
    Tc_log_page_size = 0   
    Tc_log_page_waits = 0   
    Threads_cached = 6   
    Threads_connected = 2   
    Threads_created = 42   
    Threads_running = 1   
    Uptime = 21280   
    Uptime_since_flush_status = 21280


The FCGI settings i use is:

LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .php
DefaultInitEnv PHPRC "c:/progra~1/php/"
DefaultInitEnv SystemRoot "C:/Windows"
DefaultInitEnv SystemDrive "C:"
DefaultInitEnv TEMP "C:/WINDOWS/TEMP"
DefaultInitEnv TMP "C:/WINDOWS/TEMP"
DefaultInitEnv windir "C:/WINDOWS"
MaxRequestsPerProcess 500
IdleTimeout 30
BusyTimeout 600
MaxProcessCount 32
DefaultMaxClassProcessCount 2
IPCConnectTimeout 6
IPCCommTimeout 6

If i increase Classprocesscount ive noticed the higher load i get the higher respons time apache will have... for example at 95% load at processcount 2 i will have approx 90 ms respons time, while using 4 ill have four times that amount.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Sun 12 Aug '07 19:53    Post subject: Reply with quote

I see you set the Query cache in MySQL. It's not always helping, what happens when you switch it off.

Steffen
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Sun 12 Aug '07 21:19    Post subject: Reply with quote

To turn of query cache had a drastic effect on the benchmark. From 28 requests/second to 2 requests/second. It's clearly mySQL which is slowing apache down, but i don't know how to give mySQL more juice. I have given it tons of memory, around 1,2gb, maybe i'm not allocating it wisely?

I have the majority of memory dedicated to key_buffer_size.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Mon 13 Aug '07 4:34    Post subject: Reply with quote

I noticed that you used 20,048 Connections in 21,280 seconds of Uptime. That's about one new connection per second, which seems like a lot.

A few things you might check:
    * If Coppermine Gallery uses php_mysql, check your PHP.INI [MySQL] section and make sure that it has mysql.allow_persistent = On.
    If it uses php_mysqli, then persistent connections should always be used AFAIK.

    * Check in httpd.conf that your fcgid processes live long enough. The default for ProcessLifeTime is 3600 seconds (an hour).
    Make sure this isn't set to some small value.

    * If Coppermine Gallery uses php_mysql (not php_mysqli) and MySQL is on the same machine, try using named pipes instead of port 3306 for MySQL.
    Start MySQL with the --enable-named-pipe switch and make sure that mysql.default_host = localhost in PHP.INI.
    This is a long shot, but who knows - maybe your port 3306 connection is slow for some reason.

-tom-
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Mon 13 Aug '07 9:13    Post subject: Reply with quote

tdonovan wrote:
I noticed that you used 20,048 Connections in 21,280 seconds of Uptime. That's about one new connection per second, which seems like a lot.

A few things you might check:
    * If Coppermine Gallery uses php_mysql, check your PHP.INI [MySQL] section and make sure that it has mysql.allow_persistent = On.
    If it uses php_mysqli, then persistent connections should always be used AFAIK.

    * Check in httpd.conf that your fcgid processes live long enough. The default for ProcessLifeTime is 3600 seconds (an hour).
    Make sure this isn't set to some small value.

    * If Coppermine Gallery uses php_mysql (not php_mysqli) and MySQL is on the same machine, try using named pipes instead of port 3306 for MySQL.
    Start MySQL with the --enable-named-pipe switch and make sure that mysql.default_host = localhost in PHP.INI.
    This is a long shot, but who knows - maybe your port 3306 connection is slow for some reason.

-tom-


Thanks alot for the tips, i'll post feedback once i've tried them!
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Mon 13 Aug '07 13:35    Post subject: Reply with quote

For some strange reason i cannot get named pipes to work. I've read some FAQ on mySQL and it says named piping only works with windows 2000 and higher.. im using XP so it should work (??)

Anyhow, i've configured this way:

In MY.INI
Code:
[mysqld]
port      = 3306
enable-named-pipe
socket      = localhost
skip-networking


in php.ini
Code:

mysql.default_socket = localhost
mysql.default_host = localhost


and my coppermine gallery is pointed to connect to "localhost" , im still not getting any connections, it seems the database isn't allowing any connections at all.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Mon 13 Aug '07 16:06    Post subject: Reply with quote

Once I had it working. When I recall you have to use in Wondows "." as host in your php application.

Form the manual:

On Windows, the hostname . causes the client to connect to the local server using a named pipe



Steffen
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Mon 13 Aug '07 20:23    Post subject: Reply with quote

It's only default_host you need to change for named-pipe in PHP.INI, not default_socket in PHP.INI or socket in MY.INI.

Try executing the MySQL server from the command-line with --enable-named-pipe --console to see if it is capable of named-pipe.
The MySQL Enterprise version is usually built without named-pipe support, but the Community version usually has it.
If it says unknown option '--enable-named-pipe' your server doesn't have it.

named-pipe works OK for me on w2k with Apache-2.2.4/PHP-5.2.2/MySQL 5.0.46 and default_socket = localhost in my PHP.INI.
If you get it working, request mysql_info.php and look for named_pipe = ON.

I wouldn't struggle with named-pipe too much - I find it makes a very small difference.

More important, have you figured out why you are creating so many connections?
Since you only used a max of 11 simultaneously (Max_used_connections), it doesn't seem reasonable that you created 20,000+ new connections in 6 hours of runtime.

-tom-

EDIT: Maybe Coppermine Gallery uses php_mysqli instead of php_mysql.
php_mysqli doesn't use persistent connections, so that would explain why you create so many new MySQL connections.
If this is the case, I expect there isn't much you can do about the number of connections - it's probably best to move on to tuning something else in MySQL.
-t-
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Mon 13 Aug '07 22:16    Post subject: Reply with quote

Quote:
EDIT: Maybe Coppermine Gallery uses php_mysqli instead of php_mysql.
php_mysqli doesn't use persistent connections, so that would explain why you create so many new MySQL connections.
If this is the case, I expect there isn't much you can do about the number of connections - it's probably best to move on to tuning something else in MySQL.


Hmm, my knowledge of sql/php/apache is very limited, can you please guide me how to tell what kind of sql coppermine use?

I've managed to enable named.pipe "named_pipe = ON" but i still cant get it to work...

Shouldn't i name the "socket" for my pipe somewhere in my.ini? I mean when i boot mysql with skip-networking and --consol i get this:
Code:

Version: '5.0.45-community-nt-log' socket '' port 0 MySQL Community Edition (GPL)


Shouldn't socket '' be the name where sql accepting connections? It looks to me as it's being "unnamed" so i must miss some configuration in MY.ini?

Thank you guys for your continuous help.

EDIT: Something is clearly very wrong in my MySQL configuration, it seems that even though im using MYSQLD-NT.EXE when i disable networking for [mysqld] and not [mysqld-nt] i still cant connect.... Why is my configuration for a binary im not using giving me a effect? I'm highly confused now, would anyone take a look at my my.ini if i posted it?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Wed 15 Aug '07 14:32    Post subject: MySQL named pipes Reply with quote

re: [mysqld-nt] - if you mean the sections in my.ini - I don't think there is a [mysqld-nt] section, just a [mysqld] section, regardless of which executable you run.

The MySQL startup display always shows socket '' on Windows. It will not show the name of the pipe.

The host name when you want to use named pipes on Windows is "." (a single dot) per the MySQL client API doc.

To use named pipes you need to:
    1. set enable-named-pipe (and, if you want, skip-networking) in my.ini in the [mysqld] section.

    2. set socket to the same name in my.ini, in both the [client] and [mysqld] sections.

    3. set mysql.default_socket to the socket name in php.ini

    4. change the host name from localhost to . (a single dot) in Coppermine.
This may not buy you much performance. There are varying reports about whether named pipes are faster or slower than TCP on Windows.

You could try shared-memory instead of enable-named-pipe. This should not require any config changes to PHP or Coppermine to work if Coppermine uses host name "localhost".

-tom-
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Thu 16 Aug '07 19:24    Post subject: Reply with quote

Thank you for the help, however i still cannot configure this named pipe.

Documentation seems really bad for windows users.

I've done the exact thing you say, and when i do it i get a message from "CreateNamedPipe":

Code:
The filename, directory name, or volume label syntax is incorrect.


When i enable mysql through service "mmc.exe" in windows i get this error message from coppermine gallery:

Code:
Coppermine critical error:
Unable to connect to database !
MySQL said: Can't set state of named pipe to host: . pipe: . (87)


This occurs when i put a . (dot) on socket in [client] & [mysqld] like this:

Code:
[client]
password   = XXXXXXXXXXXX
port      = 3306
socket      = .

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port      = 3306
socket      = .
skip-locking
key_buffer = 800M
max_allowed_packet = 1M
more settings below....


I've tested to change "Port" to "0" aswell, no difference.

Google fails to find a solution.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 17 Aug '07 2:23    Post subject: Reply with quote

I think you misunderstood.

The host name (somewhere in Coppermine configuration) should be dot.
This change, from localhost to . (dot), won't be in either php.ini or my.ini - it will be in some Coppermine configuration file.

The socket name cannot be dot. Try something like "MySQLpipe" (without the quotes).
The socket name must be the same in all three places: two sections of my.ini and once in php.ini.
It is case sensitive, so make sure it is exactly the same in all three places.

-tom-
Back to top
dke



Joined: 13 Jul 2007
Posts: 61
Location: sweden

PostPosted: Fri 17 Aug '07 18:20    Post subject: Reply with quote

Thank you, its working properly now!

It was a slight improvement, but i still get really high respons times out of apache when getting around 30req/sec

I'm going to try windows 2003 server r2 just to see if there is a operating system issue, thanks for all your help!

EDIT:

Tested a server operative system, and i didn't get any increase or decrease in performance, so i guess its really a coppermine issue with the queries it sends the database. Thanks for the help fixing the pipe though, it really got better, about 5 more requests/sec!
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 23 Aug '07 20:40    Post subject: Coppermine performance test Reply with quote

Your posts made me curious, so I downloaded Coppermine Gallery version 1.4.12 and gave it a try with Apache 2.2.4 (from Apache Lounge), PHP 5.2.2 via mod_fcgid, and MySQL 5.0.46 on the same machine.

My Windows 2000 machine (3.4ghz 2gb pentium) is roughly similar to yours.

Using XDebug shows that most of the time is spent executing PHP code, so an optimizer like eAcelerator is definitely warranted. I used XCache which is similar to eAccelerator, and I got a similar performance increase. It increased my throughput from 10 to 30 pages/sec using Apache Bench (ab.exe) against /coppermine/index.php.

It appears that ab is not a very fair measurement tool for an application like Coppermine, where users select images from thumbnails and can vote on various images. There are two reasons:
    1. Using ab causes every request to start a new Coppermine user session because ab doesn't retain cookies.

    2. No real users would make a thumbnail selection or choose a picture rating in milliseconds.
Instead, I recorded a script using the old, free (but still very useful) Web Application Stress Tool. I recorded a script (incluing browser pauses) as I wandered through the app as fast as I could - selecting thumbnails in about 1/2 second and voting immediatialy on pictures. Faster than any real user would go - but still more realistic than hammering the app with ab. I also configured WAST to add a random 5-50ms pause to each request, so the test would simulate users going at slightly different speeds.

I found that I could support 100 such fast-acting users comfortably, with all response times below 1 sec. CPU use would occasionally get near 100%, but the whole machine (and Coppermine) stayed very responsive throughout the test.

FYI - here are two other tuning things I tried. They helped a little - but not really enough to bother with unless you want to squeeze every last bit of performance out of Coppermine:
    * Changed the MySQL storage engine for the session table (cpg1411_sessions) to an in-memory table and added an index to speed up the search for expired sessions:
    Quote:
    mysql> DELETE FROM cpg1411_sessions;
    mysql> ALTER TABLE cpg1411_sessions ENGINE MEMORY;
    mysql> ALTER TABLE cpg1411_sessions ADD INDEX (time);
    The disadvantage to this is that Coppermine user sessions won't be retained over a MySQL shutdown and restart.

    * Altered coppermine\include\functions.inc.php line 181 to call mysql_pconnect instead of mysql_connect. This makes Coppermine re-use persistent connections instead of creating a MySQL connection for each request. Probably helpful if your MySQL is on another machine, but it didn't do a lot for me. It did cut way down on the Connections shown in mysql_info.php.

Hope this stuff is useful (or if not useful - at least interesting) to you.

It's still a guess how many "real life" users I could support - but I would guess 200-300 unless all my users had the curious ability to make photographic decisions in fractions of a second Wink

-tom-
Back to top


Reply to topic   Topic: Need some help advice [Stress testing & Performance] Apa View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2  Next