Page 1 of 1

Serverauslastung

Posted: 2006-03-14 14:18
by justme3
Ok, mache aus dem Cluster Thread vielleicht erstmal 2....
vielleicht muss ich ja doch noch etwas anders konfigurieren, einstellen.


Also wenn ich TOP eingebe sehe ich folgendes:

Tasks: 189 total, 2 running, 187 sleeping, 0 stopped, 0 zombie
Cpu(s): 62.9% us, 32.3% sy, 0.0% ni, 4.7% id, 0.0% wa, 0.0% hi, 0.2% si
Mem: 4052016k total, 4027644k used, 24372k free, 1148k buffers
Swap: 1953784k total, 48k used, 1953736k free, 2999216k cached


32623 mysql 15 0 106m 55m 4600 S 99.9 1.4 2879:19 mysqld
15915 wwwrun 15 0 120m 15m 3836 S 3.3 0.4 0:00.77 httpd2-prefork 15021 wwwrun 16 0 120m 15m 4036 S 2.7 0.4 0:01.88 httpd2-prefork
16731 wwwrun 15 0 119m 14m 3812 S 2.7 0.4 0:00.10 httpd2-prefork 15921 wwwrun 15 0 119m 15m 3860 S 2.3 0.4 0:01.22 httpd2-prefork
16726 wwwrun 15 0 119m 15m 3824 S 2.3 0.4 0:00.15 httpd2-prefork 16727 wwwrun 16 0 120m 15m 3696 S 2.3 0.4 0:00.07 httpd2-prefork
14158 wwwrun 15 0 120m 15m 4020 S 2.0 0.4 0:02.60 httpd2-prefork 14986 wwwrun 16 0 120m 15m 4012 S 2.0 0.4 0:01.28 httpd2-prefork
15241 wwwrun 15 0 119m 15m 4008 S 2.0 0.4 0:01.01 httpd2-prefork 15656 wwwrun 16 0 120m 15m 3860 S 2.0 0.4 0:00.77 httpd2-prefork
16161 wwwrun 15 0 119m 15m 3840 S 2.0 0.4 0:00.40 httpd2-prefork 16714 wwwrun 16 0 119m 14m 3820 S 2.0 0.4 0:00.15 httpd2-prefork
16426 wwwrun 15 0 120m 15m 3852 S 1.7 0.4 0:00.39 httpd2-prefork 16708 wwwrun 15 0 120m 15m 3832 S 1.7 0.4 0:00.18 httpd2-prefork

Re: Serverauslastung

Posted: 2006-03-14 15:39
by lord_pinhead
Dein Datenbank Server rechnet sich da grad nen Ast, wenn da kein Fehler irgendwo ist hast du anscheinend 4 GB Ram, wieviel davon hast du für den mysql bereitgestellt und was hast du noch für Hardware? Oder hast du dein mysql gar nicht konfiguriert?

mysql

Posted: 2006-03-14 15:54
by justme3
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 512M
max_allowed_packet = 1M
table_cache = 1048
sort_buffer_size = 8M
net_buffer_length = 16K
read_buffer_size = 8M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 8M

ich hatte mysql auch mal 2 GB gegeben...allerdings braucht apache wegen
prefork etwas mehr. prefork brauche ich wegen dem dualcore opteron der sonst immer segmenration faults verursacht und die datenbamk tabellen schrottet (ist zumindest meine theorie).

Re: mysql

Posted: 2006-03-14 16:15
by isotopp
justme3 wrote:ich hatte mysql auch mal 2 GB gegeben...
Dem top-Output nach nutzt er schon die 512M nicht. Das bedeutet wahrscheinlich fehlende Indices.

Was sagt SHOW FULL PROCESSLISTG? Was sagt SHOW TABLE STATUSG auf die Datenbanken, die in der PROCESSLIST angezeigt werden? Was sagt SHOW STATUS?

MySQL Optimierung

Posted: 2006-03-14 20:10
by justme3
Danke!

Also ich hab mich heute nochmal hingeetzt und versucht etwas zu optimieren.

Im Moment bin ich bei 505.82 Queries/Sekunde. (Wieviel kann man
denn mit so einem Server theoretisch schaffen?)

Meine my.cnf sieht nun so aus:

key_buffer = 128M
max_allowed_packet = 1M
table_cache = 2048
sort_buffer_size = 32M
net_buffer_length = 16K
read_buffer_size = 8M
read_rnd_buffer_size = 32M
myisam_sort_buffer_size = 128M
tmp_table_size = 1024M

(ist schon wesentlich schneller geworden!)

Und bei PhpMyAdmin sind folgende Werte rot:

Handler_read_rnd 379 k
(angeblich wegen sorting/table scans)


Handler_read_rnd_next 99 M
(auch hier angeblich table scans/keine gescheiten keys)

Created_tmp_disk_tables 11
(If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size value to cause temporary tables to be memory-based instead of disk-based.)

Sort_merge_passes 256
(The number of merge passes the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable.)


Opened_tables 626
(if opened tables is big, your table cache value is probably too small.)


Table_locks_waited 3 k
(If this is high, and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.)


Okay, also zusammenfassend soll ich laut phpMyAdmin folgendes machen:

