Fitting mysql and apache on a lowend linode

Just wondering how many people try and run mysql and apache on a lowend linode and end up without any memory.

9 Replies

I have the lowest end linode (64?) and run apache2 and mysql 4 on gentoo…i dont have a whole lot left over, but have some:

Tasks: 32 total, 1 running, 31 sleeping, 0 stopped, 0 zombie

Cpu(s): 0.0% user, 0.0% system, 0.0% nice, 100.0% idle

Mem: 59912k total, 41864k used, 18048k free, 6804k buffers

Swap: 263160k total, 5872k used, 257288k free, 16296k cached

I've got Debian on a Linode 64, running mysql and apache. I don't have much left over either, especially since I have the apache threads with significant amounts of perl code cached. But that's basically all the box does, and it does fine.

CPU states:   0.0% user,   0.0% system,   0.0% nice,  100.0% idle
Mem:     59908K total,    53568K used,     6340K free,     8812K buffers
Swap:   191456K total,    12816K used,   178640K free,    18256K cached

There are various things I do. I can't prove that they all work, but I can try. There are a few things I too have yet to get around too.

First I compile MySQL with the following options:

./configure –prefix=/usr/local/mysql --enable-thread-safe-client --enable-assembler --with-low-memory --enable-local-infile

Secondly I use the my-small.cnf file

cp /usr/local/mysql/share/mysql/my-small.cnf /etc/my.cnf

Lastly I choose to enable skip-networking in my.cnf because I do not need it (everyone connects via local socket), we can assume this saves a few kilobytes of memory!(lol)

For apache2, I compile with:

./configure --enable-deflate --enable-logio --enable-log-config --enable-headers --enable-ssl --enable-http --enable-rewrite --enable-so --prefix=/usr/local/apache

Additionally I have apache use /dev/urandom as a place for entroy because /dev/random is supposed to take more CPU ?

The one thing I have yet to figure out myself is how to tweak all those MPM settings. shrug

Hope these random bits of info help

Bill Clinton

I've currently have mysql, apache, proftpd, postfix, and courier (imap and pop3) running. There doesn't appear to be any RAM issues yet.

However I don't have any users yet since I am waiting on DNS servers to start directing the traffic to me. I have uses phpmyadmin and phpwiki on it without any issues.

I looked into using my-small, but I believe it has an impact on performance. It's designed to make mysql use less memory in situations where it's infrequently used. It's one of the main tasks of my box, so I chose to go with the regular my.conf. YMMV.

Also, Bill, I don't think /dev/urandom vs /dev/random is a CPU issue too much. The only difference is that when the kernel hasn't got enough entropy built up, /dev/random blocks and waits for more to come (from I/O, e.g.) whereas /dev/urandom will always return something, and that something may theoretically be predictable. In practice it may not matter.

I've got MySQL, PHP, Apache, Sendmail, Spamassassin all running fairly well on a Linode 64. Right now I have about 1200 Kb free memory and about half my 128 Mb swap used. Load average is usually around 0.5 and I use about 2% of the host cpu. None of my MySQL sites are really busy though.

There has been a few occasions when things have almost ground to a halt and the load average has shot up to around 12 and sendmail has rejected connections. I haven't been able to link it to any flurry of activity in the logs so now I'm dumping ps aux to a file every minute so if it happens again I'll hopefully have a snapshot of what's happening.

Having said that, things seem to be going particularly well right now. Last night I upraded MySQL to 4.0.18 from the rpm and Spamassassin to 2.6.3. I've been finding things a bit slow in general lately even when the load average is low but suddenly everything is running very well again like it was when I joined. I'm not sure if its related to my upgrades or the 2.4.25 kernel upgrade or something has just happened on Host 8.

You didn't mention if you are running Spamassassin but it is quite a memory hog. Maybe there is a lower footprint alternative.

I'm experimenting with a small query cache (2Mb) with MySQL. I'm not sure if its making much difference yet but I suspect even a small cache could make a big difference depending on the query behaviour of your applications especially if you could modify the code so that only the small frequent, seldom changed queries are in the cache.

I have a question. I compilied PHP with most of the extras. My libphp4.so file is a bit over 11 Mb. Does that have an effect on the memory that Apache uses? I seems like it should but 'top' lists the httpd processes size as a bit over 3332 Kb. Is it worth me trying to reduce the libphp4.so file size by taking out features I'm not using?

Cheers

Ross

@tetranz:

My libphp4.so file is a bit over 11 Mb. Does that have an effect on the memory that Apache uses?

No, it does not have an effect on the memory apache uses.

Chances are your libphp4.so file has not been stripped of its debugging information. By doing "strip libphp4.so" you will remove such information and greatly reduce the size of your file.

Whether a module is stripped or not does not have an effect on the performance of that file or the applications that use that file

Blll Clinton

One idea is to consider using SQLite instead of MySQL. It doesn't use a server, just a file, which translates to much less memory usage. Apparently, it's actually faster than MySQL, and it's definitely more than enough for most small servers. PHP 5.0 will actually use it as the default. Check it out: http://www.sqlite.com/

For PHP 4.3x users, you can just do a pear install sqlite on the command line and then add extension=sqlite.so to your php.ini. Debian users will want to have php4-dev, php4-cgi, and php4-pear installed first for this to work. You do not need sqlite installed.

@tetranz:

There has been a few occasions when things have almost ground to a halt and the load average has shot up to around 12 and sendmail has rejected connections. I haven't been able to link it to any flurry of activity in the logs so now I'm dumping ps aux to a file every minute so if it happens again I'll hopefully have a snapshot of what's happening.

I doubt that this has much to do with your specific configuration. A Linode can grind to a halt at load 12 without even doing anything, if other Linodes on the box are thrashing the disk. It happens sometimes. I am currently monitoring my Linode64 on host5 by doing an uptime every 15 seconds to see the load. I haven't looked at the results in a couple of days but in my first few days of monitoring I saw my Linode's host shoot up to 3, 4, 5, and yes, even 12, when it wasn't even doing anything. This would happen a few times per day. I'll post a summary once I have collected a week's worth of data.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct