Hauptspeicher verwendet und Prozent stimmen nicht überein

547
KisnardOnline

Ich habe einen ec2-Server und manchmal habe ich Speicherprobleme - Ich habe den Mysql-Prozess wegen zu wenig Speicher beendet. Dies bricht meine Website und mein Spiel und manchmal dauert es Stunden oder Tage, bis ich es bemerkt habe :(. Im Moment habe ich Lampe, WordPress und meinen Java-MMorpg-Server auf dem Server. Ich weiß, dass mein MMORPG-Server ziemlich viel RAM benötigt, um alles zu speichern der Entitäten und Daten.

Ich habe 1 GB RAM und 1 GB Swap . Hier ist meine Top-Ausgabe derzeit.

Top-Ausgabe

Was ich nicht verstehe, ist warum, wenn mein Java-Prozess 7,6% beträgt und meine aktuelle mysqld 1,9% ist . Es heißt, 956 MB Mem verwendet und 378 MB Swap verwendet - diese Zahlen scheinen echt zu sein. Wie ist das sogar nahe bei 7,6 + 1,9%?

Gibt es eine Möglichkeit, meinen Speicher ein wenig besser zu überwachen, oder etwas, das ich unter mysql konfigurieren kann, damit OOM nicht ausgeführt wird? Ich bin mir ziemlich sicher, dass mein Java-Server-Code kein Leck aufweist - aber nicht zu 100% sicher.

Tut mir leid für alle Fragen - nachdem ich mein mmorpg seit über 5 Jahren von Grund auf neu programmiert habe, möchte ich sicherstellen, dass mein Server bereit ist, mit einer anständigen Spielerbasis umzugehen.

EDIT in Kommentaren angefordert

freie Ausgabe

 total used free shared buffers cached Mem: 1019336 937316 82020 344 8920 45120 -/+ buffers/cache: 883276 136060 Swap: 1048572 417708 630864 

ps aux ausgang

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 19644 0 ? Ss Aug14 0:00 /sbin/init root 2 0.0 0.0 0 0 ? S Aug14 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Aug14 0:08 [ksoftirqd/0] root 4 0.0 0.0 0 0 ? S Aug14 0:00 [kworker/0:0] root 5 0.0 0.0 0 0 ? S< Aug14 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S Aug14 1:51 [rcu_sched] root 8 0.0 0.0 0 0 ? S Aug14 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S Aug14 0:00 [migration/0] root 10 0.0 0.0 0 0 ? S Aug14 0:00 [kdevtmpfs] root 11 0.0 0.0 0 0 ? S< Aug14 0:00 [netns] root 12 0.0 0.0 0 0 ? S< Aug14 0:00 [perf] root 15 0.0 0.0 0 0 ? S Aug14 0:00 [xenwatch] root 20 0.0 0.0 0 0 ? S Aug14 0:00 [xenbus] root 21 0.0 0.0 0 0 ? S Aug14 0:19 [kworker/0:1] root 128 0.0 0.0 0 0 ? S Aug14 0:00 [khungtaskd] root 129 0.0 0.0 0 0 ? S< Aug14 0:00 [writeback] root 131 0.0 0.0 0 0 ? SN Aug14 0:00 [ksmd] root 132 0.0 0.0 0 0 ? SN Aug14 0:00 [khugepaged] root 133 0.0 0.0 0 0 ? S< Aug14 0:00 [crypto] root 134 0.0 0.0 0 0 ? S< Aug14 0:00 [kintegrityd] root 135 0.0 0.0 0 0 ? S< Aug14 0:00 [bioset] root 137 0.0 0.0 0 0 ? S< Aug14 0:00 [kblockd] root 488 0.0 0.0 0 0 ? S< Aug14 0:00 [md] root 616 0.0 0.0 0 0 ? S Aug14 0:46 [kswapd0] root 617 0.0 0.0 0 0 ? S< Aug14 0:00 [vmstat] root 689 0.0 0.0 0 0 ? S Aug14 0:00 [fsnotify_mark] root 708 0.0 0.0 0 0 ? S< Aug14 0:00 [kthrotld] root 748 0.0 0.0 0 0 ? S< Aug14 0:00 [bioset] root 752 0.0 0.0 0 0 ? S< Aug14 0:00 [deferwq] root 1374 0.0 0.0 0 0 ? S< Aug14 0:00 [ata_sff] root 1387 0.0 0.0 0 0 ? S Aug14 0:00 [scsi_eh_0] root 1396 0.0 0.0 0 0 ? S< Aug14 0:00 [scsi_tmf_0] root 1399 0.0 0.0 0 0 ? S Aug14 0:00 [scsi_eh_1] root 1412 0.0 0.0 0 0 ? S< Aug14 0:00 [scsi_tmf_1] root 1470 0.0 0.0 0 0 ? S Aug14 0:34 [jbd2/xvda1-8] root 1471 0.0 0.0 0 0 ? S< Aug14 0:00 [ext4-rsv-conver] root 1499 0.0 0.0 0 0 ? S< Aug14 0:00 [kworker/0:1H] root 1517 0.0 0.0 11424 28 ? Ss Aug14 0:00 /sbin/udevd -d root 1590 0.0 0.0 0 0 ? S< Aug14 0:00 [kpsmoused] root 1641 0.0 0.0 11312 32 ? S Aug14 0:00 /sbin/udevd -d root 1827 0.0 0.0 0 0 ? S Aug14 0:00 [kauditd] root 1882 0.0 0.0 0 0 ? S< Aug14 0:00 [ipv6_addrconf] root 2035 0.0 0.0 9360 628 ? Ss Aug14 0:00 /sbin/dhclient -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0 root 2087 0.0 0.0 46536 36 ? S<sl Aug14 0:00 auditd root 2108 0.0 0.0 247464 0 ? Sl Aug14 0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5 dbus 2137 0.0 0.0 21792 4 ? Ss Aug14 0:00 dbus-daemon --system root 2266 0.0 0.0 77840 780 ? Ss Aug14 0:00 /usr/sbin/sshd root 2327 0.0 0.0 115344 28 ? S Aug14 0:00 /bin/sh /usr/libexec/mysql55/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql mysql 2536 0.6 1.3 886436 13936 ? Sl Aug14 83:28 /usr/libexec/mysql55/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 2585 0.0 0.0 88992 552 ? Ss Aug14 0:18 sendmail: accepting connections smmsp 2594 0.0 0.0 80440 400 ? Ss Aug14 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue root 2605 0.0 0.1 431276 1284 ? Ss Aug14 0:23 /usr/sbin/httpd root 2616 0.0 0.0 119516 768 ? Ss Aug14 0:03 crond root 2630 0.0 0.0 17068 88 ? Ss Aug14 0:00 /usr/sbin/atd root 2653 0.0 0.0 4312 32 tty1 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty1 root 2655 0.0 0.0 6460 32 ttyS0 Ss+ Aug14 0:00 /sbin/agetty ttyS0 9600 vt100-nav root 2657 0.0 0.0 4312 32 tty2 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty2 root 2660 0.0 0.0 4312 32 tty3 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty3 root 2664 0.0 0.0 4312 32 tty4 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty4 root 2666 0.0 0.0 4312 32 tty5 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty5 root 2668 0.0 0.0 10876 32 ? S Aug14 0:00 /sbin/udevd -d root 2669 0.0 0.0 4312 32 tty6 Ss+ Aug14 0:00 /sbin/mingetty /dev/tty6 root 2797 0.0 0.0 0 0 ? S Aug14 0:12 [kworker/u30:2] ntp 2821 0.0 0.1 29288 1808 ? Ss Aug14 0:01 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g apache 12405 0.1 4.2 471264 42920 ? S Aug22 1:08 /usr/sbin/httpd apache 12412 0.1 3.6 466372 37440 ? S Aug22 1:07 /usr/sbin/httpd apache 12413 0.1 4.1 487140 42788 ? S Aug22 1:09 /usr/sbin/httpd apache 12416 0.1 3.8 466764 39020 ? S Aug22 1:12 /usr/sbin/httpd apache 12417 0.1 4.3 474916 44180 ? S Aug22 1:09 /usr/sbin/httpd apache 12418 0.1 3.9 466596 40108 ? S Aug22 1:07 /usr/sbin/httpd apache 12419 0.1 4.1 483704 42392 ? S Aug22 1:08 /usr/sbin/httpd root 12960 0.0 0.0 0 0 ? S Aug22 0:00 [kworker/u30:0] apache 14977 0.7 4.2 485100 43372 ? S Aug21 24:02 /usr/sbin/httpd apache 14978 0.7 4.1 489860 42536 ? S Aug21 23:32 /usr/sbin/httpd apache 14979 0.7 4.3 484092 44816 ? S Aug21 23:51 /usr/sbin/httpd apache 14980 0.7 4.1 491120 42312 ? S Aug21 24:01 /usr/sbin/httpd apache 14981 0.7 4.1 491984 42732 ? S Aug21 23:34 /usr/sbin/httpd apache 14982 0.7 4.2 491680 43680 ? S Aug21 23:43 /usr/sbin/httpd apache 14983 0.7 4.1 491768 42404 ? S Aug21 23:28 /usr/sbin/httpd apache 14984 0.7 4.0 490436 41508 ? S Aug21 23:42 /usr/sbin/httpd apache 15030 0.7 4.3 486920 44224 ? S Aug21 23:39 /usr/sbin/httpd apache 15040 0.6 4.7 486704 48124 ? S Aug21 23:11 /usr/sbin/httpd apache 15343 0.6 4.0 484224 41632 ? S Aug21 22:56 /usr/sbin/httpd apache 16238 0.6 4.1 486556 41812 ? S Aug21 22:34 /usr/sbin/httpd root 17169 0.0 0.6 115740 6536 ? Ss 10:58 0:00 sshd: ec2-user [priv] ec2-user 17171 0.0 0.5 115740 5140 ? S 10:58 0:00 sshd: ec2-user@pts/0 ec2-user 17172 0.0 0.3 115476 3320 pts/0 Ss 10:58 0:00 -bash ec2-user 17227 4.0 0.2 117204 2340 pts/0 R+ 10:58 0:00 ps aux ec2-user 21561 0.0 0.0 113084 0 ? S Aug21 0:00 /bin/sh /home/ec2-user/bin/startJayServer.sh ec2-user 21562 49.2 7.2 2283928 73668 ? Sl Aug21 1393:33 java -server com.jayavon.game.server.MyServer -PROD apache 24084 0.5 4.4 486596 45336 ? S Aug21 14:53 /usr/sbin/httpd 
1
kannst du die entsprechende Ausgabe von `ps aux && free 'editieren? Matt Clark vor 7 Jahren 0
Beachten Sie auch, dass MySQL Server (oftmals das Opfer) (http://dba.stackexchange.com/a/25171/11651) ist und nicht die Ursache von Speichererschöpfungsproblemen. Michael - sqlbot vor 7 Jahren 0
@MattClark Ich habe die angeforderten Ausgaben hinzugefügt. Entschuldigung, es hat so lange gedauert, dass ich geschlafen habe. Schätze wirklich deine Hilfe! KisnardOnline vor 7 Jahren 0
Aus der Ausgabe von "ps aux" scheint es, dass der gesamte Arbeitsspeicher von _httpd_ belegt wird. Im Ausdruck kann ich ~ 19 httpd Prozess sehen, der jeweils ~ 40MiB = ~ 750 + MiB verbraucht. Matt Clark vor 7 Jahren 0
Sie können in Tuning-Handbüchern nach httpd / apache (2) suchen. Matt Clark vor 7 Jahren 0
Danke Matt - ich werde das prüfen! Wenn Sie daraus eine Antwort machen, werde ich sie als akzeptiert markieren :) KisnardOnline vor 7 Jahren 0

1 Antwort auf die Frage

1
Matt Clark

Standardmäßig topwerden Prozesse nach CPU-Auslastung sortiert. Es scheint also, dass der gesamte Arbeitsspeicher nicht viel CPU-Zeit beansprucht.

Um topnach RESidentem Speicher zu sortieren, verwenden Sie

top -o RES # or top -o MEM  # commands may vary slightly depending on distros 

In dem Ausdruck ps aux, den Sie zur Verfügung gestellt haben, können wir sehen, dass es ~ 20 httpd- Prozesse gibt, von denen jeder 40MiB = ~ 800MiB wertvollen RAM verbraucht.

Sie können in den Tuning-Anleitungen für httpd / apache2 nachsehen.