- keys anders machen -> wegen table scans :(
- tmp_table_size erhöhen damit die festplatte weniger verwendet wird
- sort_buffer_size erhöhen
- table_cache erhöhen
- tabellen splitten :(


Auf was soll ich denn bei SHOW TABLE STATUS achten?

SHOW PROCESS LIST zeigt z.B. folgendes Queries an:

select countrySHORT, countryLONG from ipcountry where ipFROM <= INET_ATON('$ip') and ipTO >= INET_ATON('$ip')


Eine der Queries war auch noch:

select a.uid
DATE_FORMAT(date_sub(a.lastactive, interval 1 hour),'%W, %r'), a.picture from
users as a, session as s where s.guest='0' and a.age>15
and a.country!='50' and a.country='70' and a.sexuality<6 and a.uname=s.username order by s.time desc limit 20

das mit dem country ist blödsinn, allerding wird die query zusammengebaut und kann nicht so leicht/einfach/schnell geändert werden.

Re: MySQL Optimierung

Posted: 2006-03-15 10:32
by isotopp
justme3 wrote:Im Moment bin ich bei 505.82 Queries/Sekunde. (Wieviel kann man denn mit so einem Server theoretisch schaffen?)
Die Frage ist nicht sehr sinnvoll. Aber um Dir in Deinen Termen zu antworten: Mit Vanilla-MySQL gegen einen gut cachebaren Datenbestand und mit Indexunterstützung kann man bis zu 5.000 queries pro Sekunde sehen. Wenn diese Queries gegen In-Memory Tables gehen (oder gegen Cluster, der ja auch In-Memory ist), dann können das auch mal 50.000 Queries pro Sekunde sein. Wenn Du auf der anderen Seite DWH-Queries machst, die sowieso auf Full Table Scans gegen Terabyte-Tabellen rauslaufen, dann kannst Du etwa 5 Milliqueries pro Sekunde erwarten.
Auf was soll ich denn bei SHOW TABLE STATUS achten?
Auf nix. Du solltest das, und den Output von SHOW STATUS und SHOW VARIABLES hier reinpasten. In code-Tags, bitte.
select countrySHORT, countryLONG from ipcountry where ipFROM <= INET_ATON('$ip') and ipTO >= INET_ATON('$ip')
Die übliche GeoIP-Tabelle. Wenn man countrylong in einen ENUM umwandelt ("select * from ipcountry procedure analyse()G" für den passenden ENUM-String), kann man danach "create table ipcountry_orig like ipcountry", "insert into ipcountry_orig select * from ipcountry", "alter table ipcountry engine=memory, add index using btree (ipfrom, ipto)" und dann init-file=/var/lib/mysql/mysqlstart.sql in die my.cnf und da dann ein "insert into databasename.ipcountry select * from databasename.ipcountry_orig".

Das kann schon mal was bringen, wenn Du viele Lookups gegen diese Tabelle hast.
select a.uid
DATE_FORMAT(date_sub(a.lastactive, interval 1 hour),'%W, %r'), a.picture from
users as a, session as s where s.guest='0' and a.age>15
and a.country!='50' and a.country='70' and a.sexuality<6 and a.uname=s.username order by s.time desc limit 20
Und EXPLAIN meint dazu?
Was ist SHOW CREATE TABLE usersG
Was ist SHOW CREATE TABLE sessionG

ipcountry

Posted: 2006-03-16 21:11
by justme3
danke!

geht alles bis auf den schritt, die tabelle nach memory zu ändern.

mysql> alter table ipcountry engine=memory
-> ;
ERROR 1114 (HY000): The table '#sql-836_94a11' is full
mysql>

Re: ipcountry

Posted: 2006-03-17 09:34
by isotopp
justme3 wrote:geht alles bis auf den schritt, die tabelle nach memory zu ändern.

mysql> alter table ipcountry engine=memory
-> ;
ERROR 1114 (HY000): The table '#sql-836_94a11' is full
mysql>
Dann hast Du noch VARCHAR(255) in Deiner Tabelle und kein ENUM. Das wird in MEMORY zu CHAR(255), und paßt dann nicht mehr in den Speicher. "SHOW CREATE TABLE ipcountry" mal hier im Forum.

ipcountry

Posted: 2006-03-19 12:52
by justme3
CREATE TABLE `ipcountry` (
`ipFROM` int(10) unsigned zerofill NOT NULL default '0000000000',
`ipTO` int(10) unsigned zerofill NOT NULL default '0000000000',
`countrySHORT` char(2) NOT NULL default '',
`countryLONG` varchar(255) NOT NULL default '',
PRIMARY KEY (`ipFROM`,`ipTO`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |


Aber wenn ich die column auf enum ändere ist doch alles weg, oder?

Oder soll ich erst ein char(255) draus machen? :?:

oder vielleicht kein memory?

Posted: 2006-03-19 12:58
by justme3
vielleicht hab ich ja auch nicht genug hauptspeicher übrig?

mysql> alter table ipcountry engine=memory, add index using btree (ipfrom, ipto);
ERROR 1114 (HY000): The table '#sql-469_5177' is full
mysql> alter table ipcountry engine=memory;
ERROR 1114 (HY000): The table '#sql-469_5177' is full
mysql>

procedure analyse()

Posted: 2006-03-19 13:21
by justme3
select Optional_fieldtype from
(SELECT countryLONG FROM `ip2countryOpt` procedure analyse());

schade dass diese abfrage nicht geht :-(