PDA

View Full Version : Why eats my Knoppix so much memory?



Photonix
05-26-2004, 11:31 PM
Hi there,

Iīm very new to Knoppix and Linux, but although being a Newbie I set up a Webserver including Apache,Mysql,SSH and Samba within 3 afternoons
(hoorray :) ).

Before I start to explain my problem I want you to know my system details:
Knoppix 3.4 HDD-Install
AMD K6 500Mhz
192MB Memory
8GB HDD (1GB Linux Swap)
Connected to Internet via DSL over Router
10Mbit LAN

As I wanted to start developing on the server I recognized itīs behaving extremely slow. phpSysInfo tells me Knoppix uses always over 85% of Physical Memory and seldom more than 2% of Disk Swap.

Because of the server is behaving that dull, most of the clients which want to connect over Internet get timeout errors, even in my LAN it takes up to 12 seconds for the webpages to be shown.

And I don't know where this comes from.. :?

I already took KDE off the start-inits but it still behaves the same.

Pinging the server is working fine, itīs responding below 1ms.

Hope someone can help me here...


If you want to, you can have a look at http://photonix.ath.cx/ , phpSysinfo will be shown.

user unknown
05-27-2004, 02:55 AM
Well - 192 MB isn't that much.

If your System isn't a Laptop, additional RAM will be quiete cheap.
Perhaps you may configure apache to use less memory, or samba, or mysql, or php.
sshd shouldn't use that much memory but you know: What you think is false - prove it!

So start 'top', hit 'M' ('m' might be usefull too) and look, who's eating ram.
Do you need a webserver and a samba-server?

Photonix
05-27-2004, 09:45 AM
Mh I need samba for copying my on Windows developed files, don't want to use ftp for that.

I thought 192MB would be enough for Linux...

I will try 'top' and let you know what it says..

Could anyone open photonix.ath.cx? At my company, with a Novel Border Manager, I canīt...

Photonix
05-27-2004, 02:04 PM
That's what top is telling me.
miniserv.pl can comes from Webmin IMHO.



PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
__________________________________________________ ____________________
647 mysql 9 0 6056 6052 2584 S 0.0 3.2 0:00.12 mysqld
649 mysql 8 0 6056 6052 2584 S 0.0 3.2 0:00.01 mysqld
650 mysql 9 0 6056 6052 2584 S 0.0 3.2 0:00.00 mysqld
653 mysql 9 0 6056 6052 2584 S 0.0 3.2 0:00.00 mysqld
1831 root 10 0 4952 4944 4280 S 0.0 2.6 0:00.05 miniserv.pl
1837 root 10 0 4952 4944 4280 S 0.0 2.6 0:00.04 miniserv.pl
1839 root 10 0 4952 4944 4304 S 0.0 2.6 0:00.01 miniserv.pl
699 root 8 0 4948 4940 4300 S 0.0 2.6 0:01.62 miniserv.pl
563 root 9 0 4560 4556 4440 S 0.0 2.4 0:00.23 apache
570 www-data 9 0 4560 4556 4452 S 0.0 2.4 0:00.00 apache
571 www-data 9 0 4560 4556 4452 S 0.0 2.4 0:00.00 apache
572 www-data 9 0 4560 4556 4452 S 0.0 2.4 0:00.01 apache
573 www-data 9 0 4560 4556 4452 S 0.0 2.4 0:00.00 apache
574 www-data 9 0 4560 4556 4452 S 0.0 2.4 0:00.00 apache
665 root 9 0 2960 2960 1984 S 0.0 1.5 0:00.01 smbd
1650 root 9 0 2452 2452 1244 S 0.0 1.3 0:00.44 bash
577 root 8 0 1972 1968 1380 S 0.0 1.0 0:00.00 mount.smbfs
1506 root 9 0 1944 1940 1684 S 0.0 1.0 0:00.06 sshd
661 root 9 0 1872 1868 1404 S 0.0 1.0 0:00.03 nmbd
582 root 9 0 1568 1568 1192 S 0.0 0.8 0:00.06 cupsd
672 root 9 0 1448 1448 1316 S 0.0 0.8 0:00.47 sshd
608 root 9 0 1232 1232 1024 S 0.0 0.6 0:00.06 mysqld_safe
1662 root 17 0 1040 1040 840 R 0.7 0.5 0:00.53 top
446 root 9 0 632 632 544 S 0.0 0.3 0:00.00 automount


That's the headline of 'top':


Tasks: 37 total, 1 running, 36 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% user, 0.3% system, 0.0% nice, 99.3% idle
Mem: 191440k total, 138116k used, 53324k free, 7540k buffers
Swap: 1084376k total, 0k used, 1084376k free, 106912k cached



The server behaved also dull after I terminated every process except from apache..
:?

user unknown
05-27-2004, 04:08 PM
Yes, I could open the php-page, and found a load of 95% too.
I even thoght 2 seconds of trying a ssh-login :)
- hey - only 84% now -

There are 6 apaches, 4 miniservs and 4 mysqlds running, - for fast answering to multiple requests.
Well that isn't very much, but the question is, how many users use the services, how often, and probably at the same time.

You might reduce the number of apaches and mysqlds in the conf-files.
But obviously the php-Page is for a good part measuring itself.

I would repeate the top-session, and while running top, start the php-script, to see, how much memory and cpu it is using. With 's' '1' you may set the interval for top to 1 (sleep, seconds?).

160 MB used - reportet by php, and 140 MB, reported by top, makes a difference of 20 MB for the php-task!

But both scenarios leave some memory free - 30 or 50 MB. So swapping doesn't seem to be involved.
The cpu-usage is very low - so no buggy program...
Is only the first request that slow, or does a second, invoked shortly later, need the same time? I'm thinking of some apm/ acpi saving power and sending harddrive to sleep...

user unknown
05-27-2004, 04:12 PM
Either there is some caching, or some sleeping involved.
I tried a request - about 12 s.
A repeated request: ca. 4 s.

This might indicate something :)

Photonix
05-27-2004, 05:44 PM
Hi,

thanks for your answers...as I read your mention of acpi I thought "that's the clue".
I remebered the serverīs screen is getting black after a time of idleness. But as I woke him up nothing was going faster than before.
Also, apmd isn't activated. But maybe there is another daemon which handles the hdd that I don't know...(being a newbie)... :D

And only a maximum of 2 people are using the server, so there is no heavy load.

What entry do I have to change in the mysql/apache conf-files to make them use less processes?

And while youīre living in the same country like I do, you know logging into someone other's SSH is forbidden by law :)
Und was sich reimt ist gut :lol:

user unknown
05-27-2004, 11:39 PM
I'm not running apache, nor mySql.
I don't need a webserver.
And use postgresql as database-server.

but apache2 is installed, and in
/usr/local/apache2/conf/httpd.conf
there is a section, starting like this
##
## Server-Pool Size Regulation (MPM specific)
##
with settings for this and that.

for mySql search on your own.

Photonix
05-28-2004, 12:26 PM
Ok, after I regulated the pool-size it's only 65% memory in usage...
hm but still not satisfying I think..

user unknown
05-28-2004, 02:24 PM
My measurement:


Mem: 256336k total, 47744k used, 208592k free, 6856k buffers
Swap: 530104k total, 0k used, 530104k free, 24456k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND
193 stefan 15 0 5968 2440 4968 S 0.0 1.0 0:00 bash
194 postgres 15 0 5776 2432 4748 S 0.0 0.9 0:00 bash
190 root 16 0 5736 2416 4748 S 0.0 0.9 0:00 bash
319 postgres 16 0 16612 1940 15m S 0.0 0.8 0:00 postmaster
325 postgres 19 0 7692 1744 6948 S 0.0 0.7 0:00 postmaster
324 postgres 19 0 8684 1732 6948 S 0.0 0.7 0:00 postmaster
404 root 16 0 6740 1708 5028 S 0.0 0.7 0:00 cupsd
336 root 15 0 2928 1340 2164 S 0.0 0.5 0:00 xitami
185 root 16 0 2384 1292 1360 S 0.0 0.5 0:00 klogd
165 root 16 0 2400 1056 2024 S 0.0 0.4 0:00 pppd
485 stefan 16 0 2064 960 1856 R 0.0 0.4 0:00 top
180 root 15 0 2164 808 1608 S 0.0 0.3 0:00 pppstatus
135 root 17 0 1732 676 1504 S 0.0 0.3 0:00 pump
183 root 16 0 1700 632 1408 S 0.0 0.2 0:00 syslogd
363 root 16 0 1528 504 1368 S 0.0 0.2 0:00 pppoe
191 root 16 0 1640 472 1352 S 0.0 0.2 0:00 getty
192 root 16 0 1640 472 1352 S 0.0 0.2 0:00 getty
195 root 16 0 1640 472 1352 S 0.0 0.2 0:00 getty
1 root 16 0 80 80 56 S 0.0 0.0 0:04 init
2 root 34 19 0 0 0 S 0.0 0.0 0:00 ksoftirqd/0
3 root 5 -10 0 0 0 S 0.0 0.0 0:00 events/0

SQL-Server: Postgres
HTTP-Servr: xitami
PHP: - none-

note:
- I didn't run any request for xitami and postgres.
- when I start X, and stop it, not all memory is shown as 'available'.

PS: Your server is now reponding in about 3 sec., even for the first request.

roger_girardin
05-29-2004, 04:35 AM
i have a similar comp

i have installed by hand (apt-get) on a woody os

i can't give you the link for testing
==> someone has cracked it and changed the root pass

i have no time now to look for the solution

Photonix
05-30-2004, 09:45 PM
After donating my server additional 64MB of RAM (I know itīs not much but I only have 2 banks of RAM available, so I replaced a 64MB with a 128MB) I believe there must be something completely wrong with it..

It still eats up to 95% (with opened dselect) of the Memory, at the moment 85%.

What happens If I put 512 or more MB in it? Will it still continue to gorge my mem?

:(

Any suggestions?

user unknown
05-31-2004, 03:48 AM
Is the amount of memory used all the time, or only at a peak, while the script is running?
I would start top first, then call the server, and compare the values, and compare it to the usage after a while - few seconds.

OErjan
05-31-2004, 09:41 AM
wait a minue here. could we se a dump frpm top please. you see linux never reclaims used memory. it keeps the "cashe" there as long as there is no demand for more ram. linux reasons that memory is faster than the fastest hdd so beter use all available instead of swapping when not needed.

Dave_Bechtel
05-31-2004, 09:57 AM
--Whaaaaaat? Of *course* Linux reclaims used memory. That's what the swap space is used for, among other things. Do a google search on "swappiness":

http://kerneltrap.org/node/view/3000


wait a minue here. could we se a dump frpm top please. you see linux never reclaims used memory. it keeps the "cashe" there as long as there is no demand for more ram. linux reasons that memory is faster than the fastest hdd so beter use all available instead of swapping when not needed.

Dave_Bechtel
05-31-2004, 10:19 AM
--Here's something I noticed right off the bat:

[[ Before I start to explain my problem I want you to know my system details:
Knoppix 3.4 HDD-Install
AMD K6 500Mhz
192MB Memory
8GB HDD (1GB Linux Swap)
Connected to Internet via DSL over Router
10Mbit LAN
]]

--First of all, an AMD K6 is not the best thing to be running a server on. Personal experience with older AMD's tells me they're flaky, and generally slower than Intels at the same speed rating. If you can get a faster (used, even) machine with an Intel (or AMD Athlon/Duron) of 800MHz or better, that would be a good step. However, I realize that $$$/resources may be limited, so I will try other suggestions as well. (My "fast" machine is currently a 900MHz AMD Duron because they were more affordable at the time, so I know whereof I speak.)

--Try enabling DMA and 32-bit mode using hdparm:
' hdparm -c1 -d1 -u1 /dev/hda '

--This should speed up the hard drive. (If you start getting DMA errors, shutdown immediately and reboot - and do not re-enable the hdparm.)

--Increase the RAM to at least 256MB, if possible. More is better. If using the machine as a server, do not run anything else on it (disable all GUI, and do not use it as a desktop machine.)

--Replace the 10MBit LAN card with 100MBit. Trust me, it makes a difference. However, you also need 100MBit infrastructure (hub/switch, cat5) to really take advantage of it. Personally, I was happy with 10mbit myself until switching to 100. Worth the investment -- 10mbit only does about 700KB/sec, while 100mbit does ~10 times that.

--Recompile your kernel. I can send you a sample config file, if you want. Especially if you're using the default one that came with an older Knoppix, it's worth your while to tweak it for your specific hardware -- you can save disk space (delete old modules after you get things working right) and memory, and compile things for your specific architecture. My Linuxtips page at the bottom of all my posts has more info on kernel recompiling.

--Outside of that, I know there are things to speedup Apache and the rest, but I don't have personal experience with them. (I'm currently only running Squid on a 233MHz Pentium-1 for my Internet needs.) Your best bet is to google around for speedup tips, and maybe find a guru in your area to also help you with config tips.

--BTW, what kind of web pages are you loading?

OErjan
05-31-2004, 10:27 AM
it reclaims it when needed, not before.

Photonix
06-01-2004, 02:24 PM
I overlooked the second page, thanks for your comments Dave.

I will try the hints you gave me.

Concerning the 10Mbit: Iīm connected over a 10Mbit router, the card can 100Mbit.

Iīm a web-developer and currently working on a shop-system, so I understand with database and all the stuff there can be a heavy load, but I didn`t expect it to be sooo slow.

Iīm already a little bit fed up with that, thinking already to switch back to windows.

On another port on a different machine I run a windows-server with similar hardware-components, and the sites are served like a bat outta hell. :?:

(Iīm not biased at all, I just see the facts)

I already tried to uninstall a lot of software, but with no effect.

Maybe, If time permits, I will try another linux distribution, it seems knoppix is not suitable for my needs :?

user unknown
06-01-2004, 05:57 PM
Sorry, Dave, but I have to disagree.

Performance-Tuning without investigation for the bottleneck, is a waste of time and money and hoping for X-mas.

The page is of less than 14 kb.
A 10 Mbit connection should send it in less than 0.1s.

As far as I understood Photonix, only few users will use this server, so investing in a new CPU would be a buisiness-solution - perhaps.

Photonix: Uninstalling software is giving you hd-space. Will not speed up anything, nor free memory.

You didn't answer my question, about the memory-peek. Not interested?

Photonix
06-01-2004, 06:24 PM
Hi unknown,

unfortunately there are no indications for memory peaks while accessing the server (I observe top via SSH). Nor are there CPU-peaks. If there WERE peaks, they would be so short they wouldnīt bother...

Paradoxically sometimes the pages loads *** fast, in less than 1 sec. It's mainly when I access pages with more database-querys than html-words :) But thatīs really seldom.

Maybe thatīs a clue, maybe itīs purely apache which causes troubles.

Though I don't know...

Photonix
06-01-2004, 06:25 PM
[double post]

user unknown
06-01-2004, 08:51 PM
And did you test how fast php is?

Perhaps you find better hints in a LAMP-Forum.
I guess it's a question of your configuration, or of the implementation of your pages.

But claiming apache to be slow is a very fast judgement.
Keep in mind that most webserver run apache, and ran apache, when 500 Mhz was fast.

Photonix
06-01-2004, 09:15 PM
I know that :) And I know it must be a configuration problem. But I believe the problem stems not from me as I changed quite nothing in knoppix' / apache configuration